Documentation
¶
Index ¶
- type ChatModel
- func (d *ChatModel) Generate(ctx context.Context, input []*schema.Message, opts ...model.Option) (*schema.Message, error)
- func (d *ChatModel) GetType() string
- func (d *ChatModel) IsCallbacksEnabled() bool
- func (d *ChatModel) Stream(ctx context.Context, input []*schema.Message, opts ...model.Option) (*schema.StreamReader[*schema.Message], error)
- func (d *ChatModel) WithTools(tools []*schema.ToolInfo) (model.ToolCallingChatModel, error)
- type OptionFunc
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatModel ¶
type ChatModel struct {
// Model is the underlying ChatModel to wrap
Model model.BaseChatModel
// GetOptionFunc is called before each Generate()/Stream() call to get dynamic options
GetOptionFunc OptionFunc
}
ChatModel wraps a BaseChatModel and enables dynamic option modification. Before each Generate() or Stream() call, it: 1. Reads the current iteration state from the parent graph via compose.ProcessState 2. Calls GetOptionFunc to get dynamic options based on the current state 3. Increments the iteration counter 4. Merges dynamic options with any static options and calls the inner model
func (*ChatModel) Generate ¶
func (d *ChatModel) Generate(ctx context.Context, input []*schema.Message, opts ...model.Option) (*schema.Message, error)
Generate implements model.BaseChatModel. It reads state, calls GetOptionFunc, increments iteration, and delegates to the inner model.
func (*ChatModel) IsCallbacksEnabled ¶
IsCallbacksEnabled implements components.Checker. Delegates to the inner model if it implements Checker.
type OptionFunc ¶
OptionFunc is the function signature for dynamic option generation. It is called before each ChatModel.Generate() call and returns options to be merged with any static options passed to the agent.
Parameters:
- ctx: The context from the current request
- input: The input messages being sent to the ChatModel
- state: The current iteration state (can be modified)
Returns:
- A slice of model.Option to be applied to this ChatModel call
type State ¶
type State struct {
// Iteration is the current iteration number (0-indexed).
// It is incremented after each ChatModel.Generate() call.
Iteration int
// LastToolCalls stores the tool calls from the previous iteration.
// This can be used to make decisions based on what tools were called.
LastToolCalls []*schema.ToolCall
// CustomData allows storing arbitrary data for custom decision logic.
CustomData map[string]any
}
State holds the iteration state that persists across ReAct loop iterations. It is stored in the parent graph's local state and accessed via compose.ProcessState.