Documentation
¶
Overview ¶
Package components includes AgentMemory etc.
Index ¶
- func NewTurnID() string
- type ApiResponse
- type ApiUsage
- type Memory
- func (m *Memory) Copy(dist *Memory)
- func (m *Memory) DeleteTurn(turnID string) error
- func (m *Memory) History() []Message
- func (m Memory) MaxMessages() int
- func (m *Memory) MessageCount() int
- func (m *Memory) NewMessage(role MessageRole, content schema.Schema) *Message
- func (m *Memory) NewTurn() *Memory
- func (m *Memory) Reset() *Memory
- func (m *Memory) SetHistory(history []Message) *Memory
- func (m *Memory) SetMaxMessages(maxMessages int) *Memory
- func (m *Memory) SetTurnID(turnID string) *Memory
- func (m Memory) TurnID() string
- type Message
- func (m Message) Attachement() *schema.Attachement
- func (m Message) Content() schema.Schema
- func (m Message) Role() MessageRole
- func (m *Message) SetTurnID(turnID string) *Message
- func (m Message) ToAnthropic(dist *anthropic.Message)
- func (m Message) ToCohere(dist *cohere.Message)
- func (m Message) ToOpenAI(dist *openai.ChatCompletionMessage)
- func (m Message) TurnID() string
- type MessageRole
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ApiResponse ¶ added in v1.0.1
type ApiResponse struct {
ID string `json:"id,omitempty"`
Role MessageRole `json:"role,omitempty"`
Model string `json:"model,omitempty"`
Usage *ApiUsage `json:"usage,omitempty"`
Timestamp int64 `json:"ts,omitempty"`
Details any `json:"content,omitempty"`
}
ApiResponse instructor provider chat response
func (*ApiResponse) FromAnthropic ¶ added in v1.0.1
func (r *ApiResponse) FromAnthropic(v *anthropic.MessagesResponse)
FromAnthropic convert response from anthropic
func (*ApiResponse) FromCohere ¶ added in v1.0.1
func (r *ApiResponse) FromCohere(v *cohere.NonStreamedChatResponse)
FromCohere convert response from cohere
func (*ApiResponse) FromOpenAI ¶ added in v1.0.1
func (r *ApiResponse) FromOpenAI(v *openai.ChatCompletionResponse)
FromOpenAI convnert response from openai
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
Memory Manages the chat history for an AI agent. threadsafe
func (*Memory) DeleteTurn ¶
DeleteTurn delete messages from the memory by its turn ID. returns Error if the specified turn ID is not found in the memory
func (*Memory) History ¶
History retrieves the chat history, filtering out unnecessary fields and serializing content.
func (Memory) MaxMessages ¶
MaxMessages returns the max number of messages
func (*Memory) MessageCount ¶
MessageCount returns the number of messages in the chat history.
func (*Memory) NewMessage ¶
func (m *Memory) NewMessage(role MessageRole, content schema.Schema) *Message
NewMessage adds a message to the chat history and manages overflow.
func (*Memory) SetHistory ¶
SetHistory set a copy of chat history
func (*Memory) SetMaxMessages ¶
SetMaxMessages set the max number of messages
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
Message Represents a message in the chat history.
Attributes:
role (str): . content: The content of the message.
func NewMessage ¶
func NewMessage(role MessageRole, content schema.Schema) *Message
NewMessage returns a new Message
func (Message) Attachement ¶
func (m Message) Attachement() *schema.Attachement
attachement returns message attachement
func (Message) ToAnthropic ¶
ToAnthropic convert message to anthropic Message
func (Message) ToOpenAI ¶
func (m Message) ToOpenAI(dist *openai.ChatCompletionMessage)
ToOpenAI convert message to openai ChatCompletionMessage
type MessageRole ¶
type MessageRole = string
MessageRole is the role of the message sender (e.g., 'user', 'system', 'tool')
const ( SystemRole MessageRole = "system" UserRole MessageRole = "user" AssistantRole MessageRole = "assistant" ToolRole MessageRole = "tool" FunctionRole MessageRole = "function" )