lwant commited on
Commit
9e8e553
Β·
1 Parent(s): cb13db3

Add telemetry support using Phoenix for LlamaIndex observability

Browse files
Files changed (1) hide show
  1. src/gaia_solving_agent/telemetry.py +22 -0
src/gaia_solving_agent/telemetry.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from getpass import getpass
2
+
3
+ import llama_index.core
4
+ import os
5
+
6
+ from gaia_solving_agent import PHOENIX_API_KEY
7
+
8
+ # Phoenix can display in real time the traces automatically
9
+ # collected from your LlamaIndex application.
10
+ # Run all of your LlamaIndex applications as usual and traces
11
+ # will be collected and displayed in Phoenix.
12
+
13
+ # setup Arize Phoenix for logging/observability
14
+ def set_telemetry(api_key=PHOENIX_API_KEY) -> None:
15
+ if api_key is None or "x" in api_key:
16
+ api_key = getpass("πŸ”‘ Enter your Phoenix API key: ")
17
+ os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = f"api_key={api_key}"
18
+ llama_index.core.set_global_handler(
19
+ "arize_phoenix",
20
+ endpoint="https://llamatrace.com/v1/traces",
21
+ project="default"
22
+ )