File size: 1,345 Bytes
35b2eed
1b07c47
35b2eed
1b07c47
8041492
35b2eed
 
 
 
 
 
1b07c47
 
 
35b2eed
b18aed5
1b07c47
 
35b2eed
1b07c47
35b2eed
 
 
 
 
 
1b07c47
 
35b2eed
 
1b07c47
 
35b2eed
 
 
 
 
1b07c47
 
35b2eed
b18aed5
 
35b2eed
 
1b07c47
35b2eed
 
b18aed5
 
 
1b07c47
35b2eed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Clean, simple agent.py - let the LLM choose
from langgraph.graph import StateGraph, END
from typing import TypedDict

from agent.nodes import (
    AgentState,
    SmartRouter,  # Our new simple LLM-driven router
    # Keep your existing working nodes
    CalculatorNode,
    WebSearchNode,
    DataExtractionNode,
    ImageExtractionNode,
    AudioExtractionNode,
    VideoExtractionNode,
    MultiStepNode,
    AnswerRefinementNode,
)

# Simple workflow - let the LLM decide everything
workflow = StateGraph(AgentState)

# Available execution nodes
execution_nodes = [
    "CalculatorNode",
    "WebSearchNode", 
    "DataExtractionNode",
    "ImageExtractionNode",
    "AudioExtractionNode",
    "VideoExtractionNode", 
    "MultiStepNode",
]

# Add the smart router
workflow.add_node("SmartRouter", SmartRouter)

# Add all execution nodes
for node in execution_nodes:
    workflow.add_node(node, globals()[node])

# Add refinement
workflow.add_node("AnswerRefinementNode", AnswerRefinementNode)

# Simple flow: Router -> Execution -> Refinement -> Done
workflow.set_conditional_entry_point(SmartRouter, {node: node for node in execution_nodes})

# All execution nodes go to refinement
for node in execution_nodes:
    workflow.add_edge(node, "AnswerRefinementNode")

workflow.add_edge("AnswerRefinementNode", END)

app = workflow.compile()