chat

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2024 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DisabledHighlightStyle = lipgloss.NewStyle().
	Foreground(gray).
	Bold(true)
View Source
var HighlightActiveStyle = lipgloss.NewStyle().
	Background(teal).
	Foreground(black).
	Bold(true).
	Padding(0, 1)
View Source
var HighlightForegroundStyle = lipgloss.NewStyle().
	Foreground(purple).
	Bold(true)
View Source
var HighlightStyle = lipgloss.NewStyle().
	Background(purple).
	Bold(true).
	Padding(0, 1)
View Source
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"),
	),
}
View Source
var NotificationStyle = lipgloss.NewStyle().
	Background(notif).
	Foreground(black).
	Bold(true).
	Padding(0, 1)
View Source
var RoundedBorder = lipgloss.NewStyle().
	BorderStyle(lipgloss.RoundedBorder())

Functions

func CenterString

func CenterString(str string, width int, color lipgloss.Color) string

func DecodeGob

func DecodeGob(r io.Reader, messages *[]ChatMessage) error

func EncodeGob

func EncodeGob(w io.Writer, messages *[]ChatMessage) error

func GenerateChatID

func GenerateChatID() string

func NewChatSettingsForm

func NewChatSettingsForm() (client.Chat, error)

Types

type Chat

type Chat struct {
	Glamour *glamour.TermRenderer

	ChatHistory  []ChatMessage
	ChatSettings client.Chat
	// contains filtered or unexported fields
}

func NewChat

func NewChat(chatSettings client.Chat) *Chat

func (*Chat) CopyToClipboard added in v0.1.11

func (chat *Chat) CopyToClipboard(content string, copyType CopyType) tea.Cmd

func (*Chat) ImagePickerView

func (m *Chat) ImagePickerView() string

func (*Chat) Init

func (chat *Chat) Init() tea.Cmd

func (*Chat) Resize

func (chat *Chat) Resize() tea.Cmd

func (*Chat) Update

func (chat *Chat) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*Chat) View

func (chat *Chat) View() string

type ChatMessage

type ChatMessage struct {
	CreatedAt time.Time
	Role      string
	Message   string
	Images    []string
}

type ContentType

type ContentType string

type CopyType added in v0.1.11

type CopyType string
const (
	CopyLastResponse CopyType = "CopyLastResponse"
	CopyHighlighted  CopyType = "CopyHighlighted"
)

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 (k *KeyMap) DefaultFullHelpKeys() [][]key.Binding

func (KeyMap) FullHelp added in v0.1.11

func (k KeyMap) FullHelp() [][]key.Binding

FullHelp returns keybindings for the expanded help view. It's part of the key.Map interface.

func (*KeyMap) SetFullHelpKeys added in v0.1.11

func (k *KeyMap) SetFullHelpKeys(keys [][]key.Binding)

func (KeyMap) ShortHelp added in v0.1.11

func (k KeyMap) ShortHelp() []key.Binding

ShortHelp returns keybindings to be shown in the mini help view. It's part of the key.Map interface.

type StreamChunk

type StreamChunk string

type Type

type Type string

Jump to

Keyboard shortcuts

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