rag
rag
Purpose
This skill implements Retrieval-Augmented Generation (RAG) for OpenClaw, enabling AI models to query external knowledge bases and integrate results into responses, enhancing accuracy for tasks like question-answering.
When to Use
Use this skill when your AI needs dynamic access to external data, such as querying a vector database for real-time information in NLP tasks, handling knowledge gaps in models, or augmenting responses in chatbots. Avoid it for purely generative tasks without external dependencies.
Key Capabilities
- Fetches documents from vector databases (e.g., Pinecone, FAISS) using similarity search.
- Integrates retrieved content into AI prompts for generation.
- Supports embedding models for query vectorization (e.g., via Hugging Face transformers).
- Handles chunking of large documents and relevance scoring.
- Configurable via JSON files for custom sources and thresholds.
Usage Patterns
Always set the API key via environment variable: export OPENCLAW_API_KEY=$SERVICE_API_KEY. For CLI, use openclaw rag with required flags. In code, import the skill and call methods like rag.retrieve(). Pattern: Query -> Retrieve -> Augment -> Generate. Ensure queries are under 512 tokens to avoid truncation.