Documentation ¶
Index ¶
- type ChatMessageHistory
- func (h *ChatMessageHistory) AddAIMessage(ctx context.Context, text string) error
- func (h *ChatMessageHistory) AddMessage(ctx context.Context, message llms.ChatMessage) error
- func (h *ChatMessageHistory) AddUserMessage(ctx context.Context, text string) error
- func (h *ChatMessageHistory) Clear(ctx context.Context) error
- func (h *ChatMessageHistory) Messages(ctx context.Context) ([]llms.ChatMessage, error)
- func (*ChatMessageHistory) SetMessages(_ context.Context, _ []llms.ChatMessage) error
- type ChatMessageHistoryOption
- type Memory
- func (m *Memory) Clear(ctx context.Context) error
- func (m *Memory) GetMemoryKey(context.Context) string
- func (m *Memory) LoadMemoryVariables(ctx context.Context, _ map[string]any) (map[string]any, error)
- func (m *Memory) MemoryVariables(context.Context) []string
- func (m *Memory) SaveContext(ctx context.Context, inputValues map[string]any, outputValues map[string]any) error
- type MemoryOption
- func WithAIPrefix(aiPrefix string) MemoryOption
- func WithHumanPrefix(humanPrefix string) MemoryOption
- func WithInputKey(inputKey string) MemoryOption
- func WithMemoryKey(memoryKey string) MemoryOption
- func WithMemoryType(memoryType zep.MemoryGetRequestMemoryType) MemoryOption
- func WithOutputKey(outputKey string) MemoryOption
- func WithReturnMessages(returnMessages bool) MemoryOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatMessageHistory ¶
type ChatMessageHistory struct { ZepClient *zepClient.Client SessionID string MemoryType zep.MemoryGetRequestMemoryType HumanPrefix string AIPrefix string }
ChatMessageHistory is a struct that stores chat messages.
func NewZepChatMessageHistory ¶
func NewZepChatMessageHistory(zep *zepClient.Client, sessionID string, options ...ChatMessageHistoryOption) *ChatMessageHistory
NewZepChatMessageHistory creates a new ZepChatMessageHistory using chat message options.
func (*ChatMessageHistory) AddAIMessage ¶
func (h *ChatMessageHistory) AddAIMessage(ctx context.Context, text string) error
AddAIMessage adds an AIMessage to the chat message history.
func (*ChatMessageHistory) AddMessage ¶
func (h *ChatMessageHistory) AddMessage(ctx context.Context, message llms.ChatMessage) error
func (*ChatMessageHistory) AddUserMessage ¶
func (h *ChatMessageHistory) AddUserMessage(ctx context.Context, text string) error
AddUserMessage adds a user to the chat message history.
func (*ChatMessageHistory) Messages ¶
func (h *ChatMessageHistory) Messages(ctx context.Context) ([]llms.ChatMessage, error)
Messages returns all messages stored.
func (*ChatMessageHistory) SetMessages ¶
func (*ChatMessageHistory) SetMessages(_ context.Context, _ []llms.ChatMessage) error
type ChatMessageHistoryOption ¶
type ChatMessageHistoryOption func(m *ChatMessageHistory)
ChatMessageHistoryOption is a function for creating new chat message history with other than the default values.
func WithChatHistoryAIPrefix ¶
func WithChatHistoryAIPrefix(aiPrefix string) ChatMessageHistoryOption
WithChatHistoryAIPrefix is an option for specifying the AI prefix. Will be passed as role for the message to zep.
func WithChatHistoryHumanPrefix ¶
func WithChatHistoryHumanPrefix(humanPrefix string) ChatMessageHistoryOption
WithChatHistoryHumanPrefix is an option for specifying the human prefix. Will be passed as role for the message to zep.
func WithChatHistoryMemoryType ¶
func WithChatHistoryMemoryType(memoryType zep.MemoryGetRequestMemoryType) ChatMessageHistoryOption
WithChatHistoryMemoryType specifies zep memory type.
type Memory ¶
type Memory struct { ChatHistory schema.ChatMessageHistory ReturnMessages bool InputKey string OutputKey string HumanPrefix string AIPrefix string MemoryKey string MemoryType zep.MemoryGetRequestMemoryType ZepClient *zepClient.Client SessionID string }
Memory is a simple form of memory that remembers previous conversational back and forth directly.
func NewMemory ¶
func NewMemory(client *zepClient.Client, sessionID string, options ...MemoryOption) *Memory
NewMemory is a function for crating a new buffer memory.
func (*Memory) LoadMemoryVariables ¶
func (m *Memory) LoadMemoryVariables( ctx context.Context, _ map[string]any, ) (map[string]any, error)
LoadMemoryVariables returns the previous chat messages stored in memory as well as a system message with conversation facts and most relevant summary. Previous chat messages are returned in a map with the key specified in the MemoryKey field. This key defaults to "history". If ReturnMessages is set to true the output is a slice of schema.ChatMessage. Otherwise, the output is a buffer string of the chat messages.
func (*Memory) MemoryVariables ¶
MemoryVariables gets the input key the buffer memory class will load dynamically.
func (*Memory) SaveContext ¶
func (m *Memory) SaveContext( ctx context.Context, inputValues map[string]any, outputValues map[string]any, ) error
SaveContext uses the input values to the llm to save a user message, and the output values of the llm to save an AI message. If the input or output key is not set, the input values or output values must contain only one key such that the function can know what string to add as a user and AI message. On the other hand, if the output key or input key is set, the input key must be a key in the input values and the output key must be a key in the output values. The values in the input and output values used to save a user and AI message must be strings.
type MemoryOption ¶
type MemoryOption func(b *Memory)
MemoryOption ZepMemoryOption is a function for creating new buffer with other than the default values.
func WithAIPrefix ¶
func WithAIPrefix(aiPrefix string) MemoryOption
WithAIPrefix is an option for specifying the AI prefix. Will be passed as role for the message to zep.
func WithHumanPrefix ¶
func WithHumanPrefix(humanPrefix string) MemoryOption
WithHumanPrefix is an option for specifying the human prefix. Will be passed as role for the message to zep.
func WithInputKey ¶
func WithInputKey(inputKey string) MemoryOption
WithInputKey is an option for specifying the input key.
func WithMemoryKey ¶
func WithMemoryKey(memoryKey string) MemoryOption
WithMemoryKey is an option for specifying the memory key.
func WithMemoryType ¶
func WithMemoryType(memoryType zep.MemoryGetRequestMemoryType) MemoryOption
WithMemoryType specifies zep memory type.
func WithOutputKey ¶
func WithOutputKey(outputKey string) MemoryOption
WithOutputKey is an option for specifying the output key.
func WithReturnMessages ¶
func WithReturnMessages(returnMessages bool) MemoryOption
WithReturnMessages is an option for specifying should it return messages.