needle
Needle Retriever
Needle makes it easy to create your RAG pipelines with minimal effort.
For more details, refer to our API documentation
Overview
The Needle Document Loader is a utility for integrating Needle collections with LangChain. It enables seamless storage, retrieval, and utilization of documents for Retrieval-Augmented Generation (RAG) workflows.
This example demonstrates:
- Storing documents into a Needle collection.
- Setting up a retriever to fetch documents.
- Building a Retrieval-Augmented Generation (RAG) pipeline.
Setup
Before starting, ensure you have the following environment variables set:
- NEEDLE_API_KEY: Your API key for authenticating with Needle.
- OPENAI_API_KEY: Your OpenAI API key for language model operations.
Initialization
To initialize the NeedleLoader, you need the following parameters:
- needle_api_key: Your Needle API key (or set it as an environment variable).
- collection_id: The ID of the Needle collection to work with.
import os
os.environ["NEEDLE_API_KEY"] = ""
os.environ["OPENAI_API_KEY"] = ""
Instantiation
from langchain_community.document_loaders.needle import NeedleLoader
collection_id = "clt_01J87M9T6B71DHZTHNXYZQRG5H"
# Initialize NeedleLoader to store documents to the collection
document_loader = NeedleLoader(
needle_api_key=os.getenv("NEEDLE_API_KEY"),
collection_id=collection_id,
)
API Reference:NeedleLoader