gpaasch commited on
Commit
a2aa52e
·
1 Parent(s): aa41e1c

added commented out agent code template for later, added langfuse monitoring code

Browse files
Files changed (4) hide show
  1. app.py +8 -0
  2. langfuse_auth.py +10 -0
  3. requirements.txt +4 -0
  4. start_langfuse_tracking.py +10 -0
app.py CHANGED
@@ -30,3 +30,11 @@ if st.button('Add Task'):
30
  tasks["descriptions"].append(task_description)
31
  tasks["completion_time_estimates"].append(task_time_estimate)
32
 
 
 
 
 
 
 
 
 
 
30
  tasks["descriptions"].append(task_description)
31
  tasks["completion_time_estimates"].append(task_time_estimate)
32
 
33
+ '''
34
+ # agent code for later
35
+ from smolagents import CodeAgent, HfApiModel
36
+
37
+ agent = CodeAgent(tools=[], model=HfApiModel())
38
+ alfred_agent = agent.from_hub('sergiopaniego/AlfredAgent', trust_remote_code=True)
39
+ alfred_agent.run("Give me the best playlist for a party at Wayne's mansion. The party idea is a 'villain masquerade' theme")
40
+ '''
langfuse_auth.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import base64
3
+
4
+ LANGFUSE_PUBLIC_KEY="pk-lf-..."
5
+ LANGFUSE_SECRET_KEY="sk-lf-..."
6
+ LANGFUSE_AUTH=base64.b64encode(f"{LANGFUSE_PUBLIC_KEY}:{LANGFUSE_SECRET_KEY}".encode()).decode()
7
+
8
+ os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = "https://cloud.langfuse.com/api/public/otel" # EU data region
9
+ # os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = "https://us.cloud.langfuse.com/api/public/otel" # US data region
10
+ os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = f"Authorization=Basic {LANGFUSE_AUTH}"
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ streamlit
2
+ opentelemetry-sdk
3
+ opentelemetry-exporter-otlp
4
+ openinference-instrumentation-smolagents
start_langfuse_tracking.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ from opentelemetry.sdk.trace import TracerProvider
2
+
3
+ from openinference.instrumentation.smolagents import SmolagentsInstrumentor
4
+ from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
5
+ from opentelemetry.sdk.trace.export import SimpleSpanProcessor
6
+
7
+ trace_provider = TracerProvider()
8
+ trace_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter()))
9
+
10
+ SmolagentsInstrumentor().instrument(tracer_provider=trace_provider)