Skip to content

feat(models): add provider model scanning#2106

Open
sheetung wants to merge 1 commit intolangbot-app:masterfrom
sheetung:feat/provider-model-scanning
Open

feat(models): add provider model scanning#2106
sheetung wants to merge 1 commit intolangbot-app:masterfrom
sheetung:feat/provider-model-scanning

Conversation

@sheetung
Copy link
Copy Markdown
Contributor

@sheetung sheetung commented Apr 3, 2026

概述 / Overview

请在此部分填写你实现/解决/优化的内容:
Summary of what you implemented/solved/optimized:

更改前后对比截图 / Screenshots

请在此部分粘贴更改前后对比截图(可以是界面截图、控制台输出、对话截图等):
Please paste the screenshots of changes before and after here (can be interface screenshots, console output, conversation screenshots, etc.):

修改前 / Before:

修改后 / After:

检查清单 / Checklist

PR 作者完成 / For PR author

请在方括号间写x以打勾 / Please tick the box with x

  • 阅读仓库贡献指引了吗? / Have you read the contribution guide?
  • 与项目所有者沟通过了吗? / Have you communicated with the project maintainer?
  • 我确定已自行测试所作的更改,确保功能符合预期。 / I have tested the changes and ensured they work as expected.

项目维护者完成 / For project maintainer

  • 相关 issues 链接了吗? / Have you linked the related issues?
  • 配置项写好了吗?迁移写好了吗?生效了吗? / Have you written the configuration items? Have you written the migration? Has it taken effect?
  • 依赖加到 pyproject.toml 和 core/bootutils/deps.py 了吗 / Have you added the dependencies to pyproject.toml and core/bootutils/deps.py?
  • 文档编写了吗? / Have you written the documentation?

改动重点:

  • 前端新增“扫描添加”模式

    • 在模型配置里,供应商下的“添加模型”支持手动添加和扫描添加两种方式
    • 扫描结果支持搜索、勾选、批量添加
    • 扫描列表保持简洁展示,不再展示调试面板和额外富信息
  • 后端新增 provider 扫描接口

    • 提供按供应商扫描可用模型的接口
    • 会过滤当前类型(llm / embedding
    • 会标记哪些模型已经添加过
  • 扫描逻辑改为 requester 自适配

    • 不再引入或保留 scan_url 配置
    • 每个 requester 自己决定怎么扫描模型
    • 通用 OpenAI 兼容供应商走 base_url + /models
    • 特殊 requester 单独覆写 scan_models()
  • 已补 requester 级扫描适配

    • OpenAI 兼容通用扫描
    • OpenRouter
    • Gemini
    • Ollama
    • Bailian 已回退为走兼容 OpenAI 扫描链路
  • 能力推断

    • 扫描时会根据返回字段或模型名,推断:
      • vision
      • func_call
    • 这些能力会在勾选添加时自动带入

为什么这样改

  • 尽量不改 LangBot 主要逻辑
  • 不新增前端复杂配置项
  • 扫描策略集中在 requester 内部,更符合不同厂商接口差异
  • 对 OpenAI 兼容供应商保持最简单的心智模型

如何适配新的模型供应商
如果后续要给某个 requester 增加扫描模型能力,建议按下面方式接入:

  1. 优先确认厂商官方“模型列表接口”
  • 不要猜接口
  • 明确请求方法、URL、鉴权方式、返回结构
  1. 在对应 requester 里实现或复用 scan_models(api_key)
  • 返回统一结构:
{
    "models": [
        {
            "id": "...",
            "name": "...",
            "type": "llm" or "embedding",
            "abilities": ["vision", "func_call"],
        }
    ]
}
  1. 如果是 OpenAI 兼容供应商
  • 通常直接复用通用实现即可
  • 通用逻辑位置:
  1. 如果是特殊厂商
  • 在对应 requester 中单独覆写 scan_models()
  • 例如:
    • Gemini 走官方 models 列表接口
    • Ollama 走 /api/tags
  1. 保持最小适配原则
  • 先保证“能扫出模型”
  • 再补 type
  • 最后补 abilities
  • 不要为了统一 UI 伪造不存在的字段

@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. eh: Feature enhance: 新功能添加 / add new features m: Provider LLM 模型相关 / LLMs management pd: Need testing pending: 待测试的PR / PR waiting to be tested labels Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

eh: Feature enhance: 新功能添加 / add new features m: Provider LLM 模型相关 / LLMs management pd: Need testing pending: 待测试的PR / PR waiting to be tested size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant