Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuditEntry ¶
type AuditEntry struct {
Time time.Time `json:"time"`
Type EventType `json:"type"`
Iteration int `json:"iteration,omitempty"`
MessageCount int `json:"message_count,omitempty"`
ToolName string `json:"tool_name,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
Error string `json:"error,omitempty"`
}
type AuditHook ¶
type AuditHook struct {
// contains filtered or unexported fields
}
func NewAuditHook ¶
func (*AuditHook) Entries ¶
func (h *AuditHook) Entries() []AuditEntry
type CounterHook ¶
type CounterHook struct {
// contains filtered or unexported fields
}
func NewCounterHook ¶
func NewCounterHook() *CounterHook
func (*CounterHook) Snapshot ¶
func (h *CounterHook) Snapshot() map[EventType]int
type EventType ¶
type EventType string
const ( EventLoopStart EventType = "loop_start" EventBeforeLLM EventType = "before_llm" EventAfterLLM EventType = "after_llm" EventBeforeTool EventType = "before_tool_call" EventAfterTool EventType = "after_tool_call" EventLoopEnd EventType = "loop_end" EventLoopError EventType = "error" DefaultMaxLoopIters = 20 )
type Loop ¶
type Loop struct {
// contains filtered or unexported fields
}
func (*Loop) Run ¶
func (l *Loop) Run(ctx context.Context, initial []llm.ChatMessage, opts RunOptions) (llm.ChatResponse, error)
type RunOptions ¶
type RunOptions struct {
MaxIterations int
OnDelta func(text string)
OnReasoningDelta func(text string)
Tools []llm.ToolSchema
BlockedTools map[string]tool.BlockedToolError
ToolChoice *llm.ToolChoice
ResponseFormat *llm.ResponseFormat
AutoExpandOnce bool
// OnTurnEnd is invoked when the LLM produces a turn with zero tool calls
// (i.e. the natural stopping point). It can request another iteration by
// returning a non-empty `injectInput` string, which will be appended as a
// user-role message and the loop will continue. Returning an empty
// `injectInput` lets the loop terminate as usual. Returning an error
// aborts the loop.
OnTurnEnd func(ctx context.Context, lastResp llm.ChatResponse) (injectInput string, err error)
}
Click to show internal directories.
Click to hide internal directories.