Files
brojs-task-699cc158d6d3a554…/main.py
T

18 lines
629 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import sys
from agent import graph
if __name__ == "__main__":
print("LangGraph streammode demo. Type 'exit' to quit.")
state = {"messages": []}
for line in sys.stdin:
user_input = line.rstrip('\n')
if not user_input:
continue
if user_input.lower() in {"exit", "quit"}:
break
for partial in graph.stream({"input": user_input, "messages": state["messages"]}):
print(partial.get("partial", ""), end="")
print()
state["messages"] = graph.invoke({"input": user_input, "messages": state["messages"]})["messages"]
print("Goodbye!")