Using Opik with LlamaIndex
This notebook showcases how to use Opik with LlamaIndex. LlamaIndex is a flexible data framework for building LLM applications:
LlamaIndex is a “data framework” to help you build LLM apps. It provides the following tools:
- Offers data connectors to ingest your existing data sources and data formats (APIs, PDFs, docs, SQL, etc.).
- Provides ways to structure your data (indices, graphs) so that this data can be easily used with LLMs.
- Provides an advanced retrieval/query interface over your data: Feed in any LLM input prompt, get back retrieved context and knowledge-augmented output.
- Allows easy integrations with your outer application framework (e.g. with LangChain, Flask, Docker, ChatGPT, anything else).
For this guide we will be downloading the essays from Paul Graham and use them as our data source. We will then start querying these essays with LlamaIndex.
Creating an account on Comet.com
Comet provides a hosted version of the Opik platform, simply create an account and grab you API Key.
You can also run the Opik platform locally, see the installation guide for more information.
Preparing our environment
First, we will download the Chinook database and set up our different API keys.
And configure the required environment variables:
In addition, we will download the Paul Graham essays:
Using LlamaIndex
Configuring the Opik integration
You can use the Opik callback directly by calling:
Now that the callback handler is configured, all traces will automatically be logged to Opik.
Using LLamaIndex
The first step is to load the data into LlamaIndex. We will use the SimpleDirectoryReader
to load the data from the data/paul_graham
directory. We will also create the vector store to index all the loaded documents.
We can now query the index using the query_engine
object:
You can now go to the Opik app to see the trace: