sqlite3

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultSchema = `` /* 936-byte string literal not displayed */

DefaultSchema sets a default schema to be run after connecting.

Variables

This section is empty.

Functions

This section is empty.

Types

type SqliteChatMessageHistoryOption

type SqliteChatMessageHistoryOption func(m *SqliteStore)

SqliteChatMessageHistoryOption is a function for creating new chat message convo with other than the default values.

func WithContext

WithContext is an option for NewSqliteChatMessageHistory to use a context internally when running Schema.

func WithConversation

func WithConversation(convoID string) SqliteChatMessageHistoryOption

WithConversation is an option for NewSqliteChatMessageHistory for setting a session name or ConvoID for the convo.

func WithDB

WithDB is an option for NewSqliteChatMessageHistory for adding a database connection.

func WithDBAddress

func WithDBAddress(addr string) SqliteChatMessageHistoryOption

WithDBAddress is an option for NewSqliteChatMessageHistory for specifying an address or file path for when connecting the db.

func WithDataPath

func WithDataPath(path string) SqliteChatMessageHistoryOption

WithDataPath is an option for NewSqliteChatMessageHistory for setting a path to the data directory.

type SqliteStore

type SqliteStore struct {
	// DB is the database connection.
	DB *sqlx.DB
	// Ctx is a context that can be used for the schema exec.
	Ctx context.Context
	// DBAddress is the address or file path for connecting the db.
	DBAddress string
	// ConvoID defines a session name or ConvoID for a convo.
	ConvoID string
	// DataPath is the path to the data directory.
	DataPath string

	*convo.SimpleChatHistoryStore
	// contains filtered or unexported fields
}

func NewSqliteStore

func NewSqliteStore(options ...SqliteChatMessageHistoryOption) *SqliteStore

func (SqliteStore) CleanContexts

func (s SqliteStore) CleanContexts(ctx context.Context, conversationID string) (int64, error)

func (*SqliteStore) ClearConversations

func (h *SqliteStore) ClearConversations(ctx context.Context) error

ClearConversations resets messages.

func (*SqliteStore) Close

func (h *SqliteStore) Close() error

func (*SqliteStore) ConversationExists

func (h *SqliteStore) ConversationExists(ctx context.Context, id string) (bool, error)

ConversationExists checks if the given chat convo exists.

func (SqliteStore) DeleteContexts

func (s SqliteStore) DeleteContexts(ctx context.Context, id uint64) error

func (*SqliteStore) DeleteConversation

func (h *SqliteStore) DeleteConversation(ctx context.Context, id string) error

func (SqliteStore) GetContext

func (s SqliteStore) GetContext(ctx context.Context, id uint64) (*convo.LoadContext, error)

func (*SqliteStore) GetConversation

func (h *SqliteStore) GetConversation(ctx context.Context, id string) (*convo.Conversation, error)

GetConversation retrieves a convo from the store

func (*SqliteStore) LatestConversation

func (h *SqliteStore) LatestConversation(ctx context.Context) (*convo.Conversation, error)

LatestConversation returns the last message in the chat convo.

func (SqliteStore) ListContextsByteConvoID

func (s SqliteStore) ListContextsByteConvoID(ctx context.Context, conversationID string) ([]convo.LoadContext, error)

func (*SqliteStore) ListConversations

func (h *SqliteStore) ListConversations(ctx context.Context) ([]convo.Conversation, error)

ListConversations retrieves all convo ConvoID from the store

func (*SqliteStore) ListConversationsOlderThan

func (h *SqliteStore) ListConversationsOlderThan(ctx context.Context, t time.Duration) ([]convo.Conversation, error)

ListConversationsOlderThan retrieves all convo ConvoID from the store that are older than the given time.

func (SqliteStore) SaveContext

func (s SqliteStore) SaveContext(ctx context.Context, lc *convo.LoadContext) error

func (*SqliteStore) SaveConversation

func (h *SqliteStore) SaveConversation(ctx context.Context, id, title, model string) error

Jump to

Keyboard shortcuts

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