sanket03 commited on
Commit
d64e535
·
1 Parent(s): d24b9ac

added graph builder

Browse files
src/langgraphagenticai/graph/graph_builder.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from langgraph.graph import StateGraph, START,END, MessagesState
2
+ from langgraph.prebuilt import tools_condition,ToolNode
3
+ from langchain_core.prompts import ChatPromptTemplate
4
+ from src.langgraphagenticai.state.state import State
5
+ from src.langgraphagenticai.nodes.basic_chatbot_node import BasicChatbotNode
6
+
7
+
8
+
9
+
10
+ class GraphBuilder:
11
+
12
+ def __init__(self,model):
13
+ self.llm=model
14
+ self.graph_builder=StateGraph(State)
15
+
16
+ def basic_chatbot_build_graph(self):
17
+ """
18
+ Builds a basic chatbot graph using LangGraph.
19
+ This method initializes a chatbot node using the `BasicChatbotNode` class
20
+ and integrates it into the graph. The chatbot node is set as both the
21
+ entry and exit point of the graph.
22
+ """
23
+ self.basic_chatbot_node=BasicChatbotNode(self.llm)
24
+ self.graph_builder.add_node("chatbot",self.basic_chatbot_node.process)
25
+ self.graph_builder.add_edge(START,"chatbot")
26
+ self.graph_builder.add_edge("chatbot",END)
27
+
28
+ def setup_graph(self, usecase: str):
29
+ """
30
+ Sets up the graph for the selected use case.
31
+ """
32
+ if usecase == "Basic Chatbot":
33
+ self.basic_chatbot_build_graph()
34
+ return self.graph_builder.compile()
35
+
36
+
37
+
38
+