Use this file to discover all available pages before exploring further.
Phoenix provides first-class support for LlamaIndex, a powerful data framework for building RAG (retrieval-augmented generation) applications. LlamaIndex makes it easy to connect your LLM to your own data sources.
from llama_index.core import VectorStoreIndex, SimpleDirectoryReaderimport os# Set your OpenAI API keyos.environ["OPENAI_API_KEY"] = "your-api-key"# Load documents and create indexdocuments = SimpleDirectoryReader("data").load_data()index = VectorStoreIndex.from_documents(documents)# Query the index - automatically traced!query_engine = index.as_query_engine()response = query_engine.query("What are the key insights from the documents?")print(response)
from llama_index.core import VectorStoreIndex, SimpleDirectoryReaderdocuments = SimpleDirectoryReader("data").load_data()index = VectorStoreIndex.from_documents(documents)query_engine = index.as_query_engine(streaming=True)# Stream the responseresponse = query_engine.query("Summarize the key points")for text in response.response_gen: print(text, end="", flush=True)# Phoenix captures the full streamed response
from llama_index.core import VectorStoreIndex, SimpleDirectoryReaderfrom llama_index.core.memory import ChatMemoryBufferdocuments = SimpleDirectoryReader("data").load_data()index = VectorStoreIndex.from_documents(documents)# Create chat engine with memorymemory = ChatMemoryBuffer.from_defaults(token_limit=3000)chat_engine = index.as_chat_engine( chat_mode="condense_plus_context", memory=memory, verbose=True)# Phoenix traces the conversation contextresponse = chat_engine.chat("What is this document about?")print(response)response = chat_engine.chat("Tell me more about that topic")print(response)