Skip to content

feat: add configure.py — interactive initialization wizard#295

Merged
lsdefine merged 2 commits into
lsdefine:mainfrom
windcat2333:feature/setup-wizard
May 8, 2026
Merged

feat: add configure.py — interactive initialization wizard#295
lsdefine merged 2 commits into
lsdefine:mainfrom
windcat2333:feature/setup-wizard

Conversation

@windcat2333

@windcat2333 windcat2333 commented May 8, 2026

Copy link
Copy Markdown
Contributor

概要

为 GenericAgent 新增 configure.py,提供交互式初始化配置,替代手动编辑 mykey.py 的流程。

本 PR 提供一个终端交互式向导,覆盖:

  1. LLM 模型配置 — 12 家厂商可选,API Key 脱敏输入,自动探测可用模型,支持主备双模型故障转移 + 高级选项(proxy / context_win / stream / user_agent)
  2. 消息平台配置 — 支持 Telegram / QQ / 飞书(终端二维码扫码)/ 企业微信 / 钉钉 / Discord
  3. 自动生成 mykey.py — 备份旧配置,模板字段按 mykey_template.py 精确对齐

文件变更

D  setup.py  (原 893 行,重命名)
A  configure.py  (958 行)

文件名从 setup.py 改为 configure.py,避免与 pip/setuptools 冲突。

交互流程

$ python configure.py
  1. 欢迎页 — Python 版本检查(含 3.14 兼容性警告)+ 已有 mykey.py 检测
  2. 顶层菜单 — 可选:仅 LLM / 仅平台 / 两项都配。单项配完后追问是否继续另一项
  3. LLM 配置 — 选厂商 → API Key 脱敏输入(输入时实时显示 sk-302a****6d6d)→ 自动探测可用模型 → 可选第二个模型做故障转移 → 高级选项
  4. 消息平台 — 多选平台 → 逐个填写 Token/Bot ID → 飞书支持终端二维码扫码
  5. 完成 — 写入 mykey.py,输出启动命令 + pip 依赖提示 + GETTING_STARTED 入门示例

Review 反馈处理

# 反馈 处理
1 文件名与 setuptools 冲突 改名为 configure.py
2 lark.AppAccessDeniedError / lark.AppExpiredError 不存在 改为 except Exception
3 probe_models 无代理支持 新增 _get_proxy_handler(),读取 HTTPS_PROXY/HTTP_PROXY
4 secret 参数未实现 改为 masked_input(),输入时实时显示脱敏版本
5 缺少 pip install 提示 配置完成后输出 pip install xxx

@lsdefine lsdefine left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

非常棒的贡献!交互式向导对新用户降低配置门槛很有价值,代码结构清晰、数据驱动设计很好,预计改完以下几点就能合并 👍

需要修改

1. 文件名 setup.py 与 setuptools 冲突
根目录的 setup.py 会被 pip/setuptools 误识别为包安装脚本(pip install . 会触发)。建议改名为 init_wizard.pyconfigure.py

2. 飞书扫码段的异常类名不存在
lark.register_app() 没问题(已验证存在),但 lark.AppAccessDeniedErrorlark.AppExpiredError 在 lark-oapi 包中不存在。如果触发这两个 except 分支会抛 AttributeError。建议改为捕获通用 Exception 或查阅 SDK 文档确认实际异常类名。

3. probe_models 的 urllib 请求无代理支持
国内用户直连 Anthropic/OpenRouter 大概率超时。建议支持读取环境变量 HTTP_PROXY/HTTPS_PROXY(可用 urllib.request.ProxyHandler),或加个代理参数。

建议改进(非阻塞)

  • ask_inputsecret 参数声明了但未实现,API Key 会明文回显。建议 secret=True 时用 getpass.getpass()
  • 平台 deps 声明了但流程中没有自动安装也没提示用户手动装,建议配置完成后输出一行 pip install xxx 提示。

@windcat2333 windcat2333 changed the title feat: add setup.py — interactive initialization wizard feat: add configure.py — interactive initialization wizard May 8, 2026
@windcat2333

