Documentation
¶
Index ¶
- type Factory
- type MixedChatModel
- func (m *MixedChatModel) Generate(ctx context.Context, messages []*schema.Message, opts ...model.Option) (*schema.Message, error)
- func (m *MixedChatModel) Stream(ctx context.Context, messages []*schema.Message, opts ...model.Option) (*schema.StreamReader[*schema.Message], error)
- func (m *MixedChatModel) WithTools(tools []*schema.ToolInfo) (model.ToolCallingChatModel, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
Factory is used to create ChatModel for different providers
func (*Factory) CreateChatModel ¶
func (f *Factory) CreateChatModel(ctx context.Context, modelName string) (model.ToolCallingChatModel, error)
CreateChatModel creates corresponding ChatModel based on model name
type MixedChatModel ¶ added in v1.5.2
type MixedChatModel struct {
// contains filtered or unexported fields
}
MixedChatModel wraps multiple ToolCallingChatModel instances and selects among them using weighted random selection. Models with weight 0 are never selected. When all active weights are equal, it falls back to round-robin.
func NewMixedChatModel ¶ added in v1.5.2
func NewMixedChatModel(models []model.ToolCallingChatModel, weights []int) *MixedChatModel
NewMixedChatModel creates a new MixedChatModel that selects among the given models using the provided weights. At least one model is required. Models with weight <= 0 are excluded from selection. When weights is nil or empty, equal weight (round-robin) is used for all models.
func (*MixedChatModel) Generate ¶ added in v1.5.2
func (m *MixedChatModel) Generate(ctx context.Context, messages []*schema.Message, opts ...model.Option) (*schema.Message, error)
Generate implements BaseChatModel. It selects a model based on weights.
func (*MixedChatModel) Stream ¶ added in v1.5.2
func (m *MixedChatModel) Stream(ctx context.Context, messages []*schema.Message, opts ...model.Option) (*schema.StreamReader[*schema.Message], error)
Stream implements BaseChatModel. It selects a model based on weights.
func (*MixedChatModel) WithTools ¶ added in v1.5.2
func (m *MixedChatModel) WithTools(tools []*schema.ToolInfo) (model.ToolCallingChatModel, error)
WithTools creates a new MixedChatModel where every underlying model has the given tools bound. Each call to WithTools returns a fresh MixedChatModel so the original is not mutated (safe for sharing across goroutines).