xai_test.go

 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/xai"
11	"gopkg.in/dnaeon/go-vcr.v4/pkg/recorder"
12)
13
14func TestXAICommon(t *testing.T) {
15	testCommon(t, []builderPair{
16		{"xai-grok-code-fast", builderXAI, nil, nil},
17	})
18}
19
20func builderXAI(t *testing.T, r *recorder.Recorder) (fantasy.LanguageModel, error) {
21	provider, err := xai.New(
22		openaicompat.WithAPIKey(os.Getenv("FANTASY_XAI_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(), "grok-code-fast-1")
29}