1package providertests
2
3import (
4 "net/http"
5 "os"
6 "testing"
7
8 "charm.land/fantasy"
9 "charm.land/fantasy/providers/openaicompat"
10 "charm.land/fantasy/providers/zai"
11 "gopkg.in/dnaeon/go-vcr.v4/pkg/recorder"
12)
13
14func TestZAICommon(t *testing.T) {
15 testCommon(t, []builderPair{
16 {"zai-glm-4.6", builderZAI, nil, nil},
17 })
18}
19
20func builderZAI(t *testing.T, r *recorder.Recorder) (fantasy.LanguageModel, error) {
21 provider, err := zai.New(
22 openaicompat.WithAPIKey(os.Getenv("FANTASY_ZAI_API_KEY")),
23 openaicompat.WithHTTPClient(&http.Client{Transport: r}),
24 )
25 if err != nil {
26 return nil, err
27 }
28 return provider.LanguageModel(t.Context(), "glm-4.6")
29}