Documentation ¶
Index ¶
- Variables
- func CenterString(str string, width int, color lipgloss.Color) string
- func DecodeGob(r io.Reader, messages *[]ChatMessage) error
- func EncodeGob(w io.Writer, messages *[]ChatMessage) error
- func GenerateChatID() string
- func NewChatSettingsForm() (client.Chat, error)
- type Chat
- type ChatMessage
- type ContentType
- type CopyType
- type FinishedStreaming
- type KeyMap
- type StreamChunk
- type Type
Constants ¶
This section is empty.
Variables ¶
var ( LEFT_HALF_CIRCLE string = string(0xe0b6) RIGHT_HALF_CIRCLE string = string(0xe0b4) BORDER_TOP_LEFT string = string(0x256d) BORDER_TOP_RIGHT string = string(0x256e) BORDER_HORIZONTAL string = string(0x2500) )
var DisabledHighlightStyle = lipgloss.NewStyle(). Foreground(gray). Bold(true)
var HighlightActiveStyle = lipgloss.NewStyle(). Background(teal). Foreground(black). Bold(true). Padding(0, 1)
var HighlightForegroundStyle = lipgloss.NewStyle(). Foreground(purple). Bold(true)
var HighlightStyle = lipgloss.NewStyle(). Background(purple). Bold(true). Padding(0, 1)
var Keys = KeyMap{ Up: key.NewBinding( key.WithKeys("ctrl+up", "k"), key.WithHelp("ctrl+↑", "Move view up"), ), Down: key.NewBinding( key.WithKeys("ctrl+down", "j"), key.WithHelp("ctrl+↓", "Move view down"), ), HalfPageUp: key.NewBinding( key.WithKeys("ctrl+u"), key.WithHelp("ctrl+u", "Half page up"), ), HalfPageDown: key.NewBinding( key.WithKeys("ctrl+d"), key.WithHelp("ctrl+d", "Half page down"), ), HighlightPreviousMessage: key.NewBinding( key.WithKeys("ctrl+p"), key.WithHelp("ctrl+p", "Previous message"), ), HighlightNextMessage: key.NewBinding( key.WithKeys("ctrl+n"), key.WithHelp("ctrl+n", "Next message"), ), CopyLastResponse: key.NewBinding( key.WithKeys("ctrl+y"), key.WithHelp("ctrl+y", "Copy last response"), ), CopyHighlightedMessage: key.NewBinding( key.WithKeys("alt+y"), key.WithHelp("alt+y", "Copy highlighted message"), ), ToggleImagePicker: key.NewBinding( key.WithKeys("ctrl+o"), key.WithHelp("ctrl+o", "Toggle image picker"), ), RemoveAttachment: key.NewBinding( key.WithKeys("ctrl+x"), key.WithHelp("ctrl+x", "Remove attachment"), ), ToggleHelp: key.NewBinding( key.WithKeys("ctrl+h"), key.WithHelp("ctrl+h", "Toggle help"), ), Quit: key.NewBinding( key.WithKeys("ctrl+c"), key.WithHelp("ctrl+c", "Exit chat"), ), }
var NotificationStyle = lipgloss.NewStyle(). Background(notif). Foreground(black). Bold(true). Padding(0, 1)
var RoundedBorder = lipgloss.NewStyle(). BorderStyle(lipgloss.RoundedBorder())
Functions ¶
func CenterString ¶
Helper function to center a string within a given width (top rounded border)
func DecodeGob ¶
func DecodeGob(r io.Reader, messages *[]ChatMessage) error
Decodes the gob-encoded messages from the reader and stores them in the provided messages slice
func EncodeGob ¶
func EncodeGob(w io.Writer, messages *[]ChatMessage) error
Encodes the provided messages to gob format and writes it to the writer
func GenerateChatID ¶
func GenerateChatID() string
Generates a unique chat ID using the UUID Version 4 algorithm
func NewChatSettingsForm ¶
Huh form for creating a new chat, returns the new chat settings TODO: add more Ollama settings and sliders (temperature, max tokens, etc.)
Types ¶
type Chat ¶
type Chat struct { Glamour *glamour.TermRenderer ChatHistory []ChatMessage ChatSettings client.Chat // contains filtered or unexported fields }
func NewChat ¶
Creates a new Chat instance with the provided chat settings Loads the chat history from the database if it exists Sets up the chat's viewport, prompt form, and image picker Sets default values for the chat settings if they don't exist
func (*Chat) CopyToClipboard ¶ added in v0.1.11
Helper function to copy the provided content to the clipboard Shows a notification with the copied content
func (*Chat) ImagePickerView ¶
func (*Chat) Init ¶
Initializes the chat by resetting the prompt and image picker Sets the chat's width and height based on the terminal size (initial)
type ChatMessage ¶
type ContentType ¶
type ContentType string
type FinishedStreaming ¶
type FinishedStreaming bool
type KeyMap ¶ added in v0.1.11
type KeyMap struct { Up key.Binding // ctrl+up Down key.Binding // ctrl+down HalfPageUp key.Binding // ctrl+u HalfPageDown key.Binding // ctrl+d HighlightPreviousMessage key.Binding // ctrl+p HighlightNextMessage key.Binding // ctrl+n CopyHighlightedMessage key.Binding // alt+c CopyLastResponse key.Binding // ctrl+shift+c ToggleImagePicker key.Binding // ctrl+o RemoveAttachment key.Binding // ctrl+x ToggleHelp key.Binding // ctrl+h Quit key.Binding // ctrl+c FullHelpKeys [][]key.Binding }
func (*KeyMap) DefaultFullHelpKeys ¶ added in v0.1.11
func (*KeyMap) DefaultFullHelpKeysNonMultiModal ¶ added in v1.0.0
func (KeyMap) FullHelp ¶ added in v0.1.11
FullHelp returns keybindings for the expanded help view. It's part of the key.Map interface.
func (*KeyMap) SetFullHelpKeys ¶ added in v0.1.11
type StreamChunk ¶
type StreamChunk string