Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -10,26 +10,18 @@ from Gradio_UI import GradioUI
|
|
10 |
import urllib, urllib.request
|
11 |
|
12 |
|
13 |
-
from openinference.instrumentation.smolagents import SmolagentsInstrumentor
|
14 |
-
# Instrument smolagents
|
15 |
-
SmolagentsInstrumentor().instrument()
|
16 |
-
|
17 |
import os
|
18 |
import base64
|
19 |
LANGFUSE_PUBLIC_KEY= os.environ.get("LANGFUSE_PUBLIC_KEY")
|
20 |
LANGFUSE_SECRET_KEY= os.environ.get("LANGFUSE_SECRET_KEY")
|
21 |
|
22 |
|
23 |
-
|
24 |
-
print(f"LANGFUSE_SECRET_KEY is set: {bool(LANGFUSE_SECRET_KEY)}")
|
25 |
LANGFUSE_AUTH=base64.b64encode(f"{LANGFUSE_PUBLIC_KEY}:{LANGFUSE_SECRET_KEY}".encode()).decode()
|
26 |
os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = "https://cloud.langfuse.com/api/public/otel" # EU data region
|
27 |
-
|
28 |
# os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = "https://us.cloud.langfuse.com/api/public/otel" # US data region
|
|
|
29 |
|
30 |
-
os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = f"authorization=Basic {LANGFUSE_AUTH}"
|
31 |
-
# your Hugging Face token
|
32 |
-
# os.environ["HF_TOKEN"] = ""
|
33 |
|
34 |
headers = {
|
35 |
"Authorization": f"Basic {LANGFUSE_AUTH}",
|
@@ -60,22 +52,6 @@ trace_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter()))
|
|
60 |
SmolagentsInstrumentor().instrument(tracer_provider=trace_provider)
|
61 |
|
62 |
|
63 |
-
import importlib
|
64 |
-
|
65 |
-
packages = [
|
66 |
-
"smolagents",
|
67 |
-
"opentelemetry.sdk.trace",
|
68 |
-
"opentelemetry.exporter.otlp.proto.http.trace_exporter",
|
69 |
-
"openinference.instrumentation.smolagents"
|
70 |
-
]
|
71 |
-
|
72 |
-
for pkg in packages:
|
73 |
-
try:
|
74 |
-
importlib.import_module(pkg)
|
75 |
-
print(f"{pkg} is installed.")
|
76 |
-
except ImportError:
|
77 |
-
print(f"{pkg} is NOT installed.")
|
78 |
-
|
79 |
from opentelemetry import trace
|
80 |
|
81 |
# Get a tracer
|
@@ -86,6 +62,9 @@ with tracer.start_as_current_span("test-span"):
|
|
86 |
print("Test span created")
|
87 |
|
88 |
|
|
|
|
|
|
|
89 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
90 |
@tool
|
91 |
def search_arxiv(search_term:str)-> str: #it's import to specify the return type
|
|
|
10 |
import urllib, urllib.request
|
11 |
|
12 |
|
|
|
|
|
|
|
|
|
13 |
import os
|
14 |
import base64
|
15 |
LANGFUSE_PUBLIC_KEY= os.environ.get("LANGFUSE_PUBLIC_KEY")
|
16 |
LANGFUSE_SECRET_KEY= os.environ.get("LANGFUSE_SECRET_KEY")
|
17 |
|
18 |
|
19 |
+
|
|
|
20 |
LANGFUSE_AUTH=base64.b64encode(f"{LANGFUSE_PUBLIC_KEY}:{LANGFUSE_SECRET_KEY}".encode()).decode()
|
21 |
os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = "https://cloud.langfuse.com/api/public/otel" # EU data region
|
|
|
22 |
# os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = "https://us.cloud.langfuse.com/api/public/otel" # US data region
|
23 |
+
os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = f"Authorization=Basic {LANGFUSE_AUTH}"
|
24 |
|
|
|
|
|
|
|
25 |
|
26 |
headers = {
|
27 |
"Authorization": f"Basic {LANGFUSE_AUTH}",
|
|
|
52 |
SmolagentsInstrumentor().instrument(tracer_provider=trace_provider)
|
53 |
|
54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
from opentelemetry import trace
|
56 |
|
57 |
# Get a tracer
|
|
|
62 |
print("Test span created")
|
63 |
|
64 |
|
65 |
+
|
66 |
+
|
67 |
+
|
68 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
69 |
@tool
|
70 |
def search_arxiv(search_term:str)-> str: #it's import to specify the return type
|