ToolFS RAG
Semantic search over vector databases for document retrieval. RAG (Retrieval-Augmented Generation) enables finding relevant documents and content based on semantic similarity rather than exact keyword matches.
How It Works
- Vector Search: Queries are converted to embeddings and compared against document vectors
- Similarity Scoring: Results are ranked by semantic similarity scores
- Top-K Results: Returns the most relevant documents up to the specified limit
- Metadata Filtering: Results include metadata for context and filtering
Usage
Semantic Search
ToolFS Path:
/toolfs/rag/query?text=<query_text>&top_k=<number>
Parameters:
textorq: The search query (URL-encoded)top_k: Number of results to return (default: 5)
Example:
GET /toolfs/rag/query?text=ToolFS%20skill%20architecture&top_k=3
// Response
{
"query": "ToolFS skill architecture",
"top_k": 3,
"results": [
{
"id": "doc-001",
"content": "ToolFS provides a skill system that supports WASM modules for sandboxed execution. Skills can be mounted to virtual paths and executed through the Skill API.",
"score": 0.95,
"metadata": {
"source": "documentation",
"section": "skills",
"title": "Skill System Overview"
}
},
{
"id": "doc-002",
"content": "The skill architecture allows mounting custom handlers to virtual paths, enabling extensible functionality within the ToolFS framework.",
"score": 0.87,
"metadata": {
"source": "documentation",
"section": "architecture",
"title": "Architecture Design"
}
},
{
"id": "doc-003",
"content": "WASM skills are executed in a sandboxed environment with resource limits and security constraints to ensure safe operation.",
"score": 0.82,
"metadata": {
"source": "documentation",
"section": "sandboxing",
"title": "Security Model"
}
}
]
}
When to Use This Skill
Use RAG skill when you need to:
- Semantic Search: Find documents based on meaning, not just keywords
- Knowledge Retrieval: Query a knowledge base or document collection
- Context Gathering: Gather relevant context for generating responses
- Document Discovery: Discover related content across a corpus
Common use cases:
- "Search for information about ToolFS skills"
- "Find documents related to vector databases"
- "Query the knowledge base for best practices"
- "Find relevant documentation about RAG systems"
Query Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
text or q |
string | Yes | - | Search query text (URL-encoded) |
top_k |
integer | No | 5 | Number of results to return |
Result Structure
Each result includes:
- id: Document identifier
- content: Document content snippet
- score: Similarity score (0.0 to 1.0, higher is better)
- metadata: Optional metadata (source, title, section, etc.)
Output Format
RAG operations return standardized result structures:
{
"type": "rag",
"source": "/toolfs/rag/query",
"content": {
"query": "...",
"top_k": 3,
"results": [...]
},
"success": true,
"error": "error message if failed"
}
Present Results to User
When presenting RAG search results:
✓ RAG search completed
Query: ToolFS skill architecture
Results: 3 matches found
1. doc-001 (score: 0.95)
Source: documentation > skills
Title: Skill System Overview
Content: ToolFS provides a skill system that supports WASM modules...
2. doc-002 (score: 0.87)
Source: documentation > architecture
Title: Architecture Design
Content: The skill architecture allows mounting custom handlers...
3. doc-003 (score: 0.82)
Source: documentation > sandboxing
Title: Security Model
Content: WASM skills are executed in a sandboxed environment...
Troubleshooting
No Results Found
If search returns no results:
- Try a different query or rephrase the search
- Reduce specificity to broaden results
- Verify the RAG store is populated with documents
- Check if the query is properly URL-encoded
Low Quality Results
If results are not relevant:
- Increase
top_kto see more options - Refine the query with more specific terms
- Check if document embeddings are up to date
- Verify the RAG store contains relevant documents
Best Practices
- Use Semantic Queries: RAG works best with natural language queries, not just keywords
- Adjust top_k: Start with 5-10 results, adjust based on use case
- Review Scores: Higher scores (>0.8) indicate strong relevance
- Check Metadata: Use metadata to filter or categorize results
- Combine Results: Combine multiple search queries for comprehensive coverage
This skill is part of ToolFS. See main SKILL.md for overview.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.