Overview
Workflow nodes are async functions that process theDocMindState as it flows through the graph. Each node performs a specific task, updates the state, and tracks its execution in the node_history.
All nodes follow the signature:
Node Functions
decompose_node
Decomposes the user query into structured sub-queries for targeted retrieval.- Initializes a
QueryDecomposercomponent - Decomposes the user query into structured sub-queries
- Stores decomposition result in state
- Appends “decompose” to
node_history
Structured decomposition of the original query
Appends “decompose” to the history
retrieve_node
Retrieves relevant documentation sections based on the query and decomposition.- Initializes
MockDocumentStoreandAgenticRetriever - Retrieves relevant sections using query and decomposition
- Stores retrieved sections in state
- Appends “retrieve” to
node_history
List of retrieved documentation sections
Appends “retrieve” to the history
generate_node
Generates a response based on the retrieved documentation sections.- Initializes a
ResponseGeneratorcomponent - Generates response from retrieved sections
- Stores generated response in state
- Appends “generate” to
node_history
Generated response based on retrieved sections
Appends “generate” to the history
judge_node
Evaluates the generated response for hallucinations and quality.- Initializes an
LLMJudgecomponent - Evaluates generated response against retrieved sections
- Stores verdict in state
- Increments
retry_countif hallucination detected - Appends “judge” to
node_history
Verdict containing:
is_hallucinated(bool): Whether response contains hallucinationsshould_return(bool): Whether response is acceptable to return
Incremented by 1 if
is_hallucinated is TrueAppends “judge” to the history
output_node
Produces the final output based on the judge verdict.- Checks if judge verdict allows returning the response
- Sets
final_outputto either generated response or fallback message - Appends “output” to
node_history
Final output to return to user:
- If
should_returnis True: returnsgenerated_response - Otherwise: returns fallback message
Appends “output” to the history
Conditional Logic
should_retry
Determines whether to retry retrieval or proceed to output based on judge verdict and retry count.Current workflow state
"retry": Retry from retrieve_node (if hallucinated and retry_count < 2)"output": Proceed to output_node
- Maximum retries: 2 attempts
- Retry triggered when:
judge_verdict.is_hallucinatedisTrueretry_countis less than 2
- Logs retry attempt when retrying
Node Execution Order
The typical execution order through the workflow:- decompose → Breaks down query
- retrieve → Fetches relevant sections
- generate → Creates response
- judge → Evaluates quality
- Conditional:
- If hallucinated and retry_count < 2: Return to retrieve
- Otherwise: Proceed to output
- output → Returns final result