sessions

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IDLE       = "idle"
	PROCESSING = "processing"
	ERROR      = "error"
)

Variables

This section is empty.

Functions

func ConstructListItems

func ConstructListItems(sessions []Session, currentSessionId int) []list.Item

func RenderBotMessage

func RenderBotMessage(msg string, width int) string

func RenderUserMessage

func RenderUserMessage(msg string, width int) string

func SendFinalProcessMessage

func SendFinalProcessMessage(msg string) tea.Cmd

func SendUpdateCurrentSessionMsg

func SendUpdateCurrentSessionMsg() tea.Cmd

Types

type Choice

type Choice struct {
	Index        int                    `json:"index"`
	Delta        map[string]interface{} `json:"delta"`
	FinishReason string                 `json:"finish_reason"`
}

type CompletionChunk

type CompletionChunk struct {
	ID               string   `json:"id"`
	Object           string   `json:"object"`
	Created          int      `json:"created"`
	Model            string   `json:"model"`
	SystemFingerpint string   `json:"system_fingerprint"`
	Choices          []Choice `json:"choices"`
}

type CompletionResponse

type CompletionResponse struct {
	Data CompletionChunk `json:"data"`
}

type FinalProcessMessage

type FinalProcessMessage struct {
	FinalMessage string
}

Final Message is the concatenated string from the chat gpt stream

type LoadDataFromDB

type LoadDataFromDB struct {
	// contains filtered or unexported fields
}

type MessageToSend

type MessageToSend struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

func ConstructUserMessage

func ConstructUserMessage(content string) MessageToSend

type Model

type Model struct {
	Settings           settings.Settings
	CurrentSessionID   int
	CurrentSessionName string

	ArrayOfProcessResult []ProcessResult
	ArrayOfMessages      []MessageToSend
	CurrentAnswer        string
	AllSessions          []Session
	ProcessingMode       string
	// contains filtered or unexported fields
}

func New

func New(db *sql.DB, ctx context.Context) Model

func (*Model) CallChatGpt

func (m *Model) CallChatGpt(resultChan chan ProcessResult) tea.Cmd

func (Model) GetLatestBotMessage

func (m Model) GetLatestBotMessage() (string, error)

func (Model) GetMessagesAsPrettyString

func (m Model) GetMessagesAsPrettyString() string

func (Model) GetMessagesAsString

func (m Model) GetMessagesAsString() string

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) Update

func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)

func (Model) View

func (m Model) View() string

type ProcessResult

type ProcessResult struct {
	ID     int
	Result CompletionChunk // or whatever type you need
	Err    error
	Final  bool
}

Define a type for the data you want to return, if needed

type Session

type Session struct {
	ID          int
	Messages    []MessageToSend
	CreatedAt   string
	SessionName string
}

type SessionService

type SessionService struct {
	DB *sql.DB
}

func NewSessionService

func NewSessionService(db *sql.DB) *SessionService

func (*SessionService) DeleteSession

func (ss *SessionService) DeleteSession(id int) error

func (*SessionService) GetAllSessions

func (ss *SessionService) GetAllSessions() ([]Session, error)

get me all the sessions

func (*SessionService) GetMostRecessionSessionOrCreateOne

func (ss *SessionService) GetMostRecessionSessionOrCreateOne() (Session, error)

func (*SessionService) GetSession

func (ss *SessionService) GetSession(id int) (Session, error)

func (*SessionService) InsertNewSession

func (ss *SessionService) InsertNewSession(name string, messages []MessageToSend) (Session, error)

func (*SessionService) UpdateSessionMessages

func (ss *SessionService) UpdateSessionMessages(id int, messages []MessageToSend) error

func (*SessionService) UpdateSessionName

func (ss *SessionService) UpdateSessionName(id int, name string) error

type UpdateCurrentSession

type UpdateCurrentSession struct{}

Jump to

Keyboard shortcuts

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