parent
7a0e526eff
commit
78719ba4eb
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# @Time : 2025/4/19 18:27
|
||||
# @Author : old-tom
|
||||
# @File : local_test
|
||||
# @Project : reActLLMDemo
|
||||
# @Desc : 本地终端运行对话
|
||||
import langgraph.store.memory
|
||||
from llmagent.assistant_graph import graph
|
||||
|
||||
|
||||
def stream_graph_updates(user_input: str):
|
||||
"""
|
||||
流式输出
|
||||
:param user_input:
|
||||
:return:
|
||||
"""
|
||||
config = {"configurable": {"thread_id": "1"}}
|
||||
for chunk, metadata in graph.stream({"messages": [{"role": "user", "content": user_input}]}, config,
|
||||
stream_mode='messages'):
|
||||
if chunk.content:
|
||||
print(chunk.content, end='', flush=True)
|
||||
print('\n')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
while True:
|
||||
try:
|
||||
user_input = input("User: ")
|
||||
if user_input.lower() in ["quit", "exit", "q"]:
|
||||
print("Goodbye!")
|
||||
break
|
||||
|
||||
stream_graph_updates(user_input)
|
||||
except:
|
||||
user_input = "What do you know about LangGraph?"
|
||||
print("User: " + user_input)
|
||||
stream_graph_updates(user_input)
|
||||
break
|
@ -1,6 +0,0 @@
|
||||
def main():
|
||||
print("Hello from reactllmdemo!")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# @Time : 2025/4/19 18:27
|
||||
# @Author : old-tom
|
||||
# @File : local_test
|
||||
# @Project : reActLLMDemo
|
||||
# @Desc : 作为服务端运行
|
||||
|
||||
def main():
|
||||
print("Hello from reactllmdemo!")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Reference in new issue