Documentation
¶
Index ¶
- Constants
- type CompressionCompleteCallback
- type Manager
- func (m *Manager) AddMessage(ctx context.Context, message *schema.Message)
- func (m *Manager) Clear()
- func (m *Manager) GetChatModel() model.ToolCallingChatModel
- func (m *Manager) GetFullMessages() []*schema.Message
- func (m *Manager) GetLastUserMessage() string
- func (m *Manager) GetMessageCount() int
- func (m *Manager) GetMessages() []*schema.Message
- func (m *Manager) GetSummary() string
- func (m *Manager) IncRound()
- func (m *Manager) RemoveLastRound()
- func (m *Manager) SetChatModel(chatmodel model.ToolCallingChatModel)
- func (m *Manager) SetCompressionCompleteCallback(cb CompressionCompleteCallback)
- func (m *Manager) SetFullMessageRounds(rounds int)
- func (m *Manager) SetPersistenceCallback(cb PersistenceCallback)
- type PersistenceCallback
Constants ¶
const ( DefaultMaxMessageRound int = 10 DefaultFullMessageRounds int = 1 // CompressionThreshold defines the minimum maxMessageRounds required for // async compression. When maxMessageRounds is below this value, simple // truncation is used instead to avoid issues like empty user queries or // premature compression. CompressionThreshold int = 8 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompressionCompleteCallback ¶
CompressionCompleteCallback is a callback function that is called after compression completes This allows the caller to persist the modified messages (full overwrite mode)
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages conversation context with intelligent context management capabilities
func NewManager ¶
NewManager creates a new Manager instance
func (*Manager) AddMessage ¶
AddMessage adds a message to the context
func (*Manager) Clear ¶
func (m *Manager) Clear()
Clear clears the context (preserves system messages)
func (*Manager) GetChatModel ¶
func (m *Manager) GetChatModel() model.ToolCallingChatModel
func (*Manager) GetFullMessages ¶
GetFullMessages retrieves all full messages in the current context This includes all original messages without any simplification. The returned messages are guaranteed to have proper tool_call / tool_result pairing.
func (*Manager) GetLastUserMessage ¶
GetLastUserMessage returns the content of the last user message in the conversation. Returns empty string if no user message is found.
func (*Manager) GetMessageCount ¶
GetMessageCount returns the total number of messages in the context
func (*Manager) GetMessages ¶
GetMessages retrieves simplified messages in the current context Old rounds are simplified (first user message + last assistant response) The returned messages are guaranteed to have proper tool_call / tool_result pairing.
func (*Manager) GetSummary ¶
GetSummary generates a summary of the conversation
func (*Manager) RemoveLastRound ¶
func (m *Manager) RemoveLastRound()
RemoveLastRound removes the last round of messages from the context. This is used for regenerating a response - the last assistant response is removed so the user message can be re-processed.
func (*Manager) SetChatModel ¶
func (m *Manager) SetChatModel(chatmodel model.ToolCallingChatModel)
SetChatModel sets the chat model for message compression
func (*Manager) SetCompressionCompleteCallback ¶
func (m *Manager) SetCompressionCompleteCallback(cb CompressionCompleteCallback)
SetCompressionCompleteCallback sets the callback that is called after compression completes
func (*Manager) SetFullMessageRounds ¶
SetFullMessageRounds sets how many recent rounds to keep full messages
func (*Manager) SetPersistenceCallback ¶
func (m *Manager) SetPersistenceCallback(cb PersistenceCallback)
SetPersistenceCallback sets the callback for auto-saving messages
type PersistenceCallback ¶
PersistenceCallback is a callback function for single message persistence Each time a new message is added, this callback is invoked with that single message