Copy link
Copy Markdown
Contributor Author

Review 反馈回复:

5 项反馈已全部处理:

# 反馈 处理
1 文件名与 setuptools 冲突 已重命名为 configure.py
2 lark.AppAccessDeniedError / lark.AppExpiredError 不存在 已改为 except Exception
3 probe_models 无代理支持 新增 _get_proxy_handler(),读取 HTTPS_PROXY/HTTP_PROXY 环境变量
4 secret 参数未实现 已改为 masked_input(),输入时实时显示脱敏版本(sk-302a****6d6d),支持逐字输入和粘贴
5 缺少 pip install 提示 配置完成后输出 pip install xxx

另外改进:

  • 顶层菜单支持灵活选择(仅 LLM / 仅平台 / 两项全配),配完后追问是否继续
  • 新增 2 个 Provider:CRS Gemini Ultra、Kimi/Moonshot OAI
  • Python 3.14 兼容性警告(匹配 GETTING_STARTED.md)
  • 已有 mykey.py 时提示是否重新配置
  • 欢迎消息限定企业微信(修复变量名 wecom_welcome_message
  • 配置完成后展示 GETTING_STARTED 入门示例命令
  • 高级 LLM 选项:proxy、context_win、stream、user_agent、thinking_budget_tokens

PTAL

… all feedback

- Rename setup.py → configure.py to avoid pip/setuptools conflict
- Fix lark exception: catch generic Exception instead of non-existent AppAccessDeniedError/AppExpiredError
- Add proxy support to probe_models via HTTPS_PROXY/HTTP_PROXY env vars
- Implement masked_input() with real-time API key masking
- Add pip install hints for messaging platform dependencies
- Add 2 new providers: CRS Gemini Ultra (Antigravity), Kimi/Moonshot OAI
- Restructure main menu: LLM only / platform only / or both with cascade prompts
- Add Python 3.14 compatibility warning and reconfiguration detection
- Fix welcome_message: WeCom only, correct variable name
- Show GETTING_STARTED example commands after configuration
- Add advanced LLM options: proxy, context_win, stream, user_agent
@lsdefine
lsdefine merged commit e1c128e into lsdefine:main May 8, 2026
@windcat2333
windcat2333 deleted the feature/setup-wizard branch May 8, 2026 09:44
FeiNiaoBF pushed a commit to FeiNiaoBF/GenericAgent that referenced this pull request May 8, 2026
)

* feat: add setup.py -- interactive initialization wizard

* fix: address PR lsdefine#295 review — rename to configure.py, improve all feedback

- Rename setup.py → configure.py to avoid pip/setuptools conflict
- Fix lark exception: catch generic Exception instead of non-existent AppAccessDeniedError/AppExpiredError
- Add proxy support to probe_models via HTTPS_PROXY/HTTP_PROXY env vars
- Implement masked_input() with real-time API key masking
- Add pip install hints for messaging platform dependencies
- Add 2 new providers: CRS Gemini Ultra (Antigravity), Kimi/Moonshot OAI
- Restructure main menu: LLM only / platform only / or both with cascade prompts
- Add Python 3.14 compatibility warning and reconfiguration detection
- Fix welcome_message: WeCom only, correct variable name
- Show GETTING_STARTED example commands after configuration
- Add advanced LLM options: proxy, context_win, stream, user_agent

---------

Co-authored-by: guowenjiao54 <guowenjiao54@users.noreply.github.com>
FeiNiaoBF pushed a commit to FeiNiaoBF/GenericAgent that referenced this pull request May 11, 2026
)

* feat: add setup.py -- interactive initialization wizard

* fix: address PR lsdefine#295 review — rename to configure.py, improve all feedback

