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