File size: 768 Bytes
c2fbc47
9e8e553
 
 
 
 
 
 
 
 
 
 
 
 
c2fbc47
9e8e553
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from functools import lru_cache
from getpass import getpass

import llama_index.core
import os

from gaia_solving_agent import PHOENIX_API_KEY

# Phoenix can display in real time the traces automatically
# collected from your LlamaIndex application.
# Run all of your LlamaIndex applications as usual and traces
# will be collected and displayed in Phoenix.

# setup Arize Phoenix for logging/observability
@lru_cache
def set_telemetry(api_key=PHOENIX_API_KEY) -> None:
    if api_key is None or "x" in api_key:
        api_key = getpass("πŸ”‘ Enter your Phoenix API key: ")
    os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = f"api_key={api_key}"
    llama_index.core.set_global_handler(
        "arize_phoenix",
        endpoint="https://llamatrace.com/v1/traces",
    )