From 85b7ea4f6cd715dc74ac5ad3b2caf196ef1ff55d Mon Sep 17 00:00:00 2001 From: Flik Date: Tue, 21 Oct 2025 21:38:46 +0800 Subject: [PATCH] =?UTF-8?q?feat(ai):=20=E6=B7=BB=E5=8A=A0=20AI=20=E5=8A=A8?= =?UTF-8?q?=E4=BD=9C=E6=94=AF=E6=8C=81=EF=BC=8C=E9=9B=86=E6=88=90=20OpenAI?= =?UTF-8?q?=20GPT-4o=20=E9=A9=B1=E5=8A=A8=E8=87=AA=E5=8A=A8=E5=8C=96?= =?UTF-8?q?=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 AIExecutor 类用于调用 OpenAI API 并解析结构化指令 - 在 Settings 中增加 OpenAI 相关配置项(API Key、模型、超时等) - 扩展 ActionContext 以支持注入 AI 服务实例 - 实现 AIAction 类处理自然语言提示并执行 AI 规划的浏览器操作 - 支持通过 max_step 参数限制 AI 操作步数(默认5,最大20) - 支持 include_html 和 include_variables 控制上下文内容传递 - 支持运行时覆盖模型和温度参数 - 增加详细的错误处理与日志记录机制- 更新 README 文档说明 AIAction 使用方法与配置选项 - 更新 XSD schema 支持 ai 类型动作定义- 在 FlowRunner 中完善步骤记录逻辑,支持 AI 执行结果输出 - 添加 plan_ai_action.md 设计文档描述实现细节与规划 --- .idea/misc.xml | 3 + README.md | 25 ++++ plan_ai_action.md | 51 ++++++++ schema/xspider.xsd | 3 +- xspider/actions/base.py | 2 + xspider/actions/builtin.py | 254 ++++++++++++++++++++++++++++++++++++- xspider/ai/__init__.py | 3 + xspider/ai/executor.py | 182 ++++++++++++++++++++++++++ xspider/app.py | 9 ++ xspider/runner.py | 70 ++++++++-- xspider/settings.py | 15 +++ 11 files changed, 604 insertions(+), 13 deletions(-) create mode 100644 plan_ai_action.md create mode 100644 xspider/ai/__init__.py create mode 100644 xspider/ai/executor.py diff --git a/.idea/misc.xml b/.idea/misc.xml index fef645d..8b44876 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -4,4 +4,7 @@