Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,7 +12,30 @@ from tools.catering_service_tool import SimpleTool as CateringServiceTool
|
|
| 12 |
from tools.superhero_party_theme_generator import SuperheroPartyThemeTool as SuperheroPartyThemeGenerator
|
| 13 |
from tools.final_answer import FinalAnswerTool as FinalAnswer
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
model = HfApiModel(
|
| 18 |
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
|
|
|
|
| 12 |
from tools.superhero_party_theme_generator import SuperheroPartyThemeTool as SuperheroPartyThemeGenerator
|
| 13 |
from tools.final_answer import FinalAnswerTool as FinalAnswer
|
| 14 |
|
| 15 |
+
# Add OpenTelemetry instrumentation
|
| 16 |
+
from opentelemetry.sdk.trace import TracerProvider
|
| 17 |
+
from openinference.instrumentation.smolagents import SmolagentsInstrumentor
|
| 18 |
+
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
|
| 19 |
+
from opentelemetry.sdk.trace.export import SimpleSpanProcessor
|
| 20 |
|
| 21 |
+
# Setup tracing if environment variables are present
|
| 22 |
+
if "LANGFUSE_PUBLIC_KEY" in os.environ and "LANGFUSE_SECRET_KEY" in os.environ:
|
| 23 |
+
# Prepare authentication
|
| 24 |
+
LANGFUSE_PUBLIC_KEY = os.environ.get("LANGFUSE_PUBLIC_KEY")
|
| 25 |
+
LANGFUSE_SECRET_KEY = os.environ.get("LANGFUSE_SECRET_KEY")
|
| 26 |
+
LANGFUSE_AUTH = base64.b64encode(f"{LANGFUSE_PUBLIC_KEY}:{LANGFUSE_SECRET_KEY}".encode()).decode()
|
| 27 |
+
|
| 28 |
+
# Set OTEL environment variables
|
| 29 |
+
os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = "https://cloud.langfuse.com/api/public/otel" # EU region
|
| 30 |
+
os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = f"Authorization=Basic {LANGFUSE_AUTH}"
|
| 31 |
+
|
| 32 |
+
# Setup tracing
|
| 33 |
+
trace_provider = TracerProvider()
|
| 34 |
+
trace_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter()))
|
| 35 |
+
SmolagentsInstrumentor().instrument(tracer_provider=trace_provider)
|
| 36 |
+
print("Langfuse tracing enabled")
|
| 37 |
+
|
| 38 |
+
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
|
| 39 |
|
| 40 |
model = HfApiModel(
|
| 41 |
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
|