Documentation
¶
Overview ¶
Package components includes AgentMemory etc.
Index ¶
- func NewTurnID() string
- type LLMResponse
- type LLMUsage
- type Memory
- func (m *Memory) AddMessage(msg *Message)
- func (m *Memory) Copy(src MemoryStore)
- 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() MemoryStore
- func (m *Memory) Reset() MemoryStore
- func (m *Memory) SetHistory(history []Message) *Memory
- func (m *Memory) SetMaxMessages(maxMessages int) *Memory
- func (m *Memory) SetTurnID(turnID string) MemoryStore
- func (m Memory) TurnID() string
- type MemoryStore
- type Message
- func (m Message) Attachement() *schema.Attachement
- func (m Message) Chunks() []schema.Schema
- func (m Message) Content() schema.Schema
- func (m Message) FileIDs() []string
- func (m Message) Files() []io.Reader
- func (m Message) ImageURLs() []string
- func (m *Message) Mode() instructor.Mode
- func (m *Message) Raw() any
- func (m *Message) RawContent() string
- func (m Message) Role() MessageRole
- func (m *Message) SetMode(mode instructor.Mode)
- func (m *Message) SetRaw(raw any)
- func (m *Message) SetRawContent(raw string)
- func (m *Message) SetTurnID(turnID string) *Message
- func (m *Message) StringifiedContent() string
- func (m Message) ToAnthropic(dist *anthropic.Message) []anthropic.Message
- func (m Message) ToCohere(dist *cohere.Message) []*cohere.Message
- func (m Message) ToGemini(dist *gemini.Content) []*gemini.Content
- func (m Message) ToOpenAI(dist *openai.ChatCompletionMessageParamUnion) []openai.ChatCompletionMessageParamUnion
- func (m Message) TryAttachChunkPrompt(idx int) string
- func (m Message) TurnID() string
- type MessageRole
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type LLMResponse ¶ added in v1.1.0
type LLMResponse struct {
ID string `json:"id,omitempty"`
Role MessageRole `json:"role,omitempty"`
Model string `json:"model,omitempty"`
Usage *LLMUsage `json:"usage,omitempty"`
Timestamp int64 `json:"ts,omitempty"`
Details any `json:"content,omitempty"`
}
LLMResponse instructor provider chat response
func (*LLMResponse) FromAnthropic ¶ added in v1.1.0
func (r *LLMResponse) FromAnthropic(v *anthropic.MessagesResponse)
FromAnthropic convert response from anthropic
func (*LLMResponse) FromCohere ¶ added in v1.1.0
func (r *LLMResponse) FromCohere(v *cohere.NonStreamedChatResponse)
FromCohere convert response from cohere
func (*LLMResponse) FromGemini ¶ added in v1.1.0
func (r *LLMResponse) FromGemini(v *gemini.GenerateContentResponse)
func (*LLMResponse) FromOpenAI ¶ added in v1.1.0
func (r *LLMResponse) FromOpenAI(v *openai.ChatCompletion)
FromOpenAI convnert response from openai
type LLMUsage ¶ added in v1.1.0
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
Memory Manages the chat history for an AI agent. threadsafe
func (*Memory) AddMessage ¶ added in v1.2.3
func (*Memory) Copy ¶
func (m *Memory) Copy(src MemoryStore)
Copy creates a copy of the chat memory.
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) NewTurn ¶
func (m *Memory) NewTurn() MemoryStore
NewTurn initializes a new turn by generating a random turn ID.
func (*Memory) Reset ¶ added in v1.0.1
func (m *Memory) Reset() MemoryStore
func (*Memory) SetHistory ¶
SetHistory set a copy of chat history
func (*Memory) SetMaxMessages ¶
SetMaxMessages set the max number of messages
func (*Memory) SetTurnID ¶
func (m *Memory) SetTurnID(turnID string) MemoryStore
SetTurnID set the current turn ID
type MemoryStore ¶ added in v1.1.9
type MemoryStore interface {
MaxMessages() int
TurnID() string
NewTurn() MemoryStore
NewMessage(MessageRole, schema.Schema) *Message
AddMessage(msg *Message)
History() []Message
Reset() MemoryStore
Copy(MemoryStore)
MessageCount() int
}
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) Mode ¶ added in v1.3.4
func (m *Message) Mode() instructor.Mode
func (*Message) RawContent ¶ added in v1.5.9
func (*Message) SetMode ¶ added in v1.3.4
func (m *Message) SetMode(mode instructor.Mode)
func (*Message) SetRawContent ¶ added in v1.5.9
func (*Message) StringifiedContent ¶ added in v1.3.4
func (Message) ToAnthropic ¶
ToAnthropic convert message to anthropic Message
func (Message) ToOpenAI ¶
func (m Message) ToOpenAI(dist *openai.ChatCompletionMessageParamUnion) []openai.ChatCompletionMessageParamUnion
ToOpenAI convert message to openai ChatCompletionMessage
func (Message) TryAttachChunkPrompt ¶ added in v1.2.1
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" )
Directories
¶
| Path | Synopsis |
|---|---|
|
Package document contains Document structs and Parsers prepare for RAG
|
Package document contains Document structs and Parsers prepare for RAG |
|
parsers
Package parsers include different parsers implementation
|
Package parsers include different parsers implementation |
|
parsers/docx
Package docx a parser for docx
|
Package docx a parser for docx |
|
parsers/html
Package html a parser for html
|
Package html a parser for html |
|
parsers/pdf
Package pdf a parser for PDF
|
Package pdf a parser for PDF |
|
parsers/pptx
Package pptx a Parser for pptx
|
Package pptx a Parser for pptx |
|
parsers/xlsx
Package xlsx a xlsx parser
|
Package xlsx a xlsx parser |
|
Package embedder contains Embedder interface and different providers including openai, voyageai, coheren, gemini and huggingface, etc.
|
Package embedder contains Embedder interface and different providers including openai, voyageai, coheren, gemini and huggingface, etc. |
|
splitter
Package splitter defines different chunker spliters
|
Package splitter defines different chunker spliters |
|
Package optimizer provides prompt optimization capabilities for Language Learning Models.
|
Package optimizer provides prompt optimization capabilities for Language Learning Models. |
|
Package systemprompt contains system prompt generator and context provider
|
Package systemprompt contains system prompt generator and context provider |
|
Package vectordb contains vectordb interface and different engines like memory, chromem and milvus implementations.
|
Package vectordb contains vectordb interface and different engines like memory, chromem and milvus implementations. |