Documentation
¶
Index ¶
- Constants
- type SqliteChatMessageHistoryOption
- func WithContext(ctx context.Context) SqliteChatMessageHistoryOption
- func WithConversation(convoID string) SqliteChatMessageHistoryOption
- func WithDB(db *sqlx.DB) SqliteChatMessageHistoryOption
- func WithDBAddress(addr string) SqliteChatMessageHistoryOption
- func WithDataPath(path string) SqliteChatMessageHistoryOption
- type SqliteStore
- func (s SqliteStore) CleanContexts(ctx context.Context, conversationID string) (int64, error)
- func (h *SqliteStore) ClearConversations(ctx context.Context) error
- func (h *SqliteStore) Close() error
- func (h *SqliteStore) ConversationExists(ctx context.Context, id string) (bool, error)
- func (s SqliteStore) DeleteContexts(ctx context.Context, id uint64) error
- func (h *SqliteStore) DeleteConversation(ctx context.Context, id string) error
- func (s SqliteStore) GetContext(ctx context.Context, id uint64) (*convo.LoadContext, error)
- func (h *SqliteStore) GetConversation(ctx context.Context, id string) (*convo.Conversation, error)
- func (h *SqliteStore) LatestConversation(ctx context.Context) (*convo.Conversation, error)
- func (s SqliteStore) ListContextsByteConvoID(ctx context.Context, conversationID string) ([]convo.LoadContext, error)
- func (h *SqliteStore) ListConversations(ctx context.Context) ([]convo.Conversation, error)
- func (h *SqliteStore) ListConversationsOlderThan(ctx context.Context, t time.Duration) ([]convo.Conversation, error)
- func (s SqliteStore) SaveContext(ctx context.Context, lc *convo.LoadContext) error
- func (h *SqliteStore) SaveConversation(ctx context.Context, id, title, model string) error
Constants ¶
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 ¶
func WithContext(ctx context.Context) SqliteChatMessageHistoryOption
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 ¶
func WithDB(db *sqlx.DB) SqliteChatMessageHistoryOption
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 (*SqliteStore) ClearConversations ¶
func (h *SqliteStore) ClearConversations(ctx context.Context) error
ClearConversations resets messages.
func (*SqliteStore) Close ¶
func (h *SqliteStore) Close() error
func (*SqliteStore) ConversationExists ¶
ConversationExists checks if the given chat convo exists.
func (SqliteStore) DeleteContexts ¶
func (*SqliteStore) DeleteConversation ¶
func (h *SqliteStore) DeleteConversation(ctx context.Context, id string) error
func (SqliteStore) GetContext ¶
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 (*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