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.