-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
22 lines (20 loc) · 796 Bytes
/
main.py
File metadata and controls
22 lines (20 loc) · 796 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from agents import Agent
def save_session_id(session_id):
"""将 session_id 保存到系统临时目录中的固定文件"""
import tempfile
temp_file = tempfile.gettempdir() + "\\session_id.txt"
with open(temp_file, "w") as f:
f.write(session_id)
print(f"\n退出程序,session_id 已保存到 {temp_file}。")
if __name__ == "__main__":
agent = Agent()
try:
while True:
user_input = input("\n请输入消息(或输入 '/exit' 退出):")
if user_input.lower() == "/exit":
save_session_id(agent.session_id)
break
response = agent.send_message(user_input)
print(f"Agent回复: {response}\n")
except KeyboardInterrupt:
save_session_id(agent.session_id)