Spaces:
Running
Running
Commit
·
e126484
1
Parent(s):
ac3a2b0
test out langfuse
Browse files- app.py +24 -1
- requirements.txt +4 -0
app.py
CHANGED
|
@@ -5,8 +5,31 @@ import pytz
|
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
|
|
|
|
|
|
|
|
|
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
@tool
|
| 11 |
def multiplication_tool(arg1:int, arg2:int)-> int:
|
| 12 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
|
@@ -56,7 +79,7 @@ agent = CodeAgent(
|
|
| 56 |
model=model,
|
| 57 |
tools=[final_answer,multiplication_tool,image_generation_tool],
|
| 58 |
max_steps=6,
|
| 59 |
-
verbosity_level=1,
|
| 60 |
grammar=None,
|
| 61 |
planning_interval=None,
|
| 62 |
name=None,
|
|
|
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
|
| 8 |
+
import os
|
| 9 |
+
import base64
|
| 10 |
+
|
| 11 |
from Gradio_UI import GradioUI
|
| 12 |
|
| 13 |
+
LANGFUSE_PUBLIC_KEY = os.getenv("LANGFUSE_PUBLIC_KEY")
|
| 14 |
+
LANGFUSE_SECRET_KEY = os.getenv("LANGFUSE_SECRET_KEY")
|
| 15 |
+
|
| 16 |
+
LANGFUSE_AUTH=base64.b64encode(f"{LANGFUSE_PUBLIC_KEY}:{LANGFUSE_SECRET_KEY}".encode()).decode()
|
| 17 |
+
|
| 18 |
+
#os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = "https://cloud.langfuse.com/api/public/otel" # EU data region
|
| 19 |
+
os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = "https://us.cloud.langfuse.com/api/public/otel" # US data region
|
| 20 |
+
os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = f"Authorization=Basic {LANGFUSE_AUTH}"
|
| 21 |
+
|
| 22 |
+
from opentelemetry.sdk.trace import TracerProvider
|
| 23 |
+
|
| 24 |
+
from openinference.instrumentation.smolagents import SmolagentsInstrumentor
|
| 25 |
+
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
|
| 26 |
+
from opentelemetry.sdk.trace.export import SimpleSpanProcessor
|
| 27 |
+
|
| 28 |
+
trace_provider = TracerProvider()
|
| 29 |
+
trace_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter()))
|
| 30 |
+
|
| 31 |
+
SmolagentsInstrumentor().instrument(tracer_provider=trace_provider)
|
| 32 |
+
|
| 33 |
@tool
|
| 34 |
def multiplication_tool(arg1:int, arg2:int)-> int:
|
| 35 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
|
|
|
| 79 |
model=model,
|
| 80 |
tools=[final_answer,multiplication_tool,image_generation_tool],
|
| 81 |
max_steps=6,
|
| 82 |
+
# verbosity_level=1,
|
| 83 |
grammar=None,
|
| 84 |
planning_interval=None,
|
| 85 |
name=None,
|
requirements.txt
CHANGED
|
@@ -3,3 +3,7 @@ smolagents
|
|
| 3 |
requests
|
| 4 |
duckduckgo_search
|
| 5 |
pandas
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
requests
|
| 4 |
duckduckgo_search
|
| 5 |
pandas
|
| 6 |
+
|
| 7 |
+
opentelemetry-sdk
|
| 8 |
+
opentelemetry-exporter-otlp
|
| 9 |
+
openinference-instrumentation-smolagents
|