Use this file to discover all available pages before exploring further.
The CriticNode class evaluates the output of a target node against a list of criteria. It is automatically added as a dependent of the target node so it always runs after the node it evaluates.
extraction_critic = CriticNode( id="extraction_critic", name="Extraction Accuracy Check", target_node="extractor", criteria=[ "all required fields extracted", "values are in the correct format", "no hallucinated information" ])
# ✅ Good — specific, observablecriteria=[ "response is between 100 and 200 words", "includes at least one concrete example", "no grammatical errors"]# ❌ Vague — hard to evaluate objectivelycriteria=[ "good quality", "sounds nice"]
Match criteria to the task
# For customer-facing contentcriteria=[ "friendly and empathetic tone", "directly addresses the user's question", "offers a clear next step"]# For internal analysiscriteria=[ "cites data from the source", "identifies at least 3 trends", "recommends concrete actions"]
from fibonacci import Workflow, LLMNode, CriticNodewf = Workflow(name="blog-writer")# Generate blog postwriter = LLMNode( id="writer", name="Write Blog Post", instruction=""" Write a blog post about {{input.topic}}. Target audience: {{input.audience}} Desired length: approximately {{input.word_count}} words Tone: {{input.tone}} """, model="claude-sonnet-4-6")# Evaluate qualitycritic = CriticNode( id="quality_check", name="Editorial Quality Check", target_node="writer", criteria=[ "engaging from the first paragraph", "well-researched and accurate", "writing style matches the target audience", "close to the requested word count", "tone is consistent throughout", "includes actionable takeaways", "compelling conclusion" ])wf.add_nodes([writer, critic])result = wf.run(input_data={ "topic": "Introduction to Machine Learning", "audience": "business professionals", "word_count": 800, "tone": "informative yet approachable"})print(result.output_data["quality_check"])