|
@@ -122,7 +122,7 @@ def run_conversation(messages):
|
|
if not any(msg.get("role") == "system" for msg in messages):
|
|
if not any(msg.get("role") == "system" for msg in messages):
|
|
messages.insert(0, {"role": "system", "content": system_prompt})
|
|
messages.insert(0, {"role": "system", "content": system_prompt})
|
|
|
|
|
|
- print("\n🤖 助手: ", end="", flush=True)
|
|
|
|
|
|
+ print("\n助手: ", end="", flush=True)
|
|
|
|
|
|
# 多轮工具调用循环
|
|
# 多轮工具调用循环
|
|
while True:
|
|
while True:
|
|
@@ -163,9 +163,9 @@ def run_conversation(messages):
|
|
"content": tool_result
|
|
"content": tool_result
|
|
})
|
|
})
|
|
|
|
|
|
- print(f"\n\n🔍 工具结果 ({tool_name}): {tool_result}")
|
|
|
|
|
|
+ print(f"\n\n工具结果 ({tool_name}): {tool_result}")
|
|
|
|
|
|
- print("\n🤖 助手: ", end="", flush=True)
|
|
|
|
|
|
+ print("\n助手: ", end="", flush=True)
|
|
else:
|
|
else:
|
|
# 没有工具调用,对话结束
|
|
# 没有工具调用,对话结束
|
|
messages.append({
|
|
messages.append({
|
|
@@ -185,7 +185,7 @@ def main():
|
|
print("开始多轮对话(输入'exit'结束对话)")
|
|
print("开始多轮对话(输入'exit'结束对话)")
|
|
|
|
|
|
while True:
|
|
while True:
|
|
- user_input = input("\n👨💻 用户: ").strip()
|
|
|
|
|
|
+ user_input = input("\n用户: ").strip()
|
|
|
|
|
|
if user_input.lower() in ['退出', 'quit', 'exit']:
|
|
if user_input.lower() in ['退出', 'quit', 'exit']:
|
|
print("对话结束")
|
|
print("对话结束")
|