Skip to content

Conversation

@15525730080
Copy link

@15525730080 15525730080 commented Dec 22, 2025

PR Title

feat: add simple_AutoGLM.py as a standalone core-logic demonstration

Description

📋 简介 (Description)

本 PR 贡献了一个名为 simple_AutoGLM.py 的单文件脚本。该脚本旨在作为 Open-AutoGLM 的最小可行性示例(MVP),帮助开发者在不深入复杂代码库的情况下,快速理解 Agent 的底层运行原理。

🎯 核心价值 (Key Values)

  • 一键运行:仅需 API_KEYadb 环境即可运行,极大降低了上手门槛。
  • 原理解剖:将分散在原项目 HandlerBuilderRunner 等多个模块中的核心逻辑(如坐标转换、AST 指令解析、上下文图像清理)浓缩在一个文件内。
  • 教学导向:代码结构清晰,展示了如何通过 Prompt 工程与多模态模型交互来实现手机自动化任务。

✨ 核心机制复刻 (Core Mechanisms)

  1. 完整 System Prompt:还原了原版 18 条执行规则,包括弹窗处理、APP 启动检查及各类业务场景(点外卖、小红书等)的特定规范。
  2. 上下文管理优化:实现了关键的“内存清理”机制,在步骤迭代中仅保留当前最新的高清截图,以防止模型产生视觉幻觉并节省 Context 空间。
  3. ADB 增强执行
    • 坐标转换:将模型输出的 [0, 1000] 相对坐标自动映射至手机真实物理像素。
    • 中文支持:集成了 ADBKeyboard 调用逻辑,解决了 ADB 原生 input text 不支持中文的问题。
  4. 鲁棒解析引擎:结合正则表达式与 ast 模块,确保从模型生成的 <think><answer> 标签中精准提取结构化动作指令。

🚀 快速开始 (Quick Start)

  1. 安装依赖pip install adbutils openai pillow
  2. 配置环境:确保手机已开启 USB 调试并连接电脑。
  3. 修改代码:在 simple_AutoGLM.py 中填入智谱 AI 的 API_KEY
  4. 运行:执行 python simple_AutoGLM.py 并根据提示输入任务描述。

💡 维护者说明 (Notes for Maintainers)

该脚本放置在 examples/ 目录下(或项目根目录演示区),作为原工程化代码的“轻量版”补充。它不改变现有的包结构,主要用于社区交流、原理教学以及快速原型验证。


Author: fanbozhou

This script demonstrates the core principles of Open-AutoGLM and requires an API key and task description to run. It includes global configurations, a system prompt, message building, context management, action parsing, and device execution logic.
@15525730080 15525730080 changed the title 用于演示Open-AutoGLM核心原理的可执行脚本Add executable script for Open-AutoGLM demonstration # PR Title feat: add simple_AutoGLM.py as a standalone core-logic demonstration Dec 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant