Spaces:
Sleeping
Sleeping
Create queryGraph.py
Browse files- src/graphs/queryGraph.py +35 -0
src/graphs/queryGraph.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from langgraph.graph import StateGraph, START, END
|
| 2 |
+
from src.states.queryState import SparrowAgentState, SparrowInputState
|
| 3 |
+
|
| 4 |
+
from src.nodes.queryNode import QueryNode
|
| 5 |
+
from src.llms.groqllm import GroqLLM
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class QueryGraphBuilder:
|
| 10 |
+
def __init__(self, llm):
|
| 11 |
+
self.llm = llm
|
| 12 |
+
self.graph = StateGraph(SparrowAgentState, input_schema=SparrowInputState)
|
| 13 |
+
|
| 14 |
+
def build_query_graph(self):
|
| 15 |
+
"""
|
| 16 |
+
Build a graph for customer query inquiry
|
| 17 |
+
|
| 18 |
+
"""
|
| 19 |
+
self.query_node_obj= QueryNode(self.llm)
|
| 20 |
+
print(self.llm)
|
| 21 |
+
|
| 22 |
+
self.graph.add_node("clarify_with_user", self.query_node_obj.clarify_with_user)
|
| 23 |
+
self.graph.add_node("write_query_brief", self.query_node_obj.write_query_brief)
|
| 24 |
+
|
| 25 |
+
self.graph.add_edge(START, "clarify_with_user")
|
| 26 |
+
self.graph.add_edge("clarify_with_user", "write_query_brief")
|
| 27 |
+
self.graph.add_edge("write_query_brief", END)
|
| 28 |
+
|
| 29 |
+
return self.graph
|
| 30 |
+
|
| 31 |
+
llm = GroqLLM().get_llm()
|
| 32 |
+
|
| 33 |
+
graph_builder=QueryGraphBuilder(llm)
|
| 34 |
+
|
| 35 |
+
graph=graph_builder.build_query_graph().compile()
|