smolagent-tuto / src /agent.py
ruaultadrienperso's picture
Implement ruff with proper checks
d2bb213
raw
history blame contribute delete
955 Bytes
"""Sandbox for using the smolagents library."""
import base64
import os
from openinference.instrumentation.smolagents import SmolagentsInstrumentor
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleSpanProcessor
def setup_langfuse() -> None:
"""Setups Langfuse."""
langfuse_auth = base64.b64encode(
f"{os.getenv('LANGFUSE_PUBLIC_KEY')}:{os.getenv('LANGFUSE_SECRET_KEY')}".encode(),
).decode()
os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = (
"https://cloud.langfuse.com/api/public/otel" # EU data region
)
os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = f"Authorization=Basic {langfuse_auth}"
trace_provider = TracerProvider()
trace_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter()))
SmolagentsInstrumentor().instrument(tracer_provider=trace_provider)