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
@@ -9,10 +9,10 @@ import (
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/internal/config"
|
||||
)
|
||||
|
||||
// TestDeepSeekAnthropicEndpoint_Classification pins the endpoint detection: a
|
||||
// DeepSeek /anthropic URL must be recognized even when the configured model name
|
||||
// is not a DeepSeek one (the service silently maps unknown names onto
|
||||
// deepseek-flash, so the name is not a reliable signal there).
|
||||
// TestDeepSeekAnthropicEndpoint_Classification 钉住端点检测:
|
||||
// 即便配置的模型名不是 DeepSeek 的,也必须认出
|
||||
// DeepSeek /anthropic URL(该服务会把未知名称静默映射到
|
||||
// deepseek-flash,所以那里模型名不是可靠信号)。
|
||||
func TestDeepSeekAnthropicEndpoint_Classification(t *testing.T) {
|
||||
t.Parallel()
|
||||
cases := []struct {
|
||||
@@ -33,18 +33,18 @@ func TestDeepSeekAnthropicEndpoint_Classification(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// newDeepSeekAnthropicAdapter builds an Anthropic-protocol adapter whose model
|
||||
// name identifies DeepSeek, so the DeepSeek /anthropic branch is exercised while
|
||||
// the request still goes to a local stub.
|
||||
// newDeepSeekAnthropicAdapter 构建一个 Anthropic 协议适配器,其模型
|
||||
// 名标识 DeepSeek,从而走到 DeepSeek /anthropic 分支,
|
||||
// 同时请求仍发往本地 stub。
|
||||
func newDeepSeekAnthropicAdapter(t *testing.T, ch chan<- anthropicCaptured, opts ...AnthropicOption) *AnthropicChatAdapter {
|
||||
t.Helper()
|
||||
srv := newAnthropicServer(t, http.StatusOK, "application/json", anthropicTextResponse, ch)
|
||||
return NewAnthropicChat(config.LLMConfig{AnthropicBaseURL: srv.URL, AnthropicModel: deepSeekModel}, opts...)
|
||||
}
|
||||
|
||||
// TestAnthropicDeepSeek_BudgetDoesNotRaiseMaxTokens asserts the max_tokens raise
|
||||
// stays on the Anthropic endpoint: DeepSeek's /anthropic ignores budget_tokens, so
|
||||
// raising the limit there would misreport the budget the provider applies.
|
||||
// TestAnthropicDeepSeek_BudgetDoesNotRaiseMaxTokens 断言抬高 max_tokens
|
||||
// 只留在 Anthropic 端点:DeepSeek 的 /anthropic 忽略 budget_tokens,所以在
|
||||
// 那里抬高限额会错误反映提供商采用的预算。
|
||||
func TestAnthropicDeepSeek_BudgetDoesNotRaiseMaxTokens(t *testing.T) {
|
||||
t.Parallel()
|
||||
ch := make(chan anthropicCaptured, 1)
|
||||
@@ -79,9 +79,9 @@ func TestAnthropicDeepSeek_BudgetDoesNotRaiseMaxTokens(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestAnthropicOfficial_BudgetStillRaisesMaxTokens is the counterpart guard: on
|
||||
// the Anthropic endpoint the design red line ("budget must not eat the answer")
|
||||
// still holds.
|
||||
// TestAnthropicOfficial_BudgetStillRaisesMaxTokens 是对位守护:在
|
||||
// Anthropic 端点上,设计红线(「预算不得吃光答案」)
|
||||
// 依然成立。
|
||||
func TestAnthropicOfficial_BudgetStillRaisesMaxTokens(t *testing.T) {
|
||||
t.Parallel()
|
||||
ch := make(chan anthropicCaptured, 1)
|
||||
@@ -110,9 +110,9 @@ func TestAnthropicOfficial_BudgetStillRaisesMaxTokens(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestAnthropicDeepSeek_OutputConfigEffort asserts the DeepSeek /anthropic
|
||||
// strength path exists: the effort becomes output_config.effort, and the aliases
|
||||
// are normalized to the tiers the service applies.
|
||||
// TestAnthropicDeepSeek_OutputConfigEffort 断言 DeepSeek /anthropic 的
|
||||
// 强度路径存在:effort 变成 output_config.effort,别名
|
||||
// 被归一化为服务采用的档位。
|
||||
func TestAnthropicDeepSeek_OutputConfigEffort(t *testing.T) {
|
||||
t.Parallel()
|
||||
cases := []struct{ sent, want string }{
|
||||
@@ -148,8 +148,8 @@ func TestAnthropicDeepSeek_OutputConfigEffort(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestAnthropicDeepSeek_OutputConfigEffortInvalidDropped asserts an unrecognized
|
||||
// effort is dropped and reported rather than approximated.
|
||||
// TestAnthropicDeepSeek_OutputConfigEffortInvalidDropped 断言无法识别的
|
||||
// effort 会被丢弃并上报,而不是做近似处理。
|
||||
func TestAnthropicDeepSeek_OutputConfigEffortInvalidDropped(t *testing.T) {
|
||||
t.Parallel()
|
||||
ch := make(chan anthropicCaptured, 1)
|
||||
@@ -178,10 +178,10 @@ func TestAnthropicDeepSeek_OutputConfigEffortInvalidDropped(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestAnthropicDeepSeek_EffortNoneDisablesThinking pins the translation of the
|
||||
// one effort value output_config cannot carry: DeepSeek's Anthropic format has no
|
||||
// effort "none", so the off intent goes through the thinking switch — mapping it
|
||||
// onto a tier would turn thinking off into thinking on.
|
||||
// TestAnthropicDeepSeek_EffortNoneDisablesThinking 钉住 output_config
|
||||
// 无法承载的那一个 effort 取值的翻译:DeepSeek 的 Anthropic 格式
|
||||
// 没有 "none" 档,所以关闭意图经 thinking 开关转达——把它映射
|
||||
// 到某个档位会把「关闭思考」变成「开启思考」。
|
||||
func TestAnthropicDeepSeek_EffortNoneDisablesThinking(t *testing.T) {
|
||||
t.Parallel()
|
||||
ch := make(chan anthropicCaptured, 1)
|
||||
@@ -208,9 +208,9 @@ func TestAnthropicDeepSeek_EffortNoneDisablesThinking(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestAnthropicDeepSeek_ThinkingSwitch asserts an explicit switch is carried as
|
||||
// the Anthropic-format thinking block, and that a disabled one omits the budget
|
||||
// (DeepSeek ignores it anyway).
|
||||
// TestAnthropicDeepSeek_ThinkingSwitch 断言显式开关以
|
||||
// Anthropic 格式的 thinking 块携带,且 disabled 时不带预算
|
||||
// (反正 DeepSeek 会忽略它)。
|
||||
func TestAnthropicDeepSeek_ThinkingSwitch(t *testing.T) {
|
||||
t.Parallel()
|
||||
cases := []struct {
|
||||
@@ -253,8 +253,8 @@ func TestAnthropicDeepSeek_ThinkingSwitch(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestAnthropicDeepSeek_EffortDroppedWhenThinkingDisabled keeps the "off wins"
|
||||
// rule on the Anthropic path too: output_config.effort must not re-open thinking.
|
||||
// TestAnthropicDeepSeek_EffortDroppedWhenThinkingDisabled 在 Anthropic 路径
|
||||
// 上也守住「关闭优先」规则:output_config.effort 不得重新打开思考。
|
||||
func TestAnthropicDeepSeek_EffortDroppedWhenThinkingDisabled(t *testing.T) {
|
||||
t.Parallel()
|
||||
ch := make(chan anthropicCaptured, 1)
|
||||
@@ -281,9 +281,9 @@ func TestAnthropicDeepSeek_EffortDroppedWhenThinkingDisabled(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestAnthropicOfficial_ReasoningEffortReportedIgnored asserts a reasoning_effort
|
||||
// aimed at the Anthropic endpoint is reported instead of silently disappearing —
|
||||
// the Messages protocol has no such field.
|
||||
// TestAnthropicOfficial_ReasoningEffortReportedIgnored 断言落在
|
||||
// Anthropic 端点上的 reasoning_effort 会被上报,而不是静默消失——
|
||||
// Messages 协议没有这个字段。
|
||||
func TestAnthropicOfficial_ReasoningEffortReportedIgnored(t *testing.T) {
|
||||
t.Parallel()
|
||||
ch := make(chan anthropicCaptured, 1)
|
||||
@@ -313,9 +313,9 @@ func TestAnthropicOfficial_ReasoningEffortReportedIgnored(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestAnthropicDeepSeek_ForcedToolChoiceWithThinkingWarns covers the DeepSeek 400
|
||||
// trap on the Anthropic path: the adapter warns and still sends the directive —
|
||||
// it never closes thinking on its own.
|
||||
// TestAnthropicDeepSeek_ForcedToolChoiceWithThinkingWarns 覆盖 Anthropic 路径
|
||||
// 上的 DeepSeek 400 陷阱:适配器会警告但仍发送该指令——
|
||||
// 它绝不自行关闭思考。
|
||||
func TestAnthropicDeepSeek_ForcedToolChoiceWithThinkingWarns(t *testing.T) {
|
||||
t.Parallel()
|
||||
ch := make(chan anthropicCaptured, 1)
|
||||
|
||||
Reference in new issue
Block a user