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
@@ -13,10 +13,10 @@ import (
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/internal/config"
|
||||
)
|
||||
|
||||
// recordingServer is an OpenAI-compatible /chat/completions endpoint that records
|
||||
// the model name of every request and either fails or succeeds. It backs the
|
||||
// local-rung tests (裁决 03.4.3): the point of the rung is that a request reaches
|
||||
// the local endpoint with the local model name, and never when the rung is off.
|
||||
// recordingServer 是一个 OpenAI 兼容的 /chat/completions 端点,记录
|
||||
// 每个请求的模型名,并或失败或成功。它支撑
|
||||
// 本地级测试(裁决 03.4.3):该级的意义在于请求以本地模型名
|
||||
// 到达本地端点,而该级关闭时绝不如此。
|
||||
type recordingServer struct {
|
||||
mu sync.Mutex
|
||||
models []string
|
||||
@@ -51,9 +51,9 @@ func newRecordingServer(t *testing.T, fail bool) (*httptest.Server, *recordingSe
|
||||
return srv, rec
|
||||
}
|
||||
|
||||
// TestNewChatChainWithLog_LocalRungAppended verifies the third degradation level
|
||||
// (primary → fallback → local) only joins the chain when it is enabled AND fully
|
||||
// configured.
|
||||
// TestNewChatChainWithLog_LocalRungAppended 验证第三级降级
|
||||
// (primary → fallback → local)只在启用且完全
|
||||
// 配置好时才加入链。
|
||||
func TestNewChatChainWithLog_LocalRungAppended(t *testing.T) {
|
||||
t.Parallel()
|
||||
cases := []struct {
|
||||
@@ -88,9 +88,9 @@ func TestNewChatChainWithLog_LocalRungAppended(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestChain_Chat_LocalRungServesAfterFallback verifies the local rung really takes
|
||||
// over the request after the primary and fallback steps fail, with the local model
|
||||
// name on the wire and the local endpoint's own base URL/API key (not the group's).
|
||||
// TestChain_Chat_LocalRungServesAfterFallback 验证本地级在主
|
||||
// 步骤与降级步骤都失败后真的接管请求,且线上用
|
||||
// 本地模型名与本地端点自己的 base URL/API key(而非组的)。
|
||||
func TestChain_Chat_LocalRungServesAfterFallback(t *testing.T) {
|
||||
t.Parallel()
|
||||
mainSrv, _ := newRecordingServer(t, true)
|
||||
@@ -117,9 +117,9 @@ func TestChain_Chat_LocalRungServesAfterFallback(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestChain_Chat_LocalRungOffNeverCalled pins the default-off red line: with the
|
||||
// rung disabled the local endpoint must never be touched, even when every other
|
||||
// step fails.
|
||||
// TestChain_Chat_LocalRungOffNeverCalled 钉住默认关闭的红线:该级
|
||||
// 禁用时绝不能触碰本地端点,即便其它所有
|
||||
// 步骤都失败。
|
||||
func TestChain_Chat_LocalRungOffNeverCalled(t *testing.T) {
|
||||
t.Parallel()
|
||||
mainSrv, _ := newRecordingServer(t, true)
|
||||
@@ -141,14 +141,14 @@ func TestChain_Chat_LocalRungOffNeverCalled(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestChain_Chat_PrimaryStepKeepsRoutedModel pins that the chain does not discard
|
||||
// the router's decision: the primary step sends the request's routed model, and
|
||||
// the fallback step still pins its own configured model (裁决 03.4.1).
|
||||
// TestChain_Chat_PrimaryStepKeepsRoutedModel 钉住链不会丢弃
|
||||
// 路由器的决策:主步骤发送请求中被路由的模型,而
|
||||
// 降级步骤仍钉住自己配置的模型(裁决 03.4.1)。
|
||||
func TestChain_Chat_PrimaryStepKeepsRoutedModel(t *testing.T) {
|
||||
t.Parallel()
|
||||
// One endpoint serves both steps (the factory builds every step against the
|
||||
// group's base URL): it fails for anything but the fallback model, so the
|
||||
// recorded model names show which model each step actually sent.
|
||||
// 一个端点同时服务两个步骤(工厂让每一步都针对
|
||||
// 组的 base URL 构建):除降级模型外它都失败,所以
|
||||
// 记录下来的模型名显示了每一步实际发送了哪个模型。
|
||||
rec := &recordingServer{}
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
var body struct {
|
||||
|
||||
Reference in new issue
Block a user