Documentation
¶
Overview ¶
Package rulebased provides a rule-based model router that selects the appropriate model based on NLP analysis of the input using Bleve.
Routes are defined with example texts, and Bleve's full-text search determines the best matching route based on text similarity.
A model becomes a rule-based router when it has routing rules configured. The model's provider/model fields define the fallback model, and each routing rule maps example phrases to different target models.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client implements the Provider interface for rule-based model routing.
func NewClient ¶
func NewClient(ctx context.Context, cfg *latest.ModelConfig, models map[string]latest.ModelConfig, env environment.Provider, providerFactory ProviderFactory, opts ...options.Opt) (*Client, error)
NewClient creates a new rule-based routing client. The cfg parameter should have Routing rules configured. The provider/model fields of cfg define the fallback model that is used when no routing rule matches.
func (*Client) BaseConfig ¶
BaseConfig returns the base configuration.
type Provider ¶
type Provider interface {
ID() string
CreateChatCompletionStream(
ctx context.Context,
messages []chat.Message,
availableTools []tools.Tool,
) (chat.MessageStream, error)
BaseConfig() base.Config
}
Provider defines the minimal interface needed for model providers.
type ProviderFactory ¶
type ProviderFactory func(ctx context.Context, modelSpec string, models map[string]latest.ModelConfig, env environment.Provider, opts ...options.Opt) (Provider, error)
ProviderFactory creates a provider from a model config. The models parameter provides access to all configured models for resolving references.