Documentation
¶
Index ¶
- Variables
- type Agent
- func (a *Agent) Compact(ctx context.Context) error
- func (a *Agent) ContextTokens() int
- func (a *Agent) ContextWindow() int
- func (a *Agent) GetLastAssistantMessage() string
- func (a *Agent) GetMessages() []openai.ChatCompletionMessageParamUnion
- func (a *Agent) Inject(text string) bool
- func (a *Agent) LogTail(epoch, from int) ([]json.RawMessage, int, error)
- func (a *Agent) MemoryDir(scope string) string
- func (a *Agent) Mode() Mode
- func (a *Agent) Model() string
- func (a *Agent) Restore(raw []json.RawMessage) error
- func (a *Agent) Run(ctx context.Context, userPrompt string) error
- func (a *Agent) SetInjectedCallback(fn func(texts []string))
- func (a *Agent) SetMode(m Mode)
- func (a *Agent) SetNoticeCallback(fn func(text string))
- func (a *Agent) SetTextCallback(fn func(delta string))
- func (a *Agent) SetToolCallCallback(fn func(name, arguments string))
- type AgentOptions
- type Mode
Constants ¶
This section is empty.
Variables ¶
var ErrNothingToCompact = errors.New("nothing to compact yet")
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
func NewAgent ¶
func NewAgent(opts AgentOptions) *Agent
func (*Agent) ContextTokens ¶
Returns the estimated tokens in the conversation
func (*Agent) ContextWindow ¶
Returns the context window size; 0 means unknown
func (*Agent) GetLastAssistantMessage ¶
Returns the content of the last assistant message
func (*Agent) GetMessages ¶
func (a *Agent) GetMessages() []openai.ChatCompletionMessageParamUnion
Returns a copy of the conversation history
func (*Agent) LogTail ¶
Returns messages from index from, each encoded as JSON, and the current epoch; if epoch is stale the history was compacted, so all messages are returned
func (*Agent) Restore ¶
func (a *Agent) Restore(raw []json.RawMessage) error
Replaces the conversation history with messages saved by LogTail
func (*Agent) SetInjectedCallback ¶
Sets a callback fired when injected messages enter the conversation
func (*Agent) SetMode ¶
Switches the mode The switch is recorded in the conversation so the model knows the rules changed
func (*Agent) SetNoticeCallback ¶
Sets a callback for status notices such as compaction
func (*Agent) SetTextCallback ¶
Sets a callback to receive assistant text deltas as they stream in
func (*Agent) SetToolCallCallback ¶
Sets a callback for tool calls