docs(comments): 注释中文化 · internal/runtime/model + internal/services/backthink(54 文件,纯替换)
- 只翻注释/文档字符串:`go/scanner` 剥注释后按 token 序列+literal 逐 token 比对,**54/54 文件 SAME**;
改动文件总行数与 HEAD 漂移 = 0(严格 1:1,无合并/拆行)
- 裁决编号与 design 节号逐字保留(03.4.1/03.4.2/03.4.3/14.4.1/14.4.5/07.4.2-4、design/04 §3.1/§3.2 等);
`chat_template_kwargs` / `enable_thinking` / `reasoning_effort` / `thinking:{type}` 字段名与形状说明未动
- 存疑译法(已登记):`persona` 在叙事语境用「角色」、标识符语境保留 `persona`(仓库既有模块本身混用);
`rung`→「级」;`provider` 存在「提供商/提供者」两种落笔(可按需一键统一)
- 复核:build/vet 绿 + 两包测试绿;gofmt 干净;残留英文注释 0 条
- 既有存量(未修,只报告):`model/anthropic_test.go` 612 行 >500;`applyAnthropicEvent` 115 行 >80
This commit is contained in:
1 parent
f5cf117482
commit
3dc1232bc2
54 files changed
+1923
-1923
No files matched your search
@@ -14,7 +14,7 @@ import (
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/internal/config"
|
||||
)
|
||||
|
||||
// anthropicCaptured records what an AnthropicChatAdapter sent to a stub server.
|
||||
// anthropicCaptured 记录 AnthropicChatAdapter 发往 stub 服务器的内容。
|
||||
type anthropicCaptured struct {
|
||||
method string
|
||||
path string
|
||||
@@ -510,8 +510,8 @@ func TestAnthropicChat_ToolResult(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// anthropicBlockContent asserts a message renders a single Anthropic content block
|
||||
// and returns it as a map for inspection.
|
||||
// anthropicBlockContent 断言一条消息渲染出单个 Anthropic 内容块,
|
||||
// 并把它作为 map 返回以供检查。
|
||||
func anthropicBlockContent(t *testing.T, msg anthropicMessage) (map[string]any, bool) {
|
||||
t.Helper()
|
||||
blocks, ok := msg.Content.([]any)
|
||||
@@ -540,7 +540,7 @@ func TestAnthropicChat_Build_ToolResultBlock(t *testing.T) {
|
||||
t.Fatalf("messages = %d, want 3", len(out))
|
||||
}
|
||||
|
||||
// The assistant turn must carry the native tool_use block, not plain text.
|
||||
// 助手回合必须携带原生 tool_use 块,而不是纯文本。
|
||||
if out[1].Role != "assistant" {
|
||||
t.Errorf("assistant role = %q, want assistant", out[1].Role)
|
||||
}
|
||||
@@ -555,8 +555,8 @@ func TestAnthropicChat_Build_ToolResultBlock(t *testing.T) {
|
||||
t.Errorf("tool_use input = %#v, want {city:Paris}", use["input"])
|
||||
}
|
||||
|
||||
// The tool-result turn must be a user turn with a native tool_result block
|
||||
// (the audit's core fix: never a user plain-text turn).
|
||||
// 工具结果回合必须是带原生 tool_result 块的 user
|
||||
// 回合(审计的核心修复:绝不是 user 纯文本回合)。
|
||||
if out[2].Role != "user" {
|
||||
t.Errorf("tool-result role = %q, want user", out[2].Role)
|
||||
}
|
||||
@@ -580,9 +580,9 @@ func TestAnthropicChat_Build_ToolResultBlock(t *testing.T) {
|
||||
|
||||
func TestAnthropicChat_Build_ToolResultLegacyText(t *testing.T) {
|
||||
t.Parallel()
|
||||
// The loop's current form: a RoleTool message carrying a plain text part and
|
||||
// Message.ToolCallID. The protocol layer must still render a native tool_result
|
||||
// block (not a user plain-text turn).
|
||||
// loop 当前的形态:一个携带纯文本片段与
|
||||
// Message.ToolCallID 的 RoleTool 消息。协议层仍必须渲染原生
|
||||
// tool_result 块(而不是 user 纯文本回合)。
|
||||
m := Message{Role: RoleTool, ToolCallID: "toolu_9",
|
||||
Content: []Content{{Type: ContentTypeText, Text: "tool weather result: 22"}}}
|
||||
_, out, err := buildAnthropicMessages([]Message{m})
|
||||
|
||||
Reference in new issue
Block a user