Documentation
¶
Index ¶
- Variables
- func InitialModel(backend Backend, options ...ModelOption) model
- func OpenTTY() (io.ReadWriteCloser, error)
- type AppendInputTextMsg
- type Backend
- type BackendFinishedMsg
- type BlurInputMsg
- type BorderColors
- type CancelCompletionMsg
- type CopyLastResponseToClipboardMsg
- type CopyLastSourceBlocksToClipboardMsg
- type CopySourceBlocksToClipboardMsg
- type CopyToClipboardMsg
- type DismissErrorMsg
- type ErrorMsg
- type FocusMessageMsg
- type GetInputTextMsg
- type InputTextMsg
- type KeyMap
- type ModelOption
- type PrependInputTextMsg
- type QuitMsg
- type ReplaceInputTextMsg
- type SaveToFileMsg
- type SelectNextMessageMsg
- type SelectPrevMessageMsg
- type StartBackendMsg
- type State
- type Status
- type Style
- type SubmitMessageMsg
- type ToggleHelpMsg
- type TriggerWeatherToolMsg
- type TriggerWebSearchToolMsg
- type UnblurInputMsg
- type UnfocusMessageMsg
- type UserActionMsg
Constants ¶
This section is empty.
Variables ¶
var DefaultKeyMap = KeyMap{ SelectPrevMessage: key.NewBinding( key.WithKeys("shift+up"), key.WithHelp("shift+↑", "move up")), SelectNextMessage: key.NewBinding( key.WithKeys("shift+down"), key.WithHelp("shift+↓", "move down"), ), UnfocusMessage: key.NewBinding( key.WithKeys("esc", "ctrl+g"), key.WithHelp("esc", "unfocus message"), ), FocusMessage: key.NewBinding( key.WithKeys("enter"), key.WithHelp("enter", "focus message"), ), SubmitMessage: key.NewBinding( key.WithKeys("tab"), key.WithHelp("tab", "submit message"), ), CancelCompletion: key.NewBinding( key.WithKeys("esc", "ctrl+g"), key.WithHelp("esc", "cancel completion"), ), DismissError: key.NewBinding( key.WithKeys("esc", "ctrl+g"), key.WithHelp("esc", "dismiss error"), ), SaveToFile: key.NewBinding( key.WithKeys("ctrl+s", "alt+s"), key.WithHelp("ctrl+s", "save to file"), ), CopyToClipboard: key.NewBinding( key.WithKeys("alt+c"), key.WithHelp("alt+c", "copy selected"), ), CopyLastResponseToClipboard: key.NewBinding( key.WithKeys("alt+l"), key.WithHelp("alt+l", "copy response"), ), CopySourceBlocksToClipboard: key.NewBinding( key.WithKeys("alt+d"), key.WithHelp("alt+d", "copy selected source"), ), CopyLastSourceBlocksToClipboard: key.NewBinding( key.WithKeys("alt+k"), key.WithHelp("alt+k", "copy source"), ), ScrollUp: key.NewBinding( key.WithKeys("pgup"), key.WithHelp("pgup", "page up"), ), ScrollDown: key.NewBinding( key.WithKeys("pgdown"), key.WithHelp("pgdown", "page down"), ), Quit: key.NewBinding( key.WithKeys("alt+q"), key.WithHelp("alt+q", "quit"), ), Help: key.NewBinding( key.WithKeys("ctrl-?"), key.WithHelp("ctrl-?", "help")), PreviousConversationThread: key.NewBinding( key.WithKeys("left"), key.WithHelp("left", "previous conversation thread"), ), NextConversationThread: key.NewBinding( key.WithKeys("right"), key.WithHelp("right", "next conversation thread"), ), TriggerWeatherTool: key.NewBinding( key.WithKeys("alt+w"), key.WithHelp("alt+w", "demo weather tool"), ), TriggerWebSearchTool: key.NewBinding( key.WithKeys("alt+s"), key.WithHelp("alt+s", "demo web search tool"), ), }
Functions ¶
func InitialModel ¶
func InitialModel(backend Backend, options ...ModelOption) model
func OpenTTY ¶
func OpenTTY() (io.ReadWriteCloser, error)
Types ¶
type AppendInputTextMsg ¶ added in v0.0.11
type AppendInputTextMsg struct {
Text string
}
type Backend ¶
type Backend interface {
// Start begins the backend process with the provided context and prompt string.
// Implementations should stream results back to the program via tea messages.
Start(ctx context.Context, prompt string) (tea.Cmd, error)
// Interrupt signals the backend process to gracefully stop its current operation.
Interrupt()
// Kill forces the backend process to terminate immediately. This is used in
// situations where an immediate halt of the backend process is required, such as
// when the application is closing or an unrecoverable error has occurred.
Kill()
// IsFinished checks if the backend process has completed its tasks. It returns
// true if the backend has finished processing and no further Stream*Msg messages
// will be sent to the UI.
IsFinished() bool
}
Backend abstracts initiating and stopping the backend process that is responsible for producing chat completions and other UI updates.
Communication between the backend and the chat UI is now timeline-centric: implementions should inject timeline lifecycle events directly into the Bubble Tea program using tea.Program.Send:
- timeline.UIEntityCreated to create entities (e.g., assistant llm_text, tool_call)
- timeline.UIEntityUpdated to stream text or update properties
- timeline.UIEntityCompleted to finish an entity
- timeline.UIEntityDeleted when removing an entity
The chat model consumes these events and renders the timeline accordingly.
Typical flow:
- The UI invokes Start(ctx, prompt).
- Backend sends UIEntityCreated for an assistant message, then multiple UIEntityUpdated with an increasing Version to stream text, followed by UIEntityCompleted.
- When the backend finishes, it sends BackendFinishedMsg so the UI can unblur input.
type BackendFinishedMsg ¶ added in v0.0.4
type BackendFinishedMsg struct{}
BackendFinishedMsg is a message sent when the backend process has finished its operation.
type BlurInputMsg ¶ added in v0.0.25
type BlurInputMsg struct{}
Blur and Unblur input control messages
type BorderColors ¶
type CancelCompletionMsg ¶ added in v0.0.11
type CancelCompletionMsg struct{}
type CopyLastResponseToClipboardMsg ¶ added in v0.0.11
type CopyLastResponseToClipboardMsg struct{}
type CopyLastSourceBlocksToClipboardMsg ¶ added in v0.0.11
type CopyLastSourceBlocksToClipboardMsg struct{}
type CopySourceBlocksToClipboardMsg ¶ added in v0.0.11
type CopySourceBlocksToClipboardMsg struct{}
type CopyToClipboardMsg ¶ added in v0.0.11
type CopyToClipboardMsg struct{}
type DismissErrorMsg ¶ added in v0.0.11
type DismissErrorMsg struct{}
type FocusMessageMsg ¶ added in v0.0.11
type FocusMessageMsg struct{}
type GetInputTextMsg ¶ added in v0.0.11
type GetInputTextMsg struct{}
type InputTextMsg ¶ added in v0.0.11
type InputTextMsg struct {
Text string
}
type KeyMap ¶
type KeyMap struct {
SelectPrevMessage key.Binding `keymap-mode:"moving-around"`
SelectNextMessage key.Binding `keymap-mode:"moving-around"`
UnfocusMessage key.Binding `keymap-mode:"user-input"`
FocusMessage key.Binding `keymap-mode:"moving-around"`
SubmitMessage key.Binding `keymap-mode:"user-input"`
ScrollUp key.Binding
ScrollDown key.Binding
CancelCompletion key.Binding `keymap-mode:"stream-completion"`
DismissError key.Binding `keymap-mode:"error"`
LoadFromFile key.Binding
Regenerate key.Binding `keymap-mode:"user-input"`
RegenerateFromHere key.Binding `keymap-mode:"moving-around"`
EditMessage key.Binding `keymap-mode:"moving-around"`
PreviousConversationThread key.Binding `keymap-mode:"moving-around"`
NextConversationThread key.Binding `keymap-mode:"moving-around"`
SaveToFile key.Binding `keymap-mode:"*"`
SaveSourceBlocksToFile key.Binding `keymap-mode:"*"`
CopyToClipboard key.Binding `keymap-mode:"moving-around"`
CopyLastResponseToClipboard key.Binding `keymap-mode:"user-input"`
CopyLastSourceBlocksToClipboard key.Binding `keymap-mode:"user-input"`
CopySourceBlocksToClipboard key.Binding `keymap-mode:"moving-around"`
Help key.Binding `keymap-mode:"*"`
// demo triggers for tool calls
TriggerWeatherTool key.Binding `keymap-mode:"user-input"`
TriggerWebSearchTool key.Binding `keymap-mode:"user-input"`
Quit key.Binding `keymap-mode:"*"`
}
type ModelOption ¶ added in v0.0.4
type ModelOption func(*model)
func WithAutoStartBackend ¶ added in v0.0.13
func WithAutoStartBackend(autoStartBackend bool) ModelOption
func WithExternalInput ¶ added in v0.0.25
func WithExternalInput(enabled bool) ModelOption
WithExternalInput turns the chat model into a reusable timeline shell by hiding the built-in input widget. The host should control input text and submission via messages.
func WithStatus ¶ added in v0.0.11
func WithStatus(status *Status) ModelOption
func WithTimelineRegister ¶ added in v0.0.25
func WithTimelineRegister(hook func(*timeline.Registry)) ModelOption
WithTimelineRegister allows callers to register custom renderers on the timeline registry
func WithTitle ¶ added in v0.0.4
func WithTitle(title string) ModelOption
type PrependInputTextMsg ¶ added in v0.0.11
type PrependInputTextMsg struct {
Text string
}
type ReplaceInputTextMsg ¶ added in v0.0.11
type ReplaceInputTextMsg struct {
Text string
}
Add these new message types
type SaveToFileMsg ¶ added in v0.0.11
type SaveToFileMsg struct{}
type SelectNextMessageMsg ¶ added in v0.0.11
type SelectNextMessageMsg struct{}
type SelectPrevMessageMsg ¶ added in v0.0.11
type SelectPrevMessageMsg struct{}
type StartBackendMsg ¶ added in v0.0.13
type StartBackendMsg struct{}
type Style ¶
type Style struct {
UnselectedMessage lipgloss.Style
SelectedMessage lipgloss.Style
FocusedMessage lipgloss.Style
MetadataStyle lipgloss.Style
ErrorMessage lipgloss.Style
ErrorSelected lipgloss.Style
}
func DefaultStyles ¶
func DefaultStyles() *Style
type SubmitMessageMsg ¶ added in v0.0.11
type SubmitMessageMsg struct{}
type ToggleHelpMsg ¶ added in v0.0.11
type ToggleHelpMsg struct{}
type TriggerWeatherToolMsg ¶ added in v0.0.25
type TriggerWeatherToolMsg struct{}
Demo tool triggers
type TriggerWebSearchToolMsg ¶ added in v0.0.25
type TriggerWebSearchToolMsg struct{}
type UnblurInputMsg ¶ added in v0.0.25
type UnblurInputMsg struct{}
type UnfocusMessageMsg ¶ added in v0.0.11
type UnfocusMessageMsg struct{}
type UserActionMsg ¶ added in v0.0.11
type UserActionMsg interface {
// contains filtered or unexported methods
}
New message types for user actions