Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -77,6 +77,32 @@ from langchain.memory import ConversationSummaryBufferMemory,ConversationBufferM
|
|
77 |
from langchain.schema import Document
|
78 |
|
79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
# Cohere (not currently in use)
|
81 |
from langchain.retrievers.document_compressors import CohereRerank
|
82 |
from langchain_community.llms import Cohere
|
|
|
77 |
from langchain.schema import Document
|
78 |
|
79 |
|
80 |
+
import os
|
81 |
+
import base64
|
82 |
+
LANGFUSE_PUBLIC_KEY= os.environ.get("LANGFUSE_PUBLIC_KEY")
|
83 |
+
LANGFUSE_SECRET_KEY= os.environ.get("LANGFUSE_SECRET_KEY")
|
84 |
+
LANGFUSE_AUTH=base64.b64encode(f"{LANGFUSE_PUBLIC_KEY}:{LANGFUSE_SECRET_KEY}".encode()).decode()
|
85 |
+
#os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = "https://cloud.langfuse.com/api/public/otel" # EU data region
|
86 |
+
os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = "https://us.cloud.langfuse.com/api/public/otel" # US data region
|
87 |
+
os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = f"Authorization=Basic {LANGFUSE_AUTH}"
|
88 |
+
|
89 |
+
|
90 |
+
from opentelemetry.sdk.trace import TracerProvider
|
91 |
+
from openinference.instrumentation.smolagents import SmolagentsInstrumentor
|
92 |
+
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
|
93 |
+
from opentelemetry.sdk.trace.export import SimpleSpanProcessor
|
94 |
+
trace_provider = TracerProvider()
|
95 |
+
trace_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter()))
|
96 |
+
SmolagentsInstrumentor().instrument(tracer_provider=trace_provider)
|
97 |
+
|
98 |
+
|
99 |
+
|
100 |
+
|
101 |
+
|
102 |
+
|
103 |
+
|
104 |
+
|
105 |
+
|
106 |
# Cohere (not currently in use)
|
107 |
from langchain.retrievers.document_compressors import CohereRerank
|
108 |
from langchain_community.llms import Cohere
|