Documentation
¶
Index ¶
- Variables
- func ExecuteParts(writer AgentIO, parts ...MessagePart) error
- func FindNewMessage(oldScreen, newScreen string) string
- func PartsToString(parts ...MessagePart) string
- type AgentIO
- type Conversation
- func (c *Conversation) AddSnapshot(screen string)
- func (c *Conversation) Messages() []ConversationMessage
- func (c *Conversation) Screen() string
- func (c *Conversation) SendMessage(messageParts ...MessagePart) error
- func (c *Conversation) StartSnapshotLoop(ctx context.Context)
- func (c *Conversation) Status() ConversationStatus
- type ConversationConfig
- type ConversationMessage
- type ConversationRole
- type ConversationStatus
- type MessagePart
- type MessagePartText
- type RingBuffer
Constants ¶
This section is empty.
Variables ¶
View Source
var ConversationRoleValues = []ConversationRole{ ConversationRoleUser, ConversationRoleAgent, }
View Source
var MessageValidationErrorChanging = xerrors.New("message can only be sent when the agent is waiting for user input")
View Source
var MessageValidationErrorEmpty = xerrors.New("message must not be empty")
View Source
var MessageValidationErrorWhitespace = xerrors.New("message must be trimmed of leading and trailing whitespace")
Functions ¶
func ExecuteParts ¶
func ExecuteParts(writer AgentIO, parts ...MessagePart) error
func FindNewMessage ¶
func PartsToString ¶
func PartsToString(parts ...MessagePart) string
Types ¶
type Conversation ¶
type Conversation struct {
// contains filtered or unexported fields
}
func NewConversation ¶
func NewConversation(ctx context.Context, cfg ConversationConfig) *Conversation
func (*Conversation) AddSnapshot ¶
func (c *Conversation) AddSnapshot(screen string)
func (*Conversation) Messages ¶
func (c *Conversation) Messages() []ConversationMessage
func (*Conversation) Screen ¶
func (c *Conversation) Screen() string
func (*Conversation) SendMessage ¶
func (c *Conversation) SendMessage(messageParts ...MessagePart) error
func (*Conversation) StartSnapshotLoop ¶
func (c *Conversation) StartSnapshotLoop(ctx context.Context)
func (*Conversation) Status ¶
func (c *Conversation) Status() ConversationStatus
type ConversationConfig ¶
type ConversationConfig struct { AgentIO AgentIO // GetTime returns the current time GetTime func() time.Time // How often to take a snapshot for the stability check SnapshotInterval time.Duration // How long the screen should not change to be considered stable ScreenStabilityLength time.Duration // Function to format the messages received from the agent // userInput is the last user message FormatMessage func(message string, userInput string) string // SkipWritingMessage skips the writing of a message to the agent. // This is used in tests SkipWritingMessage bool // SkipSendMessageStatusCheck skips the check for whether the message can be sent. // This is used in tests SkipSendMessageStatusCheck bool }
type ConversationMessage ¶
type ConversationMessage struct { Id int Message string Role ConversationRole Time time.Time }
type ConversationRole ¶
type ConversationRole string
const ( ConversationRoleUser ConversationRole = "user" ConversationRoleAgent ConversationRole = "agent" )
func (ConversationRole) Schema ¶
func (c ConversationRole) Schema(r huma.Registry) *huma.Schema
type ConversationStatus ¶
type ConversationStatus string
const ( ConversationStatusChanging ConversationStatus = "changing" ConversationStatusStable ConversationStatus = "stable" ConversationStatusInitializing ConversationStatus = "initializing" )
type MessagePart ¶
type MessagePartText ¶
func (MessagePartText) Do ¶
func (p MessagePartText) Do(writer AgentIO) error
func (MessagePartText) String ¶
func (p MessagePartText) String() string
type RingBuffer ¶
type RingBuffer[T any] struct { // contains filtered or unexported fields }
RingBuffer is a generic circular buffer that can store items of any type
func NewRingBuffer ¶
func NewRingBuffer[T any](size int) *RingBuffer[T]
NewRingBuffer creates a new ring buffer with the specified size
func (*RingBuffer[T]) Capacity ¶
func (b *RingBuffer[T]) Capacity() int
Capacity returns the capacity of the ring buffer
func (*RingBuffer[T]) GetAll ¶
func (b *RingBuffer[T]) GetAll() []T
GetAll returns all items in the buffer, oldest first
Click to show internal directories.
Click to hide internal directories.