Repository navigation
refactor!: 移除 sdk.ModelType,EmbeddingModel 补充元数据 - #117
Merged
Merged
Conversation
- 删除 sdk.ModelType 与 Model.Type,sdk.Model 只表示对话模型 - EmbeddingModel 补充显示名、描述、默认维度、输入上限,调用方式不变 - Google 对话 ListModels 不再混入 embedding 模型;Google embedding provider 新增 ListModels 列出支持 embedContent 的模型 - 文档同步,并去掉 Model 文档里早已不存在的 MaxTokens 字段 BREAKING CHANGE: sdk.ModelType 与 Model.Type 已删除。按 Type 区分 embedding 模型的代码,改为调用 provider/google/embedding 的 ListModels。 Linear: TWI-8 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.<
2E11
/span>Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
去掉
sdk.ModelType,让对话模型和 embedding 模型各自用自己的类型表示:sdk.ModelType与Model.Type。ModelType原来只有 chat、embedding 两个值,唯一的用途是让 Google 对话 provider 的ListModels混着返回 embedding 模型并打标。现在sdk.Model只表示对话模型。EmbeddingModel补充元数据:显示名、描述、默认维度、输入上限,与MaxEmbeddingsPerCall一样都是可选字段,零值表示未声明。调用方式不变,仍是sdk.Embed、sdk.EmbedMany、Client.Embed、Client.EmbedMany加WithEmbeddingModel,与语音、转写、图片、视频一致。ListModels不再包含只支持embedContent的模型。Google embedding provider 新增ListModels,列出支持embedContent的模型,并填上显示名、描述和输入上限,原有的列举能力不丢。sdk.Model时去掉Type字段;文档同步更新,并去掉Model文档里早已不存在的MaxTokens字段。本 PR 从 #116 拆出,两者都从 main 分出、互不依赖。
sdk/model.go和文档里有相邻改动,后合并的一个需要变基。破坏性变更与迁移
sdk.ModelType、sdk.ModelTypeChat、sdk.ModelTypeEmbedding与Model.Type已删除:sdk.Model时去掉Type字段。ListModels里Type == embedding找 embedding 模型的代码,改为调用provider/google/embedding的ListModels。Memoh 需要迁移的是
internal/providers/service.go中按sdk.ModelType区分模型的逻辑,以及internal/models/opencode_go.go构造模型时的Type字段。embedding 调用代码不受影响。关联
验证
ListModels不再包含 embedding 模型;Google embeddingListModels只返回支持embedContent的模型,填上显示名、描述、输入上限和单次条数,并绑定到该 provider。embedding 调用代码与原有测试未改动。go build ./...、go vet ./...、go vet -tags integration ./...、golangci-lint run ./...(0 issues)、go test ./... -short -race、internal/sdkdiff测试、go mod tidy无变化。ListModels只用模拟服务验证。🤖 Generated with Claude Code