ryanrwatkins commited on
Commit
8f9f33b
·
verified ·
1 Parent(s): 60cba82

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -17
app.py CHANGED
@@ -77,24 +77,18 @@ from langchain.memory import ConversationSummaryBufferMemory,ConversationBufferM
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
 
@@ -620,7 +614,7 @@ chain = ConversationalRetrievalChain.from_llm(
620
 
621
 
622
  # This below is for the interface
623
-
624
  def submit_message(prompt, prompt_template, temperature, max_tokens, context_length, state):
625
 
626
 
 
77
  from langchain.schema import Document
78
 
79
 
80
+ from langfuse import Langfuse
 
 
 
 
 
 
 
81
 
82
+ langfuse = Langfuse(
83
+ secret_key=os.environ.get("LANGFUSE_SECRET_KEY"),
84
+ public_key=os.environ.get("LANGFUSE_PUBLIC_KEY"),
85
+ host="https://us.cloud.langfuse.com"
86
+ )
87
+ from langfuse.decorators import observe
88
 
89
+ LANGFUSE_SECRET_KEY=os.environ.get("LANGFUSE_SECRET_KEY")
90
+ LANGFUSE_PUBLIC_KEY=os.environ.get("LANGFUSE_PUBLIC_KEY")
91
+ LANGFUSE_HOST="https://us.cloud.langfuse.com"
 
 
 
 
 
92
 
93
 
94
 
 
614
 
615
 
616
  # This below is for the interface
617
+ @observe()
618
  def submit_message(prompt, prompt_template, temperature, max_tokens, context_length, state):
619
 
620