Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions providers/cerebras/cerebras.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package cerebras

Check failure on line 1 in providers/cerebras/cerebras.go

View workflow job for this annotation

GitHub Actions / lint / lint (macos-latest)

package-comments: should have a package comment (revive)

Check failure on line 1 in providers/cerebras/cerebras.go

View workflow job for this annotation

GitHub Actions / lint / lint (macos-latest)

package-comments: should have a package comment (revive)

import (
"charm.land/fantasy"
"charm.land/fantasy/providers/openaicompat"
)

const (
Name = "cerebras"

Check failure on line 9 in providers/cerebras/cerebras.go

View workflow job for this annotation

GitHub Actions / lint / lint (macos-latest)

exported: exported const Name should have comment (or a comment on this block) or be unexported (revive)

Check failure on line 9 in providers/cerebras/cerebras.go

View workflow job for this annotation

GitHub Actions / lint / lint (macos-latest)

exported: exported const Name should have comment (or a comment on this block) or be unexported (revive)
BaseURL = "https://api.cerebras.ai/v1"
)

type Option = openaicompat.Option

Check failure on line 13 in providers/cerebras/cerebras.go

View workflow job for this annotation

GitHub Actions / lint / lint (macos-latest)

exported: exported type Option should have comment or be unexported (revive)

Check failure on line 13 in providers/cerebras/cerebras.go

View workflow job for this annotation

GitHub Actions / lint / lint (macos-latest)

exported: exported type Option should have comment or be unexported (revive)

func New(opts ...Option) (fantasy.Provider, error) {

Check failure on line 15 in providers/cerebras/cerebras.go

View workflow job for this annotation

GitHub Actions / lint / lint (macos-latest)

exported: exported function New should have comment or be unexported (revive)

Check failure on line 15 in providers/cerebras/cerebras.go

View workflow job for this annotation

GitHub Actions / lint / lint (macos-latest)

exported: exported function New should have comment or be unexported (revive)
options := []Option{
openaicompat.WithName(Name),
openaicompat.WithBaseURL(BaseURL),
}
options = append(options, opts...)
return openaicompat.New(options...)
}
22 changes: 22 additions & 0 deletions providers/groq/groq.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package groq

Check failure on line 1 in providers/groq/groq.go

View workflow job for this annotation

GitHub Actions / lint / lint (macos-latest)

package-comments: should have a package comment (revive)

Check failure on line 1 in providers/groq/groq.go

View workflow job for this annotation

GitHub Actions / lint / lint (macos-latest)

package-comments: should have a package comment (revive)

import (
"charm.land/fantasy"
"charm.land/fantasy/providers/openaicompat"
)

const (
Name = "groq"

Check failure on line 9 in providers/groq/groq.go

View workflow job for this annotation

GitHub Actions / lint / lint (macos-latest)

exported: exported const Name should have comment (or a comment on this block) or be unexported (revive)

Check failure on line 9 in providers/groq/groq.go

View workflow job for this annotation

GitHub Actions / lint / lint (macos-latest)

exported: exported const Name should have comment (or a comment on this block) or be unexported (revive)
BaseURL = "https://api.groq.com/openai/v1"
)

type Option = openaicompat.Option

Check failure on line 13 in providers/groq/groq.go

View workflow job for this annotation

GitHub Actions / lint / lint (macos-latest)

exported: exported type Option should have comment or be unexported (revive)

Check failure on line 13 in providers/groq/groq.go

View workflow job for this annotation

GitHub Actions / lint / lint (macos-latest)

exported: exported type Option should have comment or be unexported (revive)

func New(opts ...Option) (fantasy.Provider, error) {

Check failure on line 15 in providers/groq/groq.go

View workflow job for this annotation

GitHub Actions / lint / lint (macos-latest)

exported: exported function New should have comment or be unexported (revive)

Check failure on line 15 in providers/groq/groq.go

View workflow job for this annotation

GitHub Actions / lint / lint (macos-latest)

exported: exported function New should have comment or be unexported (revive)
options := []Option{
openaicompat.WithName(Name),
openaicompat.WithBaseURL(BaseURL),
}
options = append(options, opts...)
return openaicompat.New(options...)
}
22 changes: 22 additions & 0 deletions providers/huggingface/huggingface.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package huggingface

Check failure on line 1 in providers/huggingface/huggingface.go

View workflow job for this annotation

GitHub Actions / lint / lint (macos-latest)

package-comments: should have a package comment (revive)

Check failure on line 1 in providers/huggingface/huggingface.go

View workflow job for this annotation

GitHub Actions / lint / lint (macos-latest)

package-comments: should have a package comment (revive)

import (
"charm.land/fantasy"
"charm.land/fantasy/providers/openaicompat"
)

