Provider 模型目录、动态发现与内建 Provider 固化 PR 总结#123
Closed
phantom5099 wants to merge 7 commits into1024XEngineer:mainfrom
Closed
Provider 模型目录、动态发现与内建 Provider 固化 PR 总结#123phantom5099 wants to merge 7 commits into1024XEngineer:mainfrom
phantom5099 wants to merge 7 commits into1024XEngineer:mainfrom
Conversation
# Conflicts: # internal/runtime/runtime.go
# Conflicts: # internal/runtime/runtime.go
# Conflicts: # README.md
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更说明
本轮改动围绕
provider与config两个域完成了模型目录、动态发现、模型缓存和配置持久化的收口,目标是把“模型列表获取、模型元数据归一化、模型缓存、模型来源合并、当前 provider/model 的规范化”统一落到当前主链路内:TUI -> Runtime -> Provider Service/Registry -> Driver当前实现已经明确以下产品约束:
openai、gemini、openll、qiniuconfig.yaml只持久化selected_provider、current_model、workdir、shell和工具配置/models动态发现 + 本地缓存”共同组成本次实现坚持以下边界:
runtime、tui对外调用方式,ListModels()仍返回[]ModelDescriptorruntime、tui或config当前模型元数据固定为:
IDNameDescriptionContextWindowMaxOutputTokensCapabilities其中
Capabilities采用map[string]bool表达能力开关,适用于当前“只关心某能力是否支持”的场景。主要改动
1. 模型元数据结构收敛
internal/provider/types.go中的ModelDescriptorID、Name、Description、ContextWindow、MaxOutputTokens、Capabilities2. 动态模型发现下沉到 driver
internal/provider/registry.go对应的 driver 定义中接入可选 discovery 能力GET /models拉取服务端模型列表driver只负责协议差异与响应归一化,service只负责编排、缓存和合并3. 引入模型目录 JSON 缓存
ModelCatalogStore抽象~/.neocode/cache/models/driver + normalized base_url计算,不按 provider 名称计算4. 模型来源合并策略重构
provider.Service不再只依赖静态模型列表Model5. 调整 config / provider 职责边界
ApplyDefaultsFrom()始终以代码内建 provider 快照作为Providers的唯一来源current_model的合法性校正统一由provider.Service基于“当前 provider 的合并模型列表”处理provider域处理config只负责选择状态、默认值、校验和 YAML 持久化6. 配置持久化与启动校正
provider.Service校正当前模型选择selected_provider或current_model被自动修正时,会立即写回config.yamlproviders、provider_overrides、workspace_root、max_loop等字段不会再进入运行时配置,并会在后续保存时自然被清理7. 内建 provider 的唯一性校验
driver + normalized base_url全局唯一预期收益
provider层职责更清晰,模型发现属于协议能力,缓存、合并和模型选择校正属于服务编排,不再和config混杂runtime、tui接口的前提下,为后续基于上下文窗口、能力标记的策略扩展预留了数据基础