choose_your_knowledge_base_workflow.json
Overview
The choose_your_knowledge_base_workflow.json file defines a conversational retrieval workflow designed to let users select a knowledge base from a dropdown menu and then query that selected knowledge base to generate accurate, knowledge-base-specific responses.
This workflow orchestrates multiple components:
A Begin node that prompts the user and collects their knowledge base choice.
A Retrieval component that uses the selected knowledge base to fetch relevant documents.
An Agent component that processes the retrieval output and generates answers strictly based on the selected knowledge base content.
A Message component that outputs the Agent's response back to the user.
The primary goal is to ensure that answers are generated exclusively from the selected knowledge base, preventing any hallucination or inference beyond the retrieved documents, and maintaining transparency about the information source.
Components and Their Roles
1. Begin Component (begin)
Purpose: Entry point of the workflow. It initiates the conversation, presents the user with a dropdown menu to select a knowledge base, and collects the user's query.
Key Properties:
enablePrologue: Enables a prologue message that greets the user.prologue: "Hi! I'm your retrieval assistant. What do you want to ask?"mode: Conversational mode.inputs:knowledge base: Dropdown options for the user to select from:knowledge base 1
knowledge base 2
knowledge base 3
Downstream: Passes control to the
Retrievalcomponent.
Usage Example:
{ "knowledge base": "knowledge base 2" }User is greeted and prompted to select a knowledge base and ask a question.
2. Retrieval Component (Retrieval:RudeCyclesKneel)
Purpose: Fetches relevant documents or content from the selected knowledge base based on the user's query.
Key Parameters:
kb_ids: Binds to the knowledge base selected in thebegincomponent (begin@knowledge base).query: Uses the system variablesys.querywhich holds the user input query.top_n: Returns the top 8 relevant documents.top_k: Candidate documents considered for retrieval (1024).similarity_threshold: 0.2, minimal similarity to consider a document relevant.keywords_similarity_weight: 0.7, weight for keyword matching in similarity calculation.outputs:formalized_content: String output containing the retrieved content.
Downstream: Sends retrieved data to the
Agentcomponent.
Implementation Details:
The retrieval algorithm likely combines semantic similarity with keyword weighting to score documents.
It filters documents below the similarity threshold.
Retrieves top N documents to pass along for answer generation.
Usage Example (conceptual):
{ "query": "How to configure the knowledge base?", "kb_ids": ["knowledge base 2"] }Returns relevant document snippets related to the query.
3. Agent Component (Agent:ProudDingosShout)
Purpose: Acts as a conversational AI agent specialized in answering questions strictly based on the retrieved knowledge base content.
Key Parameters:
llm_id:"deepseek-chat@DeepSeek"- the language model used for response generation.max_tokens: 256 tokens max per response.max_retries: 3 retries on error.message_history_window_size: 12 messages for conversational context.frequency_penalty: 0.7 (disabled).presence_penalty: 0.4 (disabled).prompts: Uses a user prompt template that includes:User's query: {sys.query} Retrieval content: {Retrieval:RudeCyclesKneel@formalized_content}sys_prompt: Defines the role and strict behavioral guidelines for the agent, summarized as:Answer questions exclusively based on retrieved KB content.
Do not create or infer outside the KB.
Indicate clearly when info is unavailable.
Prefer accuracy over completeness.
Provide citations and quotes when possible.
Use a strict response format in markdown with an "## Answer" heading.
Downstream: Passes the generated content to the
Messagecomponent.
Implementation Details:
The agent enforces strict knowledge base adherence via prompt engineering.
It uses retrieval-augmented generation: the retrieval results are fed as context.
It prevents hallucination by explicit instructions and response formatting.
Retries and error handling are in place to ensure robustness.
Usage Example (conceptual):
## Answer According to the documentation, to configure the knowledge base, you should...
4. Message Component (Message:DarkRavensType)
Purpose: Final output component that displays the agent's generated answer to the user.
Key Parameters:
content: Receives the content from the agent's output.
Downstream: None (end of workflow).
Usage:
This component simply renders the agent's response to the interface.
Workflow Flow Summary
The user is greeted and selects a knowledge base from a dropdown.
User inputs a query.
The Retrieval component fetches relevant documents from the selected knowledge base.
The Agent component generates a response strictly based on the retrieved content.
The Message component outputs the answer.
Important Implementation Details
Strict Knowledge Base Adherence: The agent uses a carefully crafted system prompt to limit responses strictly to the retrieved documents.
Retrieval Parameters: Parameters like
keywords_similarity_weightandsimilarity_thresholdhelp balance relevance and precision in document retrieval.Retry and Error Handling: Agent retries failed generations up to 3 times with a delay.
Conversational Context: The agent maintains a message history window for context in multi-turn conversations.
User Transparency: The agent transparently indicates when answers are not found in the knowledge base.
Interaction with Other Parts of the System
The
begincomponent interacts with UI elements to receive user input including the knowledge base selection.The
Retrievalcomponent relies on external knowledge bases identified bykb_ids.The agent uses a language model service identified by
llm_id(deepseek-chat@DeepSeek).System variables (
sys.query,sys.user_id) are used for passing user queries and context.This workflow can be part of a larger conversational assistant platform where multiple workflows can be selected.
Visual Diagram
flowchart LR
Begin["Begin\n- Knowledge base selection\n- User query input"] --> Retrieval["Retrieval\n- Fetch docs from selected KB"]
Retrieval --> Agent["Agent\n- Generate answers strictly from retrieval"]
Agent --> Message["Message\n- Output response to user"]
subgraph Notes
N1["Note: Configure dropdown with knowledge bases"]
N2["Note: Retrieval uses selected KB"]
N3["Note: Agent answers based on retrieval only"]
end
Begin --- N1
Retrieval --- N2
Agent --- N3
Summary
This JSON file defines a modular, strict knowledge base question-answering workflow that guides users through selecting a knowledge base, retrieving relevant documents, and generating precise answers based on those documents only. It emphasizes accuracy, source transparency, and strict adherence to the selected knowledge base content, making it suitable for enterprise or documentation-focused QA systems.