- Rename setup.py → configure.py to avoid pip/setuptools conflict
- Fix lark exception: catch generic Exception instead of non-existent AppAccessDeniedError/AppExpiredError
- Add proxy support to probe_models via HTTPS_PROXY/HTTP_PROXY env vars
- Implement masked_input() with real-time API key masking
- Add pip install hints for messaging platform dependencies
- Add 2 new providers: CRS Gemini Ultra (Antigravity), Kimi/Moonshot OAI
- Restructure main menu: LLM only / platform only / or both with cascade prompts
- Add Python 3.14 compatibility warning and reconfiguration detection
- Fix welcome_message: WeCom only, correct variable name
- Show GETTING_STARTED example commands after configuration
- Add advanced LLM options: proxy, context_win, stream, user_agent

---------

Co-authored-by: guowenjiao54 <guowenjiao54@users.noreply.github.com>
bendusy pushed a commit to bendusy/GenericAgent that referenced this pull request May 14, 2026
)

* feat: add setup.py -- interactive initialization wizard

* fix: address PR lsdefine#295 review — rename to configure.py, improve all feedback

- Rename setup.py → configure.py to avoid pip/setuptools conflict
- Fix lark exception: catch generic Exception instead of non-existent AppAccessDeniedError/AppExpiredError
- Add proxy support to probe_models via HTTPS_PROXY/HTTP_PROXY env vars
- Implement masked_input() with real-time API key masking
- Add pip install hints for messaging platform dependencies
- Add 2 new providers: CRS Gemini Ultra (Antigravity), Kimi/Moonshot OAI
- Restructure main menu: LLM only / platform only / or both with cascade prompts
- Add Python 3.14 compatibility warning and reconfiguration detection
- Fix welcome_message: WeCom only, correct variable name
- Show GETTING_STARTED example commands after configuration
- Add advanced LLM options: proxy, context_win, stream, user_agent

---------

Co-authored-by: guowenjiao54 <guowenjiao54@users.noreply.github.com>
RocketLi pushed a commit to RocketLi/GenericAgent that referenced this pull request May 18, 2026
)

* feat: add setup.py -- interactive initialization wizard

* fix: address PR lsdefine#295 review — rename to configure.py, improve all feedback

- Rename setup.py → configure.py to avoid pip/setuptools conflict
- Fix lark exception: catch generic Exception instead of non-existent AppAccessDeniedError/AppExpiredError
- Add proxy support to probe_models via HTTPS_PROXY/HTTP_PROXY env vars
- Implement masked_input() with real-time API key masking
- Add pip install hints for messaging platform dependencies
- Add 2 new providers: CRS Gemini Ultra (Antigravity), Kimi/Moonshot OAI
- Restructure main menu: LLM only / platform only / or both with cascade prompts
- Add Python 3.14 compatibility warning and reconfiguration detection
- Fix welcome_message: WeCom only, correct variable name
- Show GETTING_STARTED example commands after configuration
- Add advanced LLM options: proxy, context_win, stream, user_agent

---------

Co-authored-by: guowenjiao54 <guowenjiao54@users.noreply.github.com>
lsdefine pushed a commit that referenced this pull request Jul 23, 2026
* feat: add setup.py -- interactive initialization wizard

* fix: address PR #295 review — rename to configure.py, improve all feedback

- Rename setup.py → configure.py to avoid pip/setuptools conflict
- Fix lark exception: catch generic Exception instead of non-existent AppAccessDeniedError/AppExpiredError
- Add proxy support to probe_models via HTTPS_PROXY/HTTP_PROXY env vars
- Implement masked_input() with real-time API key masking
- Add pip install hints for messaging platform dependencies
- Add 2 new providers: CRS Gemini Ultra (Antigravity), Kimi/Moonshot OAI
- Restructure main menu: LLM only / platform only / or both with cascade prompts
- Add Python 3.14 compatibility warning and reconfiguration detection
- Fix welcome_message: WeCom only, correct variable name
- Show GETTING_STARTED example commands after configuration
- Add advanced LLM options: proxy, context_win, stream, user_agent

---------

Co-authored-by: guowenjiao54 <guowenjiao54@users.noreply.github.com>
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.

2 participants