debugging

This commit is contained in:
2026-01-29 18:06:20 +08:00
parent 06deafc026
commit b8e9f73e89
2 changed files with 25 additions and 23 deletions

View File

@@ -146,16 +146,15 @@ if __name__ == "__main__":
HumanMessage("use the calculator tool to calculate 92*55 and say the answer")]
},{"configurable": {"thread_id": "3"}}
out = route.invoke(*nargs)
assert 0
# out = route.invoke(*nargs)
# assert 0
# for chunk, metadata in graph.stream({"inp": nargs}, stream_mode="messages"):
# node = metadata.get("langgraph_node")
# if node not in ("model"):
# print(node)
# continue # skip router or other intermediate nodes
# for mode, data in graph.stream(*nargs, stream_mode=["messages", "values"]):
# print(data)
# # Print only the final message content
# if isinstance(chunk, (BaseMessageChunk, BaseMessage)) and getattr(chunk, "content", None):
# print(chunk.content, end="", flush=True)
for _, mode, out in graph.stream(*nargs, subgraphs=True,
stream_mode=["messages", "values"]):
if mode == "values":
msgs = out.get("messages")
l = len(msgs) if msgs is not None else -1
print(type(out), out.keys(), l)

View File

@@ -206,8 +206,8 @@ if __name__ == "__main__":
from lang_agent.graphs.tool_nodes import AnnotatedToolNode, ToolNodeConfig, ChattyToolNodeConfig
load_dotenv()
route:RoutingGraph = RoutingConfig().setup()
# route:RoutingGraph = RoutingConfig(tool_node_config=ChattyToolNodeConfig()).setup()
route:RoutingGraph = RoutingConfig(tool_node_config=ChattyToolNodeConfig()).setup()
graph = route.workflow
nargs = {
@@ -215,16 +215,19 @@ if __name__ == "__main__":
HumanMessage("use calculator to calculate 926*84")]
},{"configurable": {"thread_id": "3"}}
for chunk in route.invoke(*nargs, as_stream=True):
# print(f"\033[92m{chunk}\033[0m", end="", flush=True)
continue
# for chunk in route.invoke(*nargs, as_stream=True):
# # print(f"\033[92m{chunk}\033[0m", end="", flush=True)
# continue
# for chunk, metadata in graph.stream({"inp": nargs}, stream_mode="messages"):
# node = metadata.get("langgraph_node")
# if node not in ("model"):
# continue # skip router or other intermediate nodes
# # Print only the final message content
# if isinstance(chunk, (BaseMessageChunk, BaseMessage)) and getattr(chunk, "content", None):
# print(chunk.content, end="", flush=True)
for _, mode, out in graph.stream({"inp": nargs},
subgraphs=True,
stream_mode=["messages", "values"]):
# print(mode)
if mode == "values":
msgs = out.get("messages")
l = len(msgs) if msgs is not None else -1
print(type(out), out.keys(), l)
else:
print(type(out), mode, "==================================================")
print(out[0].content)