chat

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2024 License: MIT Imports: 10 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 interface {
	// GetID returns the unique identifier of the conversation.
	GetID() string

	// GetCreatedAt returns the time when the conversation was created.
	GetCreatedAt() time.Time

	// GetMessages returns all messages in the conversation, ordered by creation date.
	GetMessages() []Message

	// RemoveMessage deletes a message from the conversation by its ID.
	RemoveMessage(id uuid.UUID)

	// AddMessage appends a new message to the conversation.
	AddMessage(message Message)

	// WithPrompt attaches a prompt to the conversation.
	WithPrompt(prompt prompts.Prompt)

	// Reset clears the conversation but retains system messages.
	Reset() (Conversation, error)

	// Clean removes all messages from the conversation, including system messages.
	Clean() (Conversation, error)
}

func NewStackedConversation

func NewStackedConversation(
	repo Repository,
) Conversation

type Message

type Message struct {
	ID        uuid.UUID `json:"id"`
	Role      Role      `json:"role"`
	Content   string    `json:"content"`
	CreatedAt time.Time `json:"created_at"`
	IsFile    bool      `json:"is_file"`
}

func NewFileMessage

func NewFileMessage(role Role, content string) Message

func NewMessage

func NewMessage(role Role, content string) Message

type Repository

type Repository interface {
	SaveConversation(conversation Conversation) error
	LoadConversation(id string) (Conversation, error)
	DeleteConversation(id string) error

	GetConversations() ([]Conversation, error)

	Close() error
}

func NewSQLiteRepository

func NewSQLiteRepository(dbPath string) (Repository, error)

type Role

type Role string
const (
	RoleSystem    Role = "system"
	RoleUser      Role = "user"
	RoleAssistant Role = "assistant"
)

func (Role) String

func (r Role) String() string

Jump to

Keyboard shortcuts

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