picoclaw/internal/fantasy/providertests/openai_test.go
ZanzyTHEbar 3589adab08 feat(deps): vendor charm.land/fantasy SDK as local module
Add Fantasy SDK (v0.8.1) as a vendored local module under internal/fantasy
with a replace directive in go.mod. This provides a unified multi-provider
LLM abstraction (OpenAI, Anthropic, Google, Azure, Bedrock, etc.) with
built-in streaming, tool calling, and retry support.

Update go.mod/go.sum with new transitive dependencies including
langchaingo, go-libsql, testify, and openai-go v2.
2026-02-15 21:47:07 +00:00

47 lines
1.1 KiB
Go

package providertests
import (
"net/http"
"os"
"testing"
"charm.land/fantasy"
"charm.land/fantasy/providers/openai"
"charm.land/x/vcr"
)
var openaiTestModels = []testModel{
{"openai-gpt-4o", "gpt-4o", false},
{"openai-gpt-4o-mini", "gpt-4o-mini", false},
{"openai-gpt-5", "gpt-5", true},
{"openai-o4-mini", "o4-mini", true},
}
func TestOpenAICommon(t *testing.T) {
var pairs []builderPair
for _, m := range openaiTestModels {
pairs = append(pairs, builderPair{m.name, openAIBuilder(m.model), nil, nil})
}
testCommon(t, pairs)
}
func TestOpenAIObjectGeneration(t *testing.T) {
var pairs []builderPair
for _, m := range openaiTestModels {
pairs = append(pairs, builderPair{m.name, openAIBuilder(m.model), nil, nil})
}
testObjectGeneration(t, pairs)
}
func openAIBuilder(model string) builderFunc {
return func(t *testing.T, r *vcr.Recorder) (fantasy.LanguageModel, error) {
provider, err := openai.New(
openai.WithAPIKey(os.Getenv("FANTASY_OPENAI_API_KEY")),
openai.WithHTTPClient(&http.Client{Transport: r}),
)
if err != nil {
return nil, err
}
return provider.LanguageModel(t.Context(), model)
}
}