mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-17 11:44:44 +08:00
feat: add langgraph.json for langgraph studio debug
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
from langgraph.graph import StateGraph, START, END
|
||||
from langgraph.checkpoint.memory import MemorySaver
|
||||
|
||||
from .types import State
|
||||
from .nodes import (
|
||||
coordinator_node,
|
||||
@@ -15,13 +16,8 @@ from .nodes import (
|
||||
)
|
||||
|
||||
|
||||
def build_graph():
|
||||
"""Build and return the agent workflow graph."""
|
||||
# use persistent memory to save conversation history
|
||||
# TODO: be compatible with SQLite / PostgreSQL
|
||||
memory = MemorySaver()
|
||||
|
||||
# build state graph
|
||||
def _build_base_graph():
|
||||
"""Build and return the base state graph with all nodes and edges."""
|
||||
builder = StateGraph(State)
|
||||
builder.add_edge(START, "coordinator")
|
||||
builder.add_node("coordinator", coordinator_node)
|
||||
@@ -32,4 +28,25 @@ def build_graph():
|
||||
builder.add_node("coder", coder_node)
|
||||
builder.add_node("human_feedback", human_feedback_node)
|
||||
builder.add_edge("reporter", END)
|
||||
return builder
|
||||
|
||||
|
||||
def build_graph_with_memory():
|
||||
"""Build and return the agent workflow graph with memory."""
|
||||
# use persistent memory to save conversation history
|
||||
# TODO: be compatible with SQLite / PostgreSQL
|
||||
memory = MemorySaver()
|
||||
|
||||
# build state graph
|
||||
builder = _build_base_graph()
|
||||
return builder.compile(checkpointer=memory)
|
||||
|
||||
|
||||
def build_graph():
|
||||
"""Build and return the agent workflow graph without memory."""
|
||||
# build state graph
|
||||
builder = _build_base_graph()
|
||||
return builder.compile()
|
||||
|
||||
|
||||
graph = build_graph()
|
||||
|
||||
Reference in New Issue
Block a user