diff --git a/admin/service/ai_specmatch.go b/admin/service/ai_specmatch.go index c6236ab..986c87c 100644 --- a/admin/service/ai_specmatch.go +++ b/admin/service/ai_specmatch.go @@ -17,9 +17,9 @@ import ( const ( AISpecMatchPromptVersion = "spec_prompt_v1" - // 单次模型调用最多携带 100 个已过滤的可购买候选。超过这个数量时, + // 单次模型调用最多携带 150 个已过滤的可购买候选。超过这个数量时, // 候选本身仍会写入审计记录,但不会让模型在过于宽泛的范围里猜测。 - maxAIModelCandidates = 100 + maxAIModelCandidates = 150 ) type AIMatchSnapshot struct { @@ -151,7 +151,7 @@ func MatchSybSpecWithAI(ctx context.Context, db *sql.DB, actor *model.User, snap } if len(eligible) > maxAIModelCandidates { baseDecision.CandidatesJSON = candidateAuditJSON(bindAICandidates(eligible)) - return recordAIMatchWithoutSave(db, baseDecision, "rejected", "可购买候选超过 100 条,请先人工核对") + return recordAIMatchWithoutSave(db, baseDecision, "rejected", "可购买候选超过 150 条,请先人工核对") } bindings := bindAICandidates(eligible) baseDecision.CandidatesJSON = candidateAuditJSON(bindings) diff --git a/admin/service/ai_specmatch_test.go b/admin/service/ai_specmatch_test.go index 17cddec..56623b6 100644 --- a/admin/service/ai_specmatch_test.go +++ b/admin/service/ai_specmatch_test.go @@ -73,23 +73,23 @@ func TestResolveExtraDimensionSignals_额外维度必须有确定信号(t *testi } func TestMatchSybSpecWithAI_候选白名单低置信度和人工优先(t *testing.T) { - t.Run("100个合格候选允许调用模型", func(t *testing.T) { + t.Run("150个合格候选允许调用模型", func(t *testing.T) { db := newTestDB(t) - actor := seedAIMatchContextWithData(t, db, "SYB-AI-100", "黑色,M", collectedAIChoicesWithCount(t, 100)) + actor := seedAIMatchContextWithData(t, db, "SYB-AI-150", "黑色,M", collectedAIChoicesWithCount(t, 150)) fake := &fakeAIModelClient{response: AIModelMatchResponse{Conclusion: "match", CandidateID: "C01", ConfidenceBPS: 9200, Reason: "候选之一规格一致"}} - result, err := MatchSybSpecWithAI(context.Background(), db, &actor, testAIMatchSnapshot(fake), "SYB-AI-100", "") - if err != nil || result.Outcome != "ai_saved" || fake.calls != 1 || len(fake.last.Candidates) != 100 { - t.Fatalf("100 条候选应调用模型: result=%+v calls=%d candidate_count=%d err=%v", result, fake.calls, len(fake.last.Candidates), err) + result, err := MatchSybSpecWithAI(context.Background(), db, &actor, testAIMatchSnapshot(fake), "SYB-AI-150", "") + if err != nil || result.Outcome != "ai_saved" || fake.calls != 1 || len(fake.last.Candidates) != 150 { + t.Fatalf("150 条候选应调用模型: result=%+v calls=%d candidate_count=%d err=%v", result, fake.calls, len(fake.last.Candidates), err) } }) - t.Run("101个合格候选不调用模型也不保存映射", func(t *testing.T) { + t.Run("151个合格候选不调用模型也不保存映射", func(t *testing.T) { db := newTestDB(t) - actor := seedAIMatchContextWithData(t, db, "SYB-AI-101", "黑色,M", collectedAIChoicesWithCount(t, 101)) + actor := seedAIMatchContextWithData(t, db, "SYB-AI-151", "黑色,M", collectedAIChoicesWithCount(t, 151)) fake := &fakeAIModelClient{err: errors.New("候选超过上限时不应调用模型")} - result, err := MatchSybSpecWithAI(context.Background(), db, &actor, testAIMatchSnapshot(fake), "SYB-AI-101", "") - if err != nil || result.Outcome != "rejected" || result.Message != "可购买候选超过 100 条,请先人工核对" || fake.calls != 0 { - t.Fatalf("101 条候选应在模型调用前拒绝: result=%+v calls=%d err=%v", result, fake.calls, err) + result, err := MatchSybSpecWithAI(context.Background(), db, &actor, testAIMatchSnapshot(fake), "SYB-AI-151", "") + if err != nil || result.Outcome != "rejected" || result.Message != "可购买候选超过 150 条,请先人工核对" || fake.calls != 0 { + t.Fatalf("151 条候选应在模型调用前拒绝: result=%+v calls=%d candidate_count=%d err=%v", result, fake.calls, len(fake.last.Candidates), err) } assertNoAIMapping(t, db) })