providers

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClaudeProvider

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

ClaudeProvider implements ModelProvider for Anthropic Claude models. Claude uses the Messages API (/v1/messages) but this provider wraps it via OpenAI-compatible proxies (e.g., LiteLLM, AWS Bedrock). For direct Anthropic API access, set baseURL to a proxy that translates OpenAI-format requests to Claude Messages format.

func NewClaudeProvider

func NewClaudeProvider(baseURL, apiKey, modelName string) *ClaudeProvider

NewClaudeProvider creates a new Claude provider. If baseURL is empty, defaults to the Anthropic API.

func (*ClaudeProvider) Capabilities

func (p *ClaudeProvider) Capabilities() []skills.CapabilityType

func (*ClaudeProvider) Embed

func (p *ClaudeProvider) Embed(ctx context.Context, texts []string) ([][]float32, error)

func (*ClaudeProvider) Generate

func (*ClaudeProvider) ID

func (p *ClaudeProvider) ID() string

type ModelProvider

type ModelProvider interface {
	// ID returns the unique identifier for this provider.
	// Format: "vendor/model" (e.g., "anthropic/claude-3-opus", "openai/gpt-4o")
	ID() string

	// Capabilities returns the list of capabilities this provider supports.
	Capabilities() []skills.CapabilityType

	// Generate performs a model generation call.
	Generate(ctx context.Context, req skills.GenerateRequest) (*skills.GenerateResponse, error)

	// Embed generates embeddings for the given texts.
	// Only available if skills.CapEmbedding is in Capabilities().
	Embed(ctx context.Context, texts []string) ([][]float32, error)
}

ModelProvider abstracts a model backend (Claude, OpenAI, etc.).

Providers are capability-based: skills declare required capabilities, and the router selects an appropriate provider.

type ModelRouter

type ModelRouter interface {
	// Route selects the best provider for the given requirements.
	// Returns ai.ErrNoMatchingProvider if no provider satisfies the requirements.
	Route(requirements []skills.CapabilityType, constraints skills.ModelConstraints) (ModelProvider, error)

	// Register adds a provider to the router.
	Register(provider ModelProvider) error

	// List returns all registered provider IDs.
	List() []string
}

ModelRouter selects a provider based on required capabilities and constraints.

type ModelScopeProvider

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

ModelScopeProvider implements ModelProvider for Alibaba ModelScope.

func NewModelScopeProvider

func NewModelScopeProvider(baseURL, apiKey, modelName string) *ModelScopeProvider

NewModelScopeProvider creates a new ModelScope provider.

func (*ModelScopeProvider) Capabilities

func (p *ModelScopeProvider) Capabilities() []skills.CapabilityType

func (*ModelScopeProvider) Embed

func (p *ModelScopeProvider) Embed(ctx context.Context, texts []string) ([][]float32, error)

func (*ModelScopeProvider) Generate

func (*ModelScopeProvider) ID

func (p *ModelScopeProvider) ID() string

type OpenAIProvider

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

OpenAIProvider implements ModelProvider for OpenAI models.

func NewOpenAIProvider

func NewOpenAIProvider(baseURL, apiKey, modelName string) *OpenAIProvider

NewOpenAIProvider creates a new OpenAI provider. If baseURL is empty, defaults to the official OpenAI API.

func (*OpenAIProvider) Capabilities

func (p *OpenAIProvider) Capabilities() []skills.CapabilityType

func (*OpenAIProvider) Embed

func (p *OpenAIProvider) Embed(ctx context.Context, texts []string) ([][]float32, error)

func (*OpenAIProvider) Generate

func (*OpenAIProvider) ID

func (p *OpenAIProvider) ID() string

type SiliconFlowProvider

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

SiliconFlowProvider implements ModelProvider for SiliconFlow gateway.

func NewSiliconFlowProvider

func NewSiliconFlowProvider(baseURL, apiKey, modelName string) *SiliconFlowProvider

NewSiliconFlowProvider creates a new SiliconFlow provider.

func (*SiliconFlowProvider) Capabilities

func (p *SiliconFlowProvider) Capabilities() []skills.CapabilityType

func (*SiliconFlowProvider) Embed

func (p *SiliconFlowProvider) Embed(ctx context.Context, texts []string) ([][]float32, error)

func (*SiliconFlowProvider) Generate

func (*SiliconFlowProvider) ID

func (p *SiliconFlowProvider) ID() string

Jump to

Keyboard shortcuts

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