kuzumab commited on
Commit
59831ad
·
verified ·
1 Parent(s): b3f1706

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -1
app.py CHANGED
@@ -8,6 +8,16 @@ import io
8
  # (Keep Constants as is)
9
  # --- Constants ---
10
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
 
 
 
 
 
 
 
 
 
 
11
 
12
  class AttachmentDownloadTool(Tool):
13
  name = "attachment_downloader"
@@ -168,7 +178,25 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
168
  api_url = DEFAULT_API_URL
169
  questions_url = f"{api_url}/questions"
170
  submit_url = f"{api_url}/submit"
171
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  # 1. Instantiate Agent ( modify this part to create your agent)
173
  try:
174
  agent = BasicAgent()
 
8
  # (Keep Constants as is)
9
  # --- Constants ---
10
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
11
+ # Get your own keys from https://cloud.langfuse.com
12
+ os.environ["LANGFUSE_HOST"] = "https://cloud.langfuse.com" # 🇪🇺 EU region example
13
+ # os.environ["LANGFUSE_HOST"] = "https://us.cloud.langfuse.com" # 🇺🇸 US region example
14
+
15
+ LANGFUSE_AUTH = base64.b64encode(
16
+ f"{os.getenv('LANGFUSE_PUBLIC_KEY')}:{os.getenv('LANGFUSE_SECRET_KEY')}".encode()
17
+ ).decode()
18
+
19
+ os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = os.environ.get("LANGFUSE_HOST") + "/api/public/otel"
20
+ os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = f"Authorization=Basic {LANGFUSE_AUTH}"
21
 
22
  class AttachmentDownloadTool(Tool):
23
  name = "attachment_downloader"
 
178
  api_url = DEFAULT_API_URL
179
  questions_url = f"{api_url}/questions"
180
  submit_url = f"{api_url}/submit"
181
+
182
+ from opentelemetry.sdk.trace import TracerProvider
183
+ from openinference.instrumentation.smolagents import SmolagentsInstrumentor
184
+ from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
185
+ from opentelemetry.sdk.trace.export import SimpleSpanProcessor
186
+
187
+ # Create a TracerProvider for OpenTelemetry
188
+ trace_provider = TracerProvider()
189
+
190
+ # Add a SimpleSpanProcessor with the OTLPSpanExporter to send traces
191
+ trace_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter()))
192
+
193
+ # Set the global default tracer provider
194
+ from opentelemetry import trace
195
+ trace.set_tracer_provider(trace_provider)
196
+ tracer = trace.get_tracer(__name__)
197
+
198
+ # Instrument smolagents with the configured provider
199
+ SmolagentsInstrumentor().instrument(tracer_provider=trace_provider)
200
  # 1. Instantiate Agent ( modify this part to create your agent)
201
  try:
202
  agent = BasicAgent()