Files
Open-AutoGLM/examples/demo_thinking.py
2025-12-08 23:55:00 +08:00

85 lines
2.2 KiB
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.
#!/usr/bin/env python3
"""
演示 thinking 输出的示例
这个脚本展示了在 verbose 模式下Agent 会同时输出思考过程和执行动作。
"""
from phone_agent import PhoneAgent
from phone_agent.agent import AgentConfig
from phone_agent.model import ModelConfig
def main():
print("=" * 60)
print("Phone Agent - Thinking 输出演示")
print("=" * 60)
# 配置模型
model_config = ModelConfig(
base_url="http://localhost:8000/v1",
model_name="autoglm-phone-9b",
temperature=0.1,
)
# 配置 Agent (verbose=True 会输出详细信息)
agent_config = AgentConfig(
max_steps=10,
verbose=True, # 开启详细输出
)
# 创建 Agent
agent = PhoneAgent(
model_config=model_config,
agent_config=agent_config,
)
# 执行任务
print("\n📱 开始执行任务...\n")
result = agent.run("打开小红书搜索美食攻略")
print("\n" + "=" * 60)
print(f"📊 最终结果: {result}")
print("=" * 60)
if __name__ == "__main__":
"""
运行此脚本,你将看到如下格式的输出:
==================================================
💭 思考过程:
--------------------------------------------------
当前在系统桌面,需要先启动小红书应用,然后进行搜索
--------------------------------------------------
🎯 执行动作:
{
"_metadata": "do",
"action": "Launch",
"app": "小红书"
}
==================================================
(执行后会继续下一步...)
==================================================
💭 思考过程:
--------------------------------------------------
小红书已打开,现在需要点击搜索框并输入关键词
--------------------------------------------------
🎯 执行动作:
{
"_metadata": "do",
"action": "Tap",
"element": [500, 100]
}
==================================================
... (更多步骤)
🎉 ================================================
✅ 任务完成: 已成功搜索美食攻略
==================================================
"""
main()