Documentation ¶
Index ¶
- type ChatMessageHistory
- func (h *ChatMessageHistory) AddAIMessage(ctx context.Context, sessionID, message string) error
- func (h *ChatMessageHistory) AddMessage(ctx context.Context, sessionID string, message llms.ChatMessage) error
- func (h *ChatMessageHistory) AddUserMessage(ctx context.Context, sessionID, message string) error
- func (h *ChatMessageHistory) Clear(ctx context.Context, sessionID string) error
- func (h *ChatMessageHistory) Exists(ctx context.Context, sessionID string) (bool, error)
- func (h *ChatMessageHistory) Messages(ctx context.Context, sessionID string) ([]llms.ChatMessage, error)
- func (h *ChatMessageHistory) Sessions(ctx context.Context) ([]string, error)
- func (h *ChatMessageHistory) SetMessages(ctx context.Context, sessionID string, messages []llms.ChatMessage) error
- type ChatMessageHistoryOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatMessageHistory ¶
type ChatMessageHistory struct {
// contains filtered or unexported fields
}
func NewMongoDBChatMessageSession ¶
func NewMongoDBChatMessageSession(ctx context.Context, options ...ChatMessageHistoryOption) (*ChatMessageHistory, error)
NewMongoDBChatMessageSession creates a new MongoDBChatMessageHistory using chat message options.
func (*ChatMessageHistory) AddAIMessage ¶
func (h *ChatMessageHistory) AddAIMessage(ctx context.Context, sessionID, message string) error
AddAIMessage adds an AIMessage to the chat message history.
func (*ChatMessageHistory) AddMessage ¶
func (h *ChatMessageHistory) AddMessage(ctx context.Context, sessionID string, message llms.ChatMessage) error
AddMessage adds a message to the store.
func (*ChatMessageHistory) AddUserMessage ¶
func (h *ChatMessageHistory) AddUserMessage(ctx context.Context, sessionID, message string) error
AddUserMessage adds a user to the chat message history.
func (*ChatMessageHistory) Clear ¶
func (h *ChatMessageHistory) Clear(ctx context.Context, sessionID string) error
Clear clear session memory from MongoDB.
func (*ChatMessageHistory) Messages ¶
func (h *ChatMessageHistory) Messages(ctx context.Context, sessionID string) ([]llms.ChatMessage, error)
Messages returns all messages stored.
func (*ChatMessageHistory) Sessions ¶
func (h *ChatMessageHistory) Sessions(ctx context.Context) ([]string, error)
Sessions retrieves all sessions id from the MongoDB.
func (*ChatMessageHistory) SetMessages ¶
func (h *ChatMessageHistory) SetMessages(ctx context.Context, sessionID string, messages []llms.ChatMessage) error
SetMessages replaces existing messages in the store.
type ChatMessageHistoryOption ¶
type ChatMessageHistoryOption func(m *ChatMessageHistory)
func WithChatEngineMode ¶
func WithChatEngineMode(chatEngineMode string) ChatMessageHistoryOption
WithChatEngineMode is an arbitrary key that is used to store the messages of a single chat session, like exec,chat etc. Must be set.
func WithCollectionName ¶
func WithCollectionName(name string) ChatMessageHistoryOption
WithCollectionName is an option for specifying the collection name.
func WithConnectionURL ¶
func WithConnectionURL(connectionURL string) ChatMessageHistoryOption
WithConnectionURL is an option for specifying the MongoDB connection URL. Must be set.
func WithDataBaseName ¶
func WithDataBaseName(name string) ChatMessageHistoryOption
WithDataBaseName is an option for specifying the database name.