Embedded RAG Knowledge Base
Reasoning now includes a built-in RAG (Retrieval-Augmented Generation) server that allows you to create and manage a custom knowledge base directly within the plugin, with no external installation required.
This significantly improves the quality and speed of code generation by providing project-specific context to the AI model.
Overview
The RAG server is automatically initialized when Reasoning is activated and offers:
- Local Storage: The knowledge base is saved in the plugin's data directory.
- Semantic Search: Uses vector embeddings to find relevant knowledge.
- Multiple Embedding Providers: OpenAI, Ollama, or local.
- Automatic Persistence: Data is automatically saved in JSON format.
Why Use RAG?
Traditional code generation often lacks project-specific context, resulting in generic and inconsistent code. RAG solves this by retrieving relevant information from your project and injecting it into the prompt, which leads to:
- 🎯 Precision: Code that aligns with your project's standards.
- ⚡ Speed: A 30-50% reduction in development time.
- 🔄 Consistency: Code generation that follows established conventions.
- 📚 Quality: A 40-60% improvement in the quality of the generated code.
Available Tools
You can interact with the knowledge base using the following tools through the chat:
1. Add Knowledge
{
"tool": "add_rag_knowledge",
"arguments": {
"content": "React is a JavaScript library for building user interfaces",
"title": "React - Introduction",
"source": "react-documentation",
"tags": ["react", "javascript", "frontend"]
}
}
2. Search Knowledge
{
"tool": "search_rag_knowledge",
"arguments": {
"query": "React hooks useState",
"maxResults": 5,
"minScore": 0.8,
"tags": ["react"]
}
}
3. List Knowledge
{
"tool": "list_rag_knowledge",
"arguments": {
"limit": 20,
"tags": ["javascript"]
}
}
4. Update Knowledge
{
"tool": "update_rag_knowledge",
"arguments": {
"id": "abc123def456",
"content": "Updated content",
"title": "Updated Title",
"tags": ["updated", "react"]
}
}
5. Delete Knowledge
{
"tool": "delete_rag_knowledge",
"arguments": {
"id": "abc123def456"
}
}
6. Get Stats
{
"tool": "get_rag_stats",
"arguments": {}
}
Chat Usage Examples
Add Documentation
Add to the knowledge base: "TypeScript is a superset of JavaScript that adds static typing."
Search for Information
Search the knowledge base for information about TypeScript
Configuration
- Open VS Code settings.
- Search for "Reasoning RAG".
- Configure embedding providers and other options.
{
"reasoning.rag.embeddingProvider": "local",
"reasoning.rag.embeddingModel": "text-embedding-3-small",
"reasoning.rag.maxResults": 10,
"reasoning.rag.minScore": 0.7,
"reasoning.rag.openaiApiKey": "your-openai-key",
"reasoning.rag.ollamaUrl": "http://localhost:11434"
}
Use Cases
- Project Documentation: Store architectural decisions, code patterns, and specific documentation.
- Code Snippets: Save code examples, solutions to common problems, and templates.
- Domain Knowledge: Document business rules and information about APIs.
- Troubleshooting: Keep a history of bugs, solutions, and workarounds.
For a detailed testing guide, refer to the RAG Knowledge Base Testing Guide.