blazingbunny commited on
Commit
1512af4
·
verified ·
1 Parent(s): 22f855f

Upload 3 files

Browse files
Files changed (2) hide show
  1. agent.py +22 -0
  2. requirements.txt +4 -1
agent.py CHANGED
@@ -14,6 +14,28 @@ from dotenv import load_dotenv
14
 
15
  load_dotenv()
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  # 1. Define the state
18
  class AgentState(TypedDict):
19
  messages: Annotated[List[BaseMessage], operator.add]
 
14
 
15
  load_dotenv()
16
 
17
+ # Configure tracing
18
+ try:
19
+ if os.getenv("ARIZE_SPACE_ID") and os.getenv("ARIZE_API_KEY"):
20
+ from arize.otel import register
21
+ from openinference.instrumentation.google_genai import GoogleGenAIInstrumentor
22
+ from openinference.instrumentation.langchain import LangChainInstrumentor
23
+
24
+ tracer_provider = register(
25
+ space_id=os.getenv("ARIZE_SPACE_ID"),
26
+ api_key=os.getenv("ARIZE_API_KEY"),
27
+ project_name=os.getenv("ARIZE_PROJECT_NAME", "langgraph-agent-test")
28
+ )
29
+ GoogleGenAIInstrumentor().instrument(tracer_provider=tracer_provider)
30
+ LangChainInstrumentor().instrument(tracer_provider=tracer_provider)
31
+ print("Tracing configured with Arize.")
32
+ else:
33
+ print("Arize tracing skipped: ARIZE_SPACE_ID or ARIZE_API_KEY not set.")
34
+ except ImportError:
35
+ print("Tracing libraries not installed. Skipping tracing.")
36
+ except Exception as e:
37
+ print(f"Error configuring tracing: {e}")
38
+
39
  # 1. Define the state
40
  class AgentState(TypedDict):
41
  messages: Annotated[List[BaseMessage], operator.add]
requirements.txt CHANGED
@@ -9,4 +9,7 @@ langchain-google-genai
9
  google-auth
10
  langchain-tavily
11
  google-cloud-aiplatform
12
- youtube-transcript-api
 
 
 
 
9
  google-auth
10
  langchain-tavily
11
  google-cloud-aiplatform
12
+ youtube-transcript-api
13
+ arize-otel
14
+ openinference-instrumentation-google-genai
15
+ openinference-instrumentation-langchain