LlamaIndex
Connect custom data sources to LLMs with data frameworks
Pythonmedium
LlamaIndex enables building RAG (Retrieval-Augmented Generation) applications. Decyra captures all LLM queries, providing visibility into your RAG pipeline's model interactions.
Prerequisites
- Decyra account with API key
- Python 3.8+ installed
- LlamaIndex package installed
Installation
pip install llama-index llama-index-llms-openai decyra-sdk
Integration
Configure OpenAI LLM with Decyra's proxy:
from llama_index.llms.openai import OpenAI
import os
llm = OpenAI(
model="gpt-4",
api_base="https://proxy.decyra.com/v1",
api_key=os.getenv("DECYRA_API_KEY"),
default_headers={
"X-Decyra-API-Key": os.getenv("DECYRA_API_KEY")
}
)
Create and use a query engine:
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader
documents = SimpleDirectoryReader("data").load_data()
index = VectorStoreIndex.from_documents(documents)
query_engine = index.as_query_engine(llm=llm)
response = query_engine.query("What is the main topic?")
print(response)
What Gets Captured
| Field | Description |
|---|---|
| Model | The AI model identifier |
| Temperature | Temperature setting |
| Query | The user's query text |
| Context Length | Length of retrieved context |
| Prompt Hash | Hash of query + context |
| Response Time | Time for query processing |
| Token Usage | Tokens used in query/response |
| Cost | Estimated API cost |
Verify
Open your Decyra dashboard and check the traces page. Each query will appear with the model call details and retrieved context information.