# LangGraph with Conditional Routing # Demonstrates conditional flow based on message content agents: classifier: type: llm config: provider: openai model: gpt-3.5-turbo temperature: 0.1 system_prompt: | Classify the input as either: - "question" if it's asking something - "command" if it's requesting an action - "statement" if it's providing information Reply with only one word: question, command, or statement. qa_agent: type: llm config: provider: openai model: gpt-4 temperature: 0.7 system_prompt: "Answer questions accurately and thoroughly." command_processor: type: tool config: tools: ["echo", "math"] safe_mode: true acknowledger: type: llm config: provider: openai model: gpt-3.5-turbo temperature: 0.5 system_prompt: "Acknowledge statements and provide relevant comments." # NEW: Unified routes section routes: conditional_flow: type: graph # REQUIRED: Must specify type entry_point: start nodes: # Classify the input classify: type: agent agent: classifier # Route based on classification router: type: conditional condition: type: always # The actual routing happens via edges # Process question handle_question: type: agent agent: qa_agent # Process command handle_command: type: agent agent: command_processor # Process statement handle_statement: type: agent agent: acknowledger edges: # Initial flow - source: start target: classify - source: classify target: router # Conditional routing based on classification - source: router target: handle_question condition: type: content_contains text: "question" - source: router target: handle_command condition: type: content_contains text: "command" - source: router target: handle_statement condition: type: content_contains text: "statement" # All paths lead to end - source: handle_question target: end - source: handle_command target: end - source: handle_statement target: end # Simple stream setup input_handler: type: stream # REQUIRED: Must specify type stream_type: cold operators: - type: graph_execute params: graph: conditional_flow publications: - __output__ merges: - sources: [__input__] target: input_handler context: global: app_name: "Conditional LangGraph Router"