模型优化

This commit is contained in:
2026-06-10 12:31:43 +08:00
parent fe2477dd97
commit 440f83f6a7
5 changed files with 110 additions and 5 deletions
+10
View File
@@ -2,6 +2,7 @@ package search
import (
"context"
"errors"
"net/http"
"net/http/httptest"
"os"
@@ -66,6 +67,15 @@ func TestBuildResultContext(t *testing.T) {
}
}
func TestBuildFallbackContext(t *testing.T) {
text := BuildFallbackContext(ProfileConfig{Name: "duckduckgo", Provider: "duckduckgo"}, "历史上的今天都发生了什么?", "需要查询当天历史事件", errors.New("未搜索到相关网页结果"))
for _, want := range []string{"没有可用的搜索结果", "历史上的今天", "需要查询当天历史事件", "模型训练数据/内置知识", "不要伪造网页链接"} {
if !strings.Contains(text, want) {
t.Fatalf("fallback context missing %q:\n%s", want, text)
}
}
}
func TestDuckDuckGoSearchParsesResults(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Query().Get("q") != "golang" {