feat(search): 智谱 provider 按官方 schema 加固(请求补确证字段 + 错误码分档)
官方文档逐页确证后落地的四件(分册 11 的「官方 schema 确证(2026-10-07)」): - 请求补 search_intent:false(官方标 required,缺发可能触发 1213)与 content_size:medium;count 仅 1–50 透传,越界不发该字段; search_query >70 rune 直接报错且**不发请求**; - 响应按官方收窄:摘要只认 snippet/summary/abstract 候选(官方响应**没有** snippet),publish_date 入 Published; - 错误码分档:1000/1001/1003⇒unauthorized、1113⇒quota_exceeded、 1302/1305⇒rate_limited。🔴 1113 与 1302/1305 **同为 HTTP 429** ⇒ 只看状态码 分不开「该充值」与「该退避」,必须读 error.code(码同时进日志文案); - media/icon/refer 当前一律不投影(Result 没有「来源站点」位;要投影应给 Result 加字段 + 同步契约,不许塞进 Snippet —— 否则摘要位会被站点名恒填满)。 另修两处过期注释(providers_test.go 仍写「只发 search_engine/search_query」)。 验收(主会话复跑 + 亲自变异):go vet 绿;search 包与调用方 io 包全绿; 我用 -overlay 删掉 1113⇒quota_exceeded 映射 ⇒ TestZhipuErrorCodeMapping 变红 (欠费被误报成限流、探针码 rate_limited)。 ⚠️ 候选键容错暂未删除:官方已排除的键保留到**真机实测通过后**再收窄(现无 key)。 ⚠️ 真机未跑:仍只打 httptest,官方真实响应形态未实测。
This commit is contained in:
1 parent
c512609c63
commit
25aa50e532
4 files changed
+452
-16
No files matched your search
@@ -101,7 +101,7 @@ func searxngCase() providerCase {
|
||||
}
|
||||
}
|
||||
|
||||
// zhipuCase 是智谱的夹具(POST + Bearer;请求字段 search_engine/search_query)。
|
||||
// zhipuCase 是智谱的夹具(POST + Bearer;请求字段 search_engine/search_query/search_intent/content_size)。
|
||||
func zhipuCase() providerCase {
|
||||
return providerCase{
|
||||
name: "zhipu", newP: newZhipu,
|
||||
@@ -112,7 +112,8 @@ func zhipuCase() providerCase {
|
||||
wantContent: "智谱正文",
|
||||
checkRequest: func(t *testing.T, c *captured) {
|
||||
t.Helper()
|
||||
// 只发官方文档确证过的字段(search_engine / search_query)。
|
||||
// 只发官方文档确证过的字段:search_engine / search_query / search_intent / content_size,
|
||||
// 外加**条件透传**的 count(仅当 Count 落在官方区间 1–50;本夹具 Query 未给 Count ⇒ 不发)。
|
||||
var body map[string]any
|
||||
mustUnmarshal(t, c.body, &body)
|
||||
if body["search_query"] != "昔涟" {
|
||||
@@ -121,6 +122,12 @@ func zhipuCase() providerCase {
|
||||
if body["search_engine"] != zhipuEngineStd {
|
||||
t.Errorf("zhipu body search_engine = %v, want %s", body["search_engine"], zhipuEngineStd)
|
||||
}
|
||||
if body["search_intent"] != false {
|
||||
t.Errorf("zhipu body search_intent = %v, want false(官方标 required)", body["search_intent"])
|
||||
}
|
||||
if body["content_size"] != zhipuContentSize {
|
||||
t.Errorf("zhipu body content_size = %v, want %s", body["content_size"], zhipuContentSize)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user