fix(web): let gemini ignore search range
This commit is contained in:
parent
685dba1c94
commit
3084c6942c
2 changed files with 24 additions and 10 deletions
|
|
@ -485,9 +485,6 @@ func (p *GeminiSearchProvider) Search(
|
||||||
count int,
|
count int,
|
||||||
rangeCode string,
|
rangeCode string,
|
||||||
) (string, error) {
|
) (string, error) {
|
||||||
if rangeCode != "" {
|
|
||||||
return "", fmt.Errorf("gemini search does not support range filter")
|
|
||||||
}
|
|
||||||
if strings.TrimSpace(p.apiKey) == "" {
|
if strings.TrimSpace(p.apiKey) == "" {
|
||||||
return "", errors.New("no API key provided")
|
return "", errors.New("no API key provided")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1959,19 +1959,36 @@ func TestGeminiSearchProvider_SearchSuccess(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGeminiSearchProvider_SearchRejectsRange(t *testing.T) {
|
func TestGeminiSearchProvider_SearchIgnoresRange(t *testing.T) {
|
||||||
provider := &GeminiSearchProvider{
|
provider := &GeminiSearchProvider{
|
||||||
apiKey: "google-key",
|
apiKey: "google-key",
|
||||||
model: "gemini-2.5-flash",
|
model: "gemini-2.5-flash",
|
||||||
client: http.DefaultClient,
|
client: &http.Client{
|
||||||
|
Transport: roundTripFunc(func(req *http.Request) (*http.Response, error) {
|
||||||
|
rec := httptest.NewRecorder()
|
||||||
|
rec.WriteHeader(http.StatusOK)
|
||||||
|
fmt.Fprint(rec, `{
|
||||||
|
"candidates": [
|
||||||
|
{
|
||||||
|
"content": {
|
||||||
|
"parts": [
|
||||||
|
{"text": "Recent robotics result."}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}`)
|
||||||
|
return rec.Result(), nil
|
||||||
|
}),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := provider.Search(context.Background(), "robotics", 2, "d")
|
out, err := provider.Search(context.Background(), "robotics", 2, "d")
|
||||||
if err == nil {
|
if err != nil {
|
||||||
t.Fatal("expected error")
|
t.Fatalf("Search() error: %v", err)
|
||||||
}
|
}
|
||||||
if !strings.Contains(err.Error(), "does not support range") {
|
if !strings.Contains(out, "Recent robotics result.") {
|
||||||
t.Fatalf("unexpected error: %v", err)
|
t.Fatalf("missing response text in output: %s", out)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue