llama-index packs arize_phoenix_query_engine integration
Project description
Arize-Phoenix LlamaPack
This LlamaPack instruments your LlamaIndex app for LLM tracing with Phoenix, an open-source LLM observability library from Arize AI.
CLI Usage
You can download llamapacks directly using llamaindex-cli
, which comes installed with the llama-index
python package:
llamaindex-cli download-llamapack ArizePhoenixQueryEnginePack --download-dir ./arize_pack
You can then inspect the files at ./arize_pack
and use them as a template for your own project!
Code Usage
You can download the pack to a the ./arize_pack
directory:
from llama_index.core.llama_pack import download_llama_pack
# download and install dependencies
ArizePhoenixQueryEnginePack = download_llama_pack(
"ArizePhoenixQueryEnginePack", "./arize_pack"
)
You can then inspect the files at ./arize_pack
or continue on to use the module.
import os
from llama_index.core.node_parser import SentenceSplitter
from llama_index.readers.web import SimpleWebPageReader
from tqdm.auto import tqdm
Configure your OpenAI API key.
os.environ["OPENAI_API_KEY"] = "copy-your-openai-api-key-here"
Parse your documents into a list of nodes and pass to your LlamaPack. In this example, use nodes from a Paul Graham essay as input.
documents = SimpleWebPageReader().load_data(
[
"https://raw.githubusercontent.com/jerryjliu/llama_index/adb054429f642cc7bbfcb66d4c232e072325eeab/examples/paul_graham_essay/data/paul_graham_essay.txt"
]
)
parser = SentenceSplitter()
nodes = parser.get_nodes_from_documents(documents)
phoenix_pack = ArizePhoenixQueryEnginePack(nodes=nodes)
Run a set of queries via the pack's run
method, which delegates to the underlying query engine.
queries = [
"What did Paul Graham do growing up?",
"When and how did Paul Graham's mother die?",
"What, in Paul Graham's opinion, is the most distinctive thing about YC?",
"When and how did Paul Graham meet Jessica Livingston?",
"What is Bel, and when and where was it written?",
]
for query in tqdm(queries):
print("Query")
print("=====")
print(query)
print()
response = phoenix_pack.run(query)
print("Response")
print("========")
print(response)
print()
View your trace data in the Phoenix UI.
phoenix_session_url = phoenix_pack.get_modules()["session_url"]
print(f"Open the Phoenix UI to view your trace data: {phoenix_session_url}")
You can access the internals of the LlamaPack, including your Phoenix session and your query engine, via the get_modules
method.
phoenix_pack.get_modules()
Check out the Phoenix documentation for more information!
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file llama_index_packs_arize_phoenix_query_engine-0.3.0.tar.gz
.
File metadata
- Download URL: llama_index_packs_arize_phoenix_query_engine-0.3.0.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.10 Darwin/22.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd0ad4048f2084e6508e9bd6243fe117de2bab39e91d019921f8f8bdcc94a78f |
|
MD5 | c9b2c41a97a01a6c129db6596317da4e |
|
BLAKE2b-256 | df7229e77cc759b632e7863e4ff4cc7cb662865491a33ee89177a2cb1290aa55 |
File details
Details for the file llama_index_packs_arize_phoenix_query_engine-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: llama_index_packs_arize_phoenix_query_engine-0.3.0-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.10 Darwin/22.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b06a278526d5be09cb4c2f4fd2bb3a3460aa82fea4ee141ed1d20f539836052 |
|
MD5 | 8070571c48c21d82abe3e66766af2b91 |
|
BLAKE2b-256 | 134b5b9264f2fbd7e4deee6531a73a167d1878b5b0305e13a2433e3c3f8e8e1a |