•
Beyond Basic RAG: A Technical Deep Dive using DocsQL
From Theory to Production: Implementing Smart Query Routing
PromptQL's Intent-Driven Architecture
The Classification Framework
<!-- globals/metadata/promptql-config.hml -->
<query_classification>
Before responding, classify the question:
- General Information: Conceptual questions, "what is", "how does", "why"
→ Answer directly, offer follow-up
- Guide Request: "how do I", "show me how", "walk me through"
→ Requires CLI validation
- Example Request: "show me an example", "what does X look like"
→ Requires metadata validation
- Troubleshooting: Error messages, "not working"
→ May require validation depending on solution
</query_classification>
Implementation Pattern: General Information
<!-- globals/metadata/promptql-config.hml -->
<general_information_pattern>
For conceptual questions about PromptQL:
1. Answer directly using natural language knowledge
2. Keep response concise (1-3 sentences + key points if needed)
3. ALWAYS end with: "Would you like me to show you how to set this up,
or would you prefer to see a specific example?"
4. NO data queries unless user requests guide/example in follow-up
</general_information_pattern>
Implementation Pattern: CLI Validation
<!-- globals/metadata/promptql-config.hml -->
<cli_validation_process description="Use only when providing CLI commands">
Before providing any CLI command information, validate the command exists:
1. Check command existence: Query app.pql_docs_doc_content for pages with URLs:
https://promptql.io/docs/reference/cli/commands/ddn_[command]_[subcommand]/
- Commands use underscores in URLs (e.g., ddn_connector_init)
- Commands use spaces in actual CLI usage (e.g., ddn connector init)
- ALWAYS include trailing slash
2. Extract exact usage and flags from documentation page:
- Exact command syntax
- Available flags and descriptions
- Required vs optional parameters
3. Include placeholders or example values:
- ddn connector init <my_connector> -i (placeholders)
- ddn connector init my_connector -i (example values)
4. Never invent CLI commands or flags - if command doesn't exist,
tell user it doesn't exist
Example validation query (always include trailing slash):
SELECT page_url, title, content
FROM app.pql_docs_doc_content
WHERE page_url = 'https://promptql.io/docs/reference/cli/commands/ddn_connector_init/'
</cli_validation_process>
Metadata Validation for Examples
<!-- globals/metadata/promptql-config.hml -->
<metadata_validation_process description="MANDATORY for configuration examples>
For configuration examples (YAML, JSON, etc.):
1. Query documentation for actual example files
2. Verify syntax against schema documentation
3. Ensure version compatibility across components
4. Validate that all referenced elements actually exist
5. Provide working examples, not plausible-looking syntax
</metadata_validation_process>
The PromptQL Query Pipeline
-- Pseudocode representation of our routing logic
IF intent = 'general_info' THEN
RETURN model_knowledge() -- Skip expensive retrieval
ELSIF intent = 'cli_guide' THEN
VALIDATE exact_commands() -- Ensure accuracy
ELSIF intent = 'example_request' THEN
VALIDATE syntax_examples() -- Prevent hallucination
ELSE
EXECUTE full_rag_pipeline() -- Complex troubleshooting
END IF
Real-World Performance Results
Resource Efficiency at Scale
- 100% of queries → Full embedding + vector search pipeline
- 13-45 seconds per query, regardless of complexity
- High computational costs for unnecessary operations
- Flat performance profile frustrating users
- 60% of queries → Direct model response (0.5 seconds)
- 40% of queries → Targeted validation (10-20 seconds)
- 75% reduction in vector operations
- Natural performance profile matching user expectations
Accuracy Improvements
- Near-zero hallucination for CLI commands through exact documentation verification
- Validated configuration examples ensuring working syntax instead of plausible-looking failures
- Maintained speed for conceptual questions while adding precision where it matters
The Bigger Picture: PromptQL's Structured Intelligence
