Documentation
¶
Index ¶
- type ABRouterChatModel
- func (a *ABRouterChatModel) Generate(ctx context.Context, input []*schema.Message, opts ...model.Option) (*schema.Message, error)
- func (a *ABRouterChatModel) IsCallbacksEnabled() bool
- func (a *ABRouterChatModel) Stream(ctx context.Context, input []*schema.Message, opts ...model.Option) (*schema.StreamReader[*schema.Message], error)
- func (a *ABRouterChatModel) WithTools(tools []*schema.ToolInfo) (model.ToolCallingChatModel, error)
- type ModelRouter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ABRouterChatModel ¶
type ABRouterChatModel struct {
// contains filtered or unexported fields
}
ABRouterChatModel is a dynamic router over chat models that implements ToolCallingChatModel.
Behavior:
- Routing: delegates the choice to a user-provided ModelRouter which returns (modelName, BaseChatModel).
- RunInfo naming: uses the returned modelName when calling callbacks.EnsureRunInfo so callbacks can log the chosen model.
- Tools: stores tool infos via WithTools and applies them lazily if the chosen model supports ToolCallingChatModel.
- Callbacks: if the chosen model exposes components.Checker and IsCallbacksEnabled()==true, delegates directly; otherwise injects OnStart/OnEnd/OnError around Generate/Stream.
- IsCallbacksEnabled: returns true to indicate this wrapper already coordinates callback triggering.
Typical usage:
router := NewABRouterChatModel(func(ctx, msgs, opts...) (string, model.BaseChatModel, error) {
return "openai", openaiModel, nil
})
router = router.WithTools(toolInfos) // optional
msg, _ := router.Generate(ctx, input)
func NewABRouterChatModel ¶
func NewABRouterChatModel(router ModelRouter) *ABRouterChatModel
func (*ABRouterChatModel) IsCallbacksEnabled ¶
func (a *ABRouterChatModel) IsCallbacksEnabled() bool
func (*ABRouterChatModel) WithTools ¶
func (a *ABRouterChatModel) WithTools(tools []*schema.ToolInfo) (model.ToolCallingChatModel, error)
Click to show internal directories.
Click to hide internal directories.