abtest

package
v0.0.0-...-cdc720d Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

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) Generate

func (a *ABRouterChatModel) Generate(ctx context.Context, input []*schema.Message, opts ...model.Option) (*schema.Message, error)

func (*ABRouterChatModel) IsCallbacksEnabled

func (a *ABRouterChatModel) IsCallbacksEnabled() bool

func (*ABRouterChatModel) Stream

func (*ABRouterChatModel) WithTools

type ModelRouter

type ModelRouter func(ctx context.Context, input []*schema.Message, opts ...model.Option) (string, model.BaseChatModel, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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