π Bonus Exercise β Advanced Techniques for Smarter RAGs
πͺ This is a free-form, bonus exercise. There's no "correct" outcome β only deeper exploration.
You've already built a powerful testing assistant. Now it's time to experiment with advanced Retrieval-Augmented Generation (RAG) strategies and Dify-specific features that make your assistant more intelligent, focused, and useful for testers.
π§ Why Go Beyond the Basics?β
While standard RAG systems retrieve documents and pass them to a language model, real-world software testing questions require:
- Better focus on relevant information
- More structured reasoning for complex queries
- Dynamic adaptation to different types of questions
This is where combining advanced RAG strategies with Dify blocks unlocks the next level.

π§ͺ Part 1 β Advanced RAG Techniquesβ
These are conceptual strategies used in many RAG systems that help with retrieval quality, context relevance, and multi-turn generation.
πͺ 1. ParentβChild Retrievalβ
Why it matters: You often need related items together: a parent epic with child issues, or a test suite with all cases. This improves reasoning and coverage.
How to use it:
- Structure your documents with parent-child metadata (e.g.,
epic_id,test_suite) - Filter in Dify's knowledge retriever by metadata field to retrieve children or a whole group
π§Ή 2. Query Rewritingβ
Why it matters: Many queries are vague or poorly phrased. Rewriting improves retrieval and LLM generation.
How to use it:- Use a classifier or prompt node to detect vague queries
- Add system prompts that reformulate the query with more context before retrieval
π 3. Iterative or Multi-Query Retrievalβ
Why it matters: If a query references multiple issues or modules, each subquery deserves its own chunk of context.
How to use it:- Split queries using a Parameter Extractor
- Loop over values with the Iteration node
- Combine or format answers at the end
π― 4. Retrieval Filtering and Chunk Designβ
Why it matters: Filtering based on metadata avoids off-topic results. Chunking well ensures completeness without verbosity.
How to use it:- During ingestion, assign metadata like
component,priority, ortype - Use metadata filters in the Retrieval node
- Experiment with different chunk sizes: smaller for bugs, bigger for concepts
βοΈ Part 2 β Powerful Dify Blocks to Boost Your Chatbotβ
These are not RAG strategies per se, but Dify capabilities that improve your assistant's intelligence and control.
π 1. Parameter Extractorβ
Extracts structured data (like issue keys, module names, or dates) from user queries. Ideal for filtering or branching logic.
π§ 2. Question Classifierβ
Classifies user intent (e.g., test generation vs. documentation lookup). Each category can follow a different chatflow.
Try categories like:specific_issuelist_issuesgeneral_projecttest_relatedtest_generationunrelated
π 3. Iterationβ
Use it to generate a loop over multiple issues. Great for:
- "Generate test cases for REST-201, REST-202, REST-203"
- "Summarize these five bugs"
βοΈ 4. If/Else Routingβ
Adds logic to your flow:
- If
issue_keyexists β go to filtered retrieval - If query is
unrelatedβ reply with a fallback message
π§° 5. Prompt Templatesβ
Use specialized prompts depending on user intent. For example:
- System prompt for test generation (
You are a Gherkin generator...) - System prompt for architecture questions (
You are a system design assistant...)
π§ͺ Bonus Challengesβ
Let's revisit our question classifier. It identifies 6 types of queries. Try customizing each path using the above techniques:
| Category | Try This... |
|---|---|
specific_issue | Parameter extractor β filtered retriever by issue_key |
list_issues | Parameter extractor β iteration over each β summarize or generate |
general_project | Dedicated retriever + LLM focused on project scope |
test_related | Retrieval filtering by type = test_strategy or tuned prompt |
test_generation | Custom prompt + single or iterative test generation |
unrelated | Route to fallback LLM with polite redirect message |
ποΈ Download: Preconfigured Bonus Chatflowβ
You can download a ready-made version of this bonus exercise, including a fully configured Dify chatflow with:
- Question classifier
- Iteration for multi-issue generation
- Metadata-based filters
- Specialized prompts per query type
β¬οΈ Download Exercise 4 Sample
π‘ Import this YAML file into Dify and start tweaking!
π Wrap-upβ
If you've made it here, congratulations β you're ready to take Testus Patronus to the next level! Explore, experiment, and summon the full potential of AI-powered software testing.