HoneyHive X LanceDB
RAG with HoneyHive Tracing
HoneyHive is an AI monitoring and evaluation platform that helps developers and businesses build, track, and improve reliable AI applications. It offers tools for performance monitoring, dataset management, debugging, and collaboration, ensuring AI systems run smoothly and scale effectively in production.
Step 1: Initialize Clients and Setup
First, set up the necessary clients and configuration for HoneyHive, OpenAI, and LanceDB:
Step 2: Define Document Class
Create a simple document class to hold text chunks:
Step 3: Load and Process Documents with Tracing
Create functions to load and chunk documents with HoneyHive tracing:
Step 4: Create LanceDB Table with Tracing
Set up a LanceDB table with embeddings:
This function creates a LanceDB table and adds document chunks with embeddings. The @trace decorator logs information about the embedding model used and table creation process.
Step 5: Retrieve Documents with Tracing
Create a function to retrieve relevant documents from LanceDB:
The @trace decorator logs information about the retrieval process, including the query and number of results.
Step 6: Generate Response with Tracing
Create a function to generate a response using OpenAI with tracing:
Step 7: Complete RAG Pipeline with Tracing
Create a function that combines all the previous steps into a complete RAG pipeline:
The @trace decorator logs the entire RAG pipeline process, creating a parent span that contains all the child spans from the individual functions.
Step 8: Run the Example
Finally, create a main function to run the example:
Sample dataset has been taken from Llamaindex dataset based off an essay by Paul Graham
100% 1/1 [00:00<00:00, 2.33it/s] Successfully downloaded PaulGrahamEssayDataset to ./data