const (
Name = "huggingface"

Check failure on line 9 in providers/huggingface/huggingface.go

View workflow job for this annotation

GitHub Actions / lint / lint (macos-latest)

exported: exported const Name should have comment (or a comment on this block) or be unexported (revive)

Check failure on line 9 in providers/huggingface/huggingface.go

View workflow job for this annotation

GitHub Actions / lint / lint (macos-latest)

exported: exported const Name should have comment (or a comment on this block) or be unexported (revive)
BaseURL = "https://router.huggingface.co/v1"
)

type Option = openaicompat.Option

func New(opts ...Option) (fantasy.Provider, error) {
options := []Option{
openaicompat.WithName(Name),
openaicompat.WithBaseURL(BaseURL),
}
options = append(options, opts...)
return openaicompat.New(options...)
}
22 changes: 22 additions & 0 deletions providers/xai/xai.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package xai

import (
"charm.land/fantasy"
"charm.land/fantasy/providers/openaicompat"
)

const (
Name = "xai"
BaseURL = "https://api.x.ai/v1"
)

type Option = openaicompat.Option

func New(opts ...Option) (fantasy.Provider, error) {
options := []Option{
openaicompat.WithName(Name),
openaicompat.WithBaseURL(BaseURL),
}
options = append(options, opts...)
return openaicompat.New(options...)
}
22 changes: 22 additions & 0 deletions providers/zai/zai.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package zai

import (
"charm.land/fantasy"
"charm.land/fantasy/providers/openaicompat"
)

const (
Name = "zai"
BaseURL = "https://api.z.ai/api/coding/paas/v4"
)

type Option = openaicompat.Option

func New(opts ...Option) (fantasy.Provider, error) {
options := []Option{
openaicompat.WithName(Name),
openaicompat.WithBaseURL(BaseURL),
}
options = append(options, opts...)
return openaicompat.New(options...)
}
29 changes: 29 additions & 0 deletions providertests/cerebras_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package providertests

import (
"net/http"
"os"
"testing"

"charm.land/fantasy"
"charm.land/fantasy/providers/cerebras"
"charm.land/fantasy/providers/openaicompat"
"gopkg.in/dnaeon/go-vcr.v4/pkg/recorder"
)

func TestCerebrasCommon(t *testing.T) {
testCommon(t, []builderPair{
{"cerebras-qwen-3-coder-480b", builderCerebras, nil, nil},
})
}

func builderCerebras(t *testing.T, r *recorder.Recorder) (fantasy.LanguageModel, error) {
provider, err := cerebras.New(
openaicompat.WithAPIKey(os.Getenv("FANTASY_CEREBRAS_API_KEY")),
openaicompat.WithHTTPClient(&http.Client{Transport: r}),
)
if err != nil {
return nil, err
}
return provider.LanguageModel(t.Context(), "qwen-3-coder-480b")
}
29 changes: 29 additions & 0 deletions providertests/groq_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package providertests

import (
"net/http"
"os"
"testing"

"charm.land/fantasy"
"charm.land/fantasy/providers/groq"
"charm.land/fantasy/providers/openaicompat"
"gopkg.in/dnaeon/go-vcr.v4/pkg/recorder"
)

func TestGroqCommon(t *testing.T) {
testCommon(t, []builderPair{
{"groq-kimi-k2-0905", builderGroqProvider, nil, nil},
})
}

func builderGroqProvider(t *testing.T, r *recorder.Recorder) (fantasy.LanguageModel, error) {
provider, err := groq.New(
openaicompat.WithAPIKey(os.Getenv("FANTASY_GROQ_API_KEY")),
openaicompat.WithHTTPClient(&http.Client{Transport: r}),
)
if err != nil {
return nil, err
}
return provider.LanguageModel(t.Context(), "moonshotai/kimi-k2-instruct-0905")
}
29 changes: 29 additions & 0 deletions providertests/huggingface_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package providertests

import (
"net/http"
"os"
"testing"

"charm.land/fantasy"
"charm.land/fantasy/providers/huggingface"
"charm.land/fantasy/providers/openaicompat"
"gopkg.in/dnaeon/go-vcr.v4/pkg/recorder"
)

func TestHuggingFaceCommon(t *testing.T) {
testCommon(t, []builderPair{
{"huggingface-glm-4.6", builderHuggingFaceProvider, nil, nil},
})
}

func builderHuggingFaceProvider(t *testing.T, r *recorder.Recorder) (fantasy.LanguageModel, error) {
provider, err := huggingface.New(
openaicompat.WithAPIKey(os.Getenv("FANTASY_HUGGINGFACE_API_KEY")),
openaicompat.WithHTTPClient(&http.Client{Transport: r}),
)
if err != nil {
return nil, err
}
return provider.LanguageModel(t.Context(), "zai-org/GLM-4.6")
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading