1package providertests
2
3import (
4 "cmp"
5 "net/http"
6 "os"
7 "testing"
8
9 "github.com/charmbracelet/fantasy/ai"
10 "github.com/charmbracelet/fantasy/google"
11 "gopkg.in/dnaeon/go-vcr.v4/pkg/recorder"
12)
13
14func TestGoogleCommon(t *testing.T) {
15 testCommon(t, []builderPair{
16 {"gemini-2.5-flash", builderGoogleGemini25Flash, nil},
17 {"gemini-2.5-pro", builderGoogleGemini25Pro, nil},
18 })
19}
20
21func builderGoogleGemini25Flash(r *recorder.Recorder) (ai.LanguageModel, error) {
22 provider := google.New(
23 google.WithAPIKey(cmp.Or(os.Getenv("GEMINI_API_KEY"), "(missing)")),
24 google.WithHTTPClient(&http.Client{Transport: r}),
25 )
26 return provider.LanguageModel("gemini-2.5-flash")
27}
28
29func builderGoogleGemini25Pro(r *recorder.Recorder) (ai.LanguageModel, error) {
30 provider := google.New(
31 google.WithAPIKey(cmp.Or(os.Getenv("GEMINI_API_KEY"), "(missing)")),
32 google.WithHTTPClient(&http.Client{Transport: r}),
33 )
34 return provider.LanguageModel("gemini-2.5-pro")
35}