openinference-instrumentation-llama-index

OpenInference LlamaIndex Instrumentation

56 个版本 Python <3.15,>=3.10
安装
pip install openinference-instrumentation-llama-index
poetry add openinference-instrumentation-llama-index
pipenv install openinference-instrumentation-llama-index
conda install openinference-instrumentation-llama-index
描述

OpenInference LlamaIndex Instrumentation

Python auto-instrumentation library for LlamaIndex.

These traces are fully OpenTelemetry compatible and can be sent to an OpenTelemetry collector for viewing, such as arize-phoenix.

pypi

Installation

pip install openinference-instrumentation-llama-index

Compatibility

llama-index version openinference-instrumentation-llama-index version
>=0.12.3 >=4.0
>=0.11.0 >=3.0
>=0.10.43 >=2.0, <3.0
>=0.10.0, <0.10.43 >=1.0, <0.2
>=0.9.14, <0.10.0 0.1.3

Quickstart

Install packages needed for this demonstration.

python -m pip install --upgrade \
    openinference-instrumentation-llama-index \
    opentelemetry-sdk \
    opentelemetry-exporter-otlp \
    "opentelemetry-proto>=1.12.0" \
    arize-phoenix

Start the Phoenix app in the background as a collector. By default, it listens on http://localhost:6006. You can visit the app via a browser at the same address.

The Phoenix app does not send data over the internet. It only operates locally on your machine.

python -m phoenix.server.main serve

The following Python code sets up the LlamaIndexInstrumentor to trace llama-index and send the traces to Phoenix at the endpoint shown below.

from openinference.instrumentation.llama_index import LlamaIndexInstrumentor
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk import trace as trace_sdk
from opentelemetry.sdk.trace.export import SimpleSpanProcessor

endpoint = "http://127.0.0.1:6006/v1/traces"
tracer_provider = trace_sdk.TracerProvider()
tracer_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter(endpoint)))

LlamaIndexInstrumentor().instrument(tracer_provider=tracer_provider)

To demonstrate tracing, we'll use LlamaIndex below to query a document.

First, download a text file.

import tempfile
from urllib.request import urlretrieve
from llama_index.core import SimpleDirectoryReader

url = "https://raw.githubusercontent.com/Arize-ai/phoenix-assets/main/data/paul_graham/paul_graham_essay.txt"
with tempfile.NamedTemporaryFile() as tf:
    urlretrieve(url, tf.name)
    documents = SimpleDirectoryReader(input_files=[tf.name]).load_data()

Next, we'll query using OpenAI. To do that you need to set up your OpenAI API key in an environment variable.

import os

os.environ["OPENAI_API_KEY"] = "<your openai key>"

Now we can query the indexed documents.

from llama_index.core import VectorStoreIndex

query_engine = VectorStoreIndex.from_documents(documents).as_query_engine()
print(query_engine.query("What did the author do growing up?"))

Visit the Phoenix app at http://localhost:6006 to see the traces.

More Info

版本列表
4.4.2 2026-05-18
4.4.1 2026-05-14
4.4.0 2026-05-13
4.3.10 2026-05-10
4.3.9 2025-11-18
4.3.8 2025-10-23
4.3.7 2025-10-15
4.3.6 2025-10-10
4.3.5 2025-09-12
4.3.4 2025-08-01
4.3.3 2025-07-29
4.3.2 2025-07-23
4.3.1 2025-06-27
4.3.0 2025-05-29
4.2.1 2025-04-11
4.2.0 2025-04-10
4.1.0 2025-04-03
4.0.0 2025-03-28
3.3.3 2025-03-18
3.3.2 2025-03-14
3.3.1 2025-02-19
3.3.0 2025-02-18
3.2.0 2025-02-13
3.1.4 2025-02-04
3.1.3 2025-01-09
3.1.2 2024-12-20
3.1.1 2024-12-17
3.1.0 2024-12-12
3.0.4 2024-11-12
3.0.3 2024-10-31
3.0.2 2024-09-06
3.0.1 2024-09-05
3.0.0 2024-08-27
2.2.4 2024-08-10
2.2.3 2024-08-06
2.2.2 2024-08-06
2.2.1 2024-08-01
2.2.0 2024-07-31
2.1.1 2024-07-25
2.1.0 2024-07-15
2.0.0 2024-06-10
1.4.2 2024-06-03
1.4.1 2024-05-21
1.4.0 2024-05-17
1.3.0 2024-05-06
1.2.2 2024-04-23
1.2.1 2024-03-18
1.2.0 2024-03-13
1.1.1 2024-03-04
1.1.0 2024-02-24
1.0.1 2024-02-15
1.0.0 2024-02-13
0.1.3 2024-02-12
0.1.2 2024-02-09
0.1.1 2024-01-27
0.1.0 2024-01-22