chat

package
v0.13.8 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package chat implements the terminal-based chat interface for AI interactions. It handles the UI rendering, state management, and communication with the AI engine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chat

type Chat struct {
	Error      *errbook.AiError // Error encountered during chat
	TokenUsage llms.Usage       // Token usage statistics from the AI
	// contains filtered or unexported fields
}

Chat represents the main chat application structure

func NewChat

func NewChat(cfg *options.Config, opts ...Option) *Chat

NewChat creates and initializes a new Chat instance cfg: Application configuration opts: Optional parameters for customizing chat behavior

func (*Chat) GetGlamOutput added in v0.13.5

func (c *Chat) GetGlamOutput() string

GetGlamOutput returns the formatted markdown output Returns the rendered markdown output string

func (*Chat) GetOutput added in v0.13.5

func (c *Chat) GetOutput() string

GetOutput returns the unescaped chat output Returns the processed chat output string

func (*Chat) Init

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

Init initializes the chat application and returns the initial command to execute This is part of the Bubble Tea framework's initialization process

func (*Chat) Run added in v0.12.0

func (c *Chat) Run() error

Run starts the chat application and handles the main execution loop Returns error if the program fails to start or encounters an error during execution

func (*Chat) Update

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

Update handles state updates and message processing for the chat application msg: The incoming message to process Returns the updated model and commands to execute This is part of the Bubble Tea framework's update loop

func (*Chat) View

func (c *Chat) View() string

View renders the current state of the chat application Returns the string representation of the current view This is part of the Bubble Tea framework's rendering process

type HistoryWriter added in v0.13.8

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

HistoryWriter wraps console output functions to also write to chat history

func NewHistoryWriter added in v0.13.8

func NewHistoryWriter() *HistoryWriter

NewHistoryWriter creates a new HistoryWriter instance

func (*HistoryWriter) Render added in v0.13.8

func (h *HistoryWriter) Render(format string, args ...interface{})

Render writes to console and chat history

func (*HistoryWriter) RenderComment added in v0.13.8

func (h *HistoryWriter) RenderComment(format string, args ...interface{})

RenderComment writes comment to console and chat history

func (*HistoryWriter) RenderError added in v0.13.8

func (h *HistoryWriter) RenderError(err error, reason string, args ...interface{})

RenderError writes error to console and chat history

func (*HistoryWriter) RenderHelps added in v0.13.8

func (h *HistoryWriter) RenderHelps(commands []ui.Command)

RenderHelps writes to console and chat history

func (*HistoryWriter) RenderStep added in v0.13.8

func (h *HistoryWriter) RenderStep(format string, args ...interface{})

RenderStep writes step information to console and chat history

func (*HistoryWriter) WriteToHistory added in v0.13.8

func (h *HistoryWriter) WriteToHistory(content string) error

WriteToHistory writes content to the chat history file

type Option added in v0.12.0

type Option func(*Options)

func WithContent added in v0.12.0

func WithContent(content string) Option

func WithContext added in v0.12.0

func WithContext(ctx context.Context) Option

func WithCopyToClipboard added in v0.13.5

func WithCopyToClipboard(copy bool) Option

func WithEngine added in v0.12.0

func WithEngine(engine *ai.Engine) Option

func WithMessages added in v0.12.0

func WithMessages(messages []llms.ChatMessage) Option

func WithPromptMode added in v0.12.0

func WithPromptMode(promptMode ui.PromptMode) Option

func WithRenderer added in v0.12.0

func WithRenderer(renderer *lipgloss.Renderer) Option

func WithRunMode added in v0.12.0

func WithRunMode(runMode ui.RunMode) Option

func WithWordWrap added in v0.12.0

func WithWordWrap(wordWrap int) Option

type Options added in v0.12.0

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

func NewOptions added in v0.12.0

func NewOptions(opts ...Option) *Options

Jump to

Keyboard shortcuts

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