File size: 693 Bytes
3002e1b
 
 
872d043
3002e1b
 
 
 
 
 
 
 
872d043
 
3002e1b
872d043
 
 
3002e1b
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from langgraph.graph import StateGraph, START, END
from langgraph.checkpoint.memory import MemorySaver
from .utils.state import State
from .utils.nodes import ChatbotNode, FetchDataNode

class ChatbotAgent:
    def __init__(self):
        self.memory = MemorySaver()

    def chatbot_graph(self):
        graph_builder= StateGraph(State)
        graph_builder.add_node("chatbot", ChatbotNode().run)
        graph_builder.add_node("fetch_data", FetchDataNode().run)
        
        graph_builder.add_edge(START, "chatbot")
        graph_builder.add_edge("chatbot", 'fetch_data')
        graph_builder.add_edge("fetch_data", END)


        return graph_builder.compile(checkpointer=self.memory)