mongo

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

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 NewMongoDBChatMessageHistory

func NewMongoDBChatMessageHistory(ctx context.Context, options ...ChatMessageHistoryOption) (*ChatMessageHistory, error)

NewMongoDBChatMessageHistory creates a new MongoDBChatMessageHistory 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

AddMessage adds a message to the store.

func (*ChatMessageHistory) AddUserMessage

func (h *ChatMessageHistory) AddUserMessage(ctx context.Context, text string) error

AddUserMessage adds a user to the chat message history.

func (*ChatMessageHistory) Clear

func (h *ChatMessageHistory) Clear(ctx context.Context) error

Clear clear session memory from MongoDB.

func (*ChatMessageHistory) Messages

func (h *ChatMessageHistory) Messages(ctx context.Context) ([]llms.ChatMessage, error)

Messages returns all messages stored.

func (*ChatMessageHistory) SetMessages

func (h *ChatMessageHistory) SetMessages(ctx context.Context, messages []llms.ChatMessage) error

SetMessages replaces existing messages in the store.

type ChatMessageHistoryOption

type ChatMessageHistoryOption func(m *ChatMessageHistory)

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.

func WithSessionID

func WithSessionID(sessionID string) ChatMessageHistoryOption

WithSessionID is an arbitrary key that is used to store the messages of a single chat session, like user name, email, chat id etc. Must be set.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL