session

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterHistoryStore

func RegisterHistoryStore(factory Factory)

Types

type Factory

type Factory interface {
	// Type unique type of the history store
	Type() string
	// Create relevant history store by type
	Create(options options.Config, chatEngineMode string) (History, error)
}

type History

type History interface {
	// AddAIMessage is a convenience method for adding an AI message string to
	// the store.
	AddAIMessage(ctx context.Context, sessionID, message string) error

	// AddUserMessage is a convenience method for adding a human message string
	// to the store.
	AddUserMessage(ctx context.Context, sessionID, message string) error

	// AddMessage adds a message to the store.
	AddMessage(ctx context.Context, sessionID string, message llms.ChatMessage) error

	// SetMessages replaces existing messages in the store
	SetMessages(ctx context.Context, sessionID string, messages []llms.ChatMessage) error

	// Messages retrieves all messages from the store
	Messages(ctx context.Context, sessionID string) ([]llms.ChatMessage, error)

	// Sessions retrieves all sessions id from the store
	Sessions(ctx context.Context) ([]string, error)

	// Clear removes all session from the store.
	Clear(ctx context.Context, sessionID string) error

	//Exists checks if the given chat session exists.
	Exists(ctx context.Context, sessionID string) (bool, error)
}

History is the interface for chat history session store.

func GetHistoryStore

func GetHistoryStore(cfg options.Config, chatEngineMode string) (History, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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