Spaces:
Sleeping
Sleeping
File size: 859 Bytes
6cbca40 c0a7f25 6cbca40 c0a7f25 6cbca40 c0a7f25 6cbca40 c0a7f25 6cbca40 c0a7f25 6cbca40 c0a7f25 |
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 |
from langgraph.graph import StateGraph, START, END
from .func import State
from langgraph.graph.state import CompiledStateGraph
from langgraph.store.memory import InMemoryStore
class PrimaryChatBot:
def __init__(self):
pass
@staticmethod
def should_continue(state: State):
messages = state["messages"]
last_message = messages[-1]
if not last_message.tool_calls:
return "end"
else:
return "continue"
def node(self, graph: StateGraph):
return graph
def edge(self, graph: StateGraph):
return graph
def __call__(self, checkpointer=InMemoryStore()) -> CompiledStateGraph:
graph = StateGraph(State)
graph: StateGraph = self.node(graph)
graph: StateGraph = self.edge(graph)
return graph.compile(checkpointer=checkpointer)
|