Merge branch 'main' into lg-agent-initialize

This commit is contained in:
Lucas Gomide
2025-06-19 13:56:39 -03:00
committed by GitHub

View File

@@ -30,18 +30,29 @@ Set your Langfuse API keys and configure OpenTelemetry export settings to send t
```python ```python
import os import os
import base64
# Get keys for your project from the project settings page: https://cloud.langfuse.com
os.environ["LANGFUSE_PUBLIC_KEY"] = "pk-lf-..."
os.environ["LANGFUSE_SECRET_KEY"] = "sk-lf-..."
os.environ["LANGFUSE_HOST"] = "https://cloud.langfuse.com" # 🇪🇺 EU region
# os.environ["LANGFUSE_HOST"] = "https://us.cloud.langfuse.com" # 🇺🇸 US region
# Your OpenAI key
os.environ["OPENAI_API_KEY"] = "sk-proj-..."
```
With the environment variables set, we can now initialize the Langfuse client. get_client() initializes the Langfuse client using the credentials provided in the environment variables.
LANGFUSE_PUBLIC_KEY="pk-lf-..." ```python
LANGFUSE_SECRET_KEY="sk-lf-..." from langfuse import get_client
LANGFUSE_AUTH=base64.b64encode(f"{LANGFUSE_PUBLIC_KEY}:{LANGFUSE_SECRET_KEY}".encode()).decode()
langfuse = get_client()
os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = "https://cloud.langfuse.com/api/public/otel" # EU data region
# os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = "https://us.cloud.langfuse.com/api/public/otel" # US data region # Verify connection
os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = f"Authorization=Basic {LANGFUSE_AUTH}" if langfuse.auth_check():
print("Langfuse client is authenticated and ready!")
# your openai key else:
os.environ["OPENAI_API_KEY"] = "sk-..." print("Authentication failed. Please check your credentials and host.")
``` ```
### Step 3: Initialize OpenLit ### Step 3: Initialize OpenLit