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 ¶
- type Chat
- type HistoryWriter
- func (h *HistoryWriter) Render(format string, args ...interface{})
- func (h *HistoryWriter) RenderComment(format string, args ...interface{})
- func (h *HistoryWriter) RenderError(err error, reason string, args ...interface{})
- func (h *HistoryWriter) RenderHelps(commands []ui.Command)
- func (h *HistoryWriter) RenderStep(format string, args ...interface{})
- func (h *HistoryWriter) WriteToHistory(content string) error
- type Option
- func WithContent(content string) Option
- func WithContext(ctx context.Context) Option
- func WithCopyToClipboard(copy bool) Option
- func WithEngine(engine *ai.Engine) Option
- func WithMessages(messages []llms.ChatMessage) Option
- func WithPromptMode(promptMode ui.PromptMode) Option
- func WithRenderer(renderer *lipgloss.Renderer) Option
- func WithRunMode(runMode ui.RunMode) Option
- func WithWordWrap(wordWrap int) Option
- type Options
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 ¶
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
GetGlamOutput returns the formatted markdown output Returns the rendered markdown output string
func (*Chat) GetOutput ¶ added in v0.13.5
GetOutput returns the unescaped chat output Returns the processed chat output string
func (*Chat) Init ¶
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
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
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 WithContext ¶ added in v0.12.0
func WithCopyToClipboard ¶ added in v0.13.5
func WithEngine ¶ added in v0.12.0
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