persistence

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conversation

type Conversation struct {
	Id       int64
	Messages []Message
}

type DatabaseClient

type DatabaseClient struct {
	Conn *sql.DB
}

func StartClient

func StartClient(projectPath string) (DatabaseClient, error)

func (*DatabaseClient) FetchRecentConversation

func (c *DatabaseClient) FetchRecentConversation() (
	Conversation,
	error,
)

Simply fetches the conversation that was created most recently.

func (*DatabaseClient) InitializeConversation

func (c *DatabaseClient) InitializeConversation() (
	Conversation,
	error,
)

Creates an empty conversation in the database.

func (*DatabaseClient) InsertMessageIntoConversation

func (c *DatabaseClient) InsertMessageIntoConversation(
	conversationId int64,
	role string,
	content string,
) (Message, error)

func (*DatabaseClient) PruneOldConversations

func (c *DatabaseClient) PruneOldConversations(maxHistory int) error

func (*DatabaseClient) WriteToMessage

func (c *DatabaseClient) WriteToMessage(messageId int64, text string) error

Extends the existing content of a message with the provided text (used for recording streaming responses from an LLM chat).

type Message

type Message struct {
	Id      int64
	Role    string
	Content string
}

Jump to

Keyboard shortcuts

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