providers

package
v2.9.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpenAIProviderType    = "openai"
	AzureProviderType     = "azure"
	AnthropicProviderType = "anthropic"
	BedrockProviderType   = "bedrock"
	CohereProviderType    = "cohere"
	DeepSeekProviderType  = "deepseek"
	GeminiProviderType    = "gemini"
	MistralProviderType   = "mistral"
	OllamaProviderType    = "ollama"
	QwenProviderType      = "qwen"
)

All Supported Provider types

Variables

View Source
var ProviderTypeRegistry = map[string]reflect.Type{}

ProviderTypeRegistry is a registry for AI gateway providers.

Functions

func ValidateSpec

func ValidateSpec(spec *aicontext.ProviderSpec) error

Types

type AnthropicProvider

type AnthropicProvider struct {
	BaseProvider
}

func (*AnthropicProvider) Type

func (p *AnthropicProvider) Type() string

type AzureProvider

type AzureProvider struct {
	BaseProvider
}

func (*AzureProvider) Type

func (p *AzureProvider) Type() string

type BaseProvider

type BaseProvider struct {
	// contains filtered or unexported fields
}

BaseProvider is a struct that contains the common fields for all AI gateway providers. Almost all providers compatible with OpenAI API, so we abstract the common logic.

func (*BaseProvider) Handle

func (bp *BaseProvider) Handle(ctx *aicontext.Context)

func (*BaseProvider) HealthCheck

func (bp *BaseProvider) HealthCheck() error

func (*BaseProvider) Name

func (bp *BaseProvider) Name() string

func (*BaseProvider) ParseTokens

func (bp *BaseProvider) ParseTokens(ctx *aicontext.Context, fc *aicontext.FinishContext, respBody []byte) (inputToken int, outputToken int, err metricshub.MetricError)

func (*BaseProvider) ProxyRequest

func (bp *BaseProvider) ProxyRequest(ctx *aicontext.Context, req *http.Request)

func (*BaseProvider) RequestMapper

func (bp *BaseProvider) RequestMapper(pc *aicontext.Context) (string, []byte, error)

func (*BaseProvider) Spec

func (bp *BaseProvider) Spec() *aicontext.ProviderSpec

func (*BaseProvider) Type

func (bp *BaseProvider) Type() string

type BedrockProvider

type BedrockProvider struct {
	BaseProvider
}

func (*BedrockProvider) Type

func (p *BedrockProvider) Type() string

type CoHereProvider

type CoHereProvider struct {
	BaseProvider
}

func (*CoHereProvider) Type

func (p *CoHereProvider) Type() string

type DeepSeekProvider

type DeepSeekProvider struct {
	BaseProvider
}

func (*DeepSeekProvider) Type

func (p *DeepSeekProvider) Type() string

type GeminiProvider

type GeminiProvider struct {
	BaseProvider
}

func (*GeminiProvider) Type

func (p *GeminiProvider) Type() string

type MistralProvider

type MistralProvider struct {
	BaseProvider
}

func (*MistralProvider) Type

func (p *MistralProvider) Type() string

type OllamaProvider

type OllamaProvider struct {
	BaseProvider
}

func (*OllamaProvider) Type

func (p *OllamaProvider) Type() string

type OpenAIProvider

type OpenAIProvider struct {
	BaseProvider
}

func (*OpenAIProvider) Type

func (p *OpenAIProvider) Type() string

type Provider

type Provider interface {
	Name() string
	Type() string
	Handle(ctx *aicontext.Context)
	Spec() *aicontext.ProviderSpec

	// HealthCheck checks the health of the provider.
	// It should return nil if the provider is healthy, otherwise it returns an error.
	HealthCheck() error
	// contains filtered or unexported methods
}

func NewProvider

func NewProvider(spec *aicontext.ProviderSpec) Provider

type QwenProvider

type QwenProvider struct {
	BaseProvider
}

func (*QwenProvider) Type

func (p *QwenProvider) Type() string

type RequestMapper

type RequestMapper func(pc *aicontext.Context) (path string, newBody []byte, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL