Repository navigation
feat!: Chat Completions 推理回传字段可配置,sdk.Model 补充模型元数据 - #116
Merged
Merged
Conversation
sheepbox8646
force-pushed
the
feat/twi-7-reasoning-replay-catalog
branch
from
October 13, 2026 05:17
3fe87c4 to
9c259d4
Compare
sheepbox8646
force-pushed
the
feat/twi-7-reasoning-replay-catalog
branch
from
October 13, 2026 07:29
bd7a79a to
5cef5ae
Compare
sheepbox8646
force-pushed
the
feat/twi-7-reasoning-replay-catalog
branch
from
October 13, 2026 07:37
5cef5ae to
787b3c9
Compare
- 新增 completions.WithReasoningReplay(sdk.ReasoningReplay):回传字段可选
reasoning_content(默认)、reasoning_details、reasoning;Required 为真时每条
带工具调用的助手消息都补上空的文本字段;默认沿用原通用路径
- reasoning_details 通用保存到 openai-chat 命名空间并原样回传,仍可读取旧的
minimax 命名空间;流式按 index 合并,只带加密内容的条目不再丢失
- sdk.Model 补充描述、模态、上下文窗口、最大输出、工具调用、结构化输出与
推理能力 ModelReasoning(Toggle、Efforts、Budget、Off、Dialect、Default、
Replay)
- 文档:回传说明、兼容选项、API 参考
BREAKING CHANGE: WithDeepSeekChatCompletionsCompat、WithKimiChatCompletionsCompat
不再隐含补空 reasoning_content,需加 WithReasoningReplay(sdk.ReasoningReplay{Required: true});
WithMiniMaxChatCompletionsCompat 不再自动回传 reasoning_details,需加
WithReasoningReplay(sdk.ReasoningReplay{Field: sdk.ReasoningReplayDetails})。
Linear: TWI-7
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sheepbox8646
force-pushed
the
feat/twi-7-reasoning-replay-catalog
branch
from
October 13, 2026 07:43
787b3c9 to
ff5eef7
Compare
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.
概要
1. Chat Completions 推理回传字段可配置
新增
WithReasoningReplay(sdk.ReasoningReplay{Field, Required}):Fieldsdk.ReasoningReplayContent(默认)reasoning_contentsdk.ReasoningReplayDetailsreasoning_details数组原样回传sdk.ReasoningReplayReasoningreasoningreasoning的网关reasoning_content,只有对话里已经出现过这个字段时,才给没有推理的工具调用消息补空串,与原来通用路径的行为一致。Required: true:每条带工具调用的助手消息都补上空的文本字段,满足 DeepSeek 和 Kimi 思考模式的校验。reasoning_details是数组,不做补齐。reasoning_details通用保存:详情改存到openai-chat命名空间,回传时原样发回,保留签名、加密内容和index。旧的minimax命名空间仍能读取,Memoh 已保存的历史不受影响。index合并,文本和摘要拼接,签名等字段由带值的片段写入。以前只带加密内容、没有文本的条目会被丢掉,现在会保留。reasoning.summary条目也能显示为推理文本。2.
sdk.Model补充模型元数据sdk.Model原来只有 ID、显示名、Provider 和类型。现在补充以下可选字段,零值表示未声明,现有的构造代码不受影响:Accepts、Produces)、上下文窗口、最大输出、工具调用、结构化输出。Reasoning *ModelReasoning,与 Memoh 的模型配置和新的推理字段设计对齐:Toggle(独立开关)、Efforts(只列开启推理的档位)、Budget(预算范围)、Off(accepted、low_effort_only、rejected)。Dialect:tier、budget、toggle、adaptive。adaptive 对应 Memohthinking_mode里区分自适应思考的那部分含义。Default:不发推理参数时模型是否思考、用哪一档或多少预算,取代单独的默认开启标记。Replay:Chat Completions 回传字段与是否必须。sdk.ReasoningReplay,completions.WithReasoningReplay直接接收它,模型上的Reasoning.Replay可以原样传入。Model的定义已同步更新,并去掉了早已不存在的MaxTokens字段。models.dev 的解析不放在 twilight,是否接入、如何接入由 Memoh 侧决定。
去掉
sdk.ModelType的改动已拆到 #117 并已合并,本 PR 已变基到合并后的 main,sdk.Model不再有Type字段。模型元数据不包含费用,本 PR 也不再改动EmbeddingModel。破坏性变更与迁移
兼容选项不再隐含回传行为,需要显式设置:
兼容选项里与回传无关的行为保留不变,包括 DeepSeek 和 MiniMax 的思考开关映射、MiniMax 的
reasoning_split、Kimi 的工具 schema 改写。Memoh 升级本版本时需要按服务商补上这两行配置,或在sdk.Model.Reasoning.Replay里声明后原样传入。关联
验证
Required补齐与不补齐;reasoning_details原样往返,新旧两个命名空间都覆盖;默认配置只发reasoning_content;未知字段在发送前报错;流式按index合并带签名和加密条目的详情;ModelReasoning的Controllable、CanTurnOff与Model的Accepts、Produces。原有用例按新的显式配置更新,并新增「只开 DeepSeek 兼容选项不再补齐」的用例,把破坏性变更固定下来。z-ai/glm-4.7配sdk.ReasoningReplayDetails:流式拿到推理和工具调用,推理详情合并为一条完整条目。第二步请求的助手消息只带reasoning_details和tool_calls,接口正常返回最终答案。deepseek/deepseek-v4-flash配reasoning_content加Required:第二步请求只带reasoning_content,接口正常返回最终答案。go build ./...、go vet ./...、go vet -tags integration ./...、golangci-lint run ./...(0 issues)、go test ./... -short -race、internal/sdkdiff测试、go mod tidy无变化。🤖 Generated with Claude Code