chat

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 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() string
	GetCreatedAt() time.Time
	GetMessages() []Message

	RemoveMessage(id uuid.UUID)
	AddMessage(message Message)

	WithPrompt(prompt prompts.Prompt)

	Reset() Conversation
}

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