Documentation
¶
Index ¶
- Constants
- Variables
- func AddNewSession(isTemporary bool) tea.Cmd
- func CalcChatPaneSize(tw, th int, mode ViewMode) (w, h int)
- func CalcMaxSettingItemWidth(containerWidth int) int
- func CalcModelsListSize(tw, th int) (w, h int)
- func CalcPromptPaneSize(tw, th int, mode ViewMode) (w, h int)
- func CalcSessionsListSize(tw, th, tipsOffset int) (w, h int)
- func CalcSessionsPaneSize(tw, th int) (w, h int)
- func CalcSettingsPaneSize(tw, th int) (w, h int)
- func CalcVisualModeViewSize(tw, th int) (w, h int)
- func CleanContent(content string) string
- func DeleteFilesIfDevMode()
- func GetAppDataPath() (string, error)
- func GetAppDirName() string
- func GetFilteredModelList(providerType string, apiUrl string, models []string) []string
- func GetManual(w int, colors SchemeColors) string
- func GetMessagesAsPrettyString(msgsToRender []LocalStoreMessage, w int, colors SchemeColors, isQuickChat bool, ...) string
- func GetNextProcessResultId(chatMsgs []LocalStoreMessage) int
- func GetQuickChatDisclaimer(w int, colors SchemeColors) string
- func GetVisualModeView(msgsToRender []LocalStoreMessage, w int, colors SchemeColors, ...) string
- func InitDb() *sql.DB
- func IsFocusAllowed(mode ViewMode, pane Pane, tw int) bool
- func IsProcessingActive(state ProcessingState) bool
- func IsSystemMessageSupported(provider ApiProvider, model string) bool
- func MakeErrorMsg(v string) tea.Cmd
- func MakeFocusMsg(v bool) tea.Msg
- func MigrateFS(db *sql.DB, migrationsFS fs.FS, dir string) error
- func PurgeModelsCache(db *sql.DB) error
- func RemoveDuplicates[T comparable](slice []T) []T
- func RenderBotChunk(chunk string, width int, colors SchemeColors) string
- func RenderBotMessage(msg LocalStoreMessage, width int, colors SchemeColors, isVisualMode bool, ...) string
- func RenderErrorMessage(msg string, width int, colors SchemeColors) string
- func RenderToolCall(msg LocalStoreMessage, width int, colors SchemeColors, isVisualMode bool, ...) string
- func RenderUserMessage(userMessage LocalStoreMessage, width int, colors SchemeColors, ...) string
- func SendAsyncDependencyReadyMsg(dependency AsyncDependency) tea.Cmd
- func SendCopyAllMsgs() tea.Msg
- func SendCopyLastMsg() tea.Msg
- func SendNotificationMsg(notification Notification) tea.Cmd
- func SendProcessingStateChangedMsg(processingState ProcessingState) tea.Cmd
- func SendPromptReadyMsg(prompt string, attachments []Attachment) tea.Cmd
- func SendViewModeChangedMsg(mode ViewMode) tea.Cmd
- func SortByNumberDesc[T any, V int | int64 | float64](slice []T, keyFunc func(T) V)
- func StripAnsiCodes(str string) string
- func SwitchToEditor(content string, op Operation, isFocused bool) tea.Cmd
- func TransformRequestHeaders(provider ApiProvider, params map[string]any) map[string]any
- func TrimListItem(value string, listWidth int) string
- func UpdateSystemPrompt(prompt string) tea.Cmd
- func WriteToResponseChannel(ctx context.Context, ch chan<- ProcessApiCompletionResponse, ...)
- type AddNewSessionMsg
- type ApiProvider
- type AsyncDependency
- type AsyncDependencyReady
- type Attachment
- type Choice
- type ColorScheme
- type CompletionChunk
- type CompletionResponse
- type CopyAllMsgs
- type CopyLastMsg
- type ErrorEvent
- type FocusEvent
- type LlmClient
- type LocalStoreMessage
- type ModelDescription
- type ModelsListResponse
- type ModelsLoaded
- type Notification
- type NotificationMsg
- type OpenTextEditorMsg
- type Operation
- type Pane
- type ProcessApiCompletionResponse
- type ProcessModelsResponse
- type ProcessingState
- type ProcessingStateChanged
- type PrompInputMode
- type PromptReady
- type SchemeColors
- type Settings
- type SwitchToPaneMsg
- type SystemPromptUpdatedMsg
- type TokenUsage
- type ToolCall
- type ToolFunction
- type ViewMode
- type ViewModeChanged
Constants ¶
View Source
const ( DefaultTerminalWidth = 120 DefaultTerminalHeight = 80 DefaultElementsPadding = 2 )
Defaults
View Source
const ( PromptPaneHeight = 6 PromptPanePadding = 2 PromptPaneMarginTop = 0 StatusBarPaneHeight = 5 EditModeUIElementsSum = 4 ChatPaneMarginRight = 1 SidePaneLeftPadding = 5 // A 'counterweight' is a sum of other elements' margins and paggings // The counterweight needs to be subtracted when calculating pane sizes // in order to properly align elements SettingsPaneHeightCounterweight = 3 SessionsPaneHeightCounterweight = 4 // TODO: info pane hight ChatPaneVisualModeCounterweight = 2 )
Panes
View Source
const ( ListRightShiftedItemPadding = -2 TextSelectorMaxWidthCorrection = 6 InputContainerDelta = 5 ListItemMarginLeft = 2 ListItemPaddingLeft = 2 WidthMinScalingLimit = 120 HeightMinScalingLimit = 46 ListItemTrimThreshold = 10 ListItemTrimCharAmount = 14 )
UI elements
View Source
const ( OpenAiProviderType = "openai" GeminiProviderType = "gemini" OpenrouterProviderType = "openrouter" )
View Source
const ActiveDot = "■"
View Source
const ChunkIndexStart = 1
View Source
const DefaultRequestTimeOutSec = 5
View Source
const DefaultSettingsId = 0
View Source
const ErrorHelp = "" /* 131-byte string literal not displayed */
View Source
const FrequencyRange = "[-2.0, 2.0)"
View Source
const InactiveDot = "•"
View Source
const ListHeadingDot = "■"
View Source
const QuickChatWarning = "" /* 135-byte string literal not displayed */
View Source
const TemperatureRange = "[0.0, 2.0]"
View Source
const TipsSeparator = " • "
View Source
const TopPRange = "[0.0, 1.0]"
View Source
const WordWrapDelta = 7
Variables ¶
View Source
var ( NormalFocusPanes = []Pane{SettingsPane, SessionsPane, PromptPane, ChatPane} ZenFocusPanes = []Pane{PromptPane, ChatPane} )
View Source
var DeleteSessionValidator = func(input string) error { allowed := []string{"y", "n"} if len(input) > 1 || !slices.Contains(allowed, input) { return errors.New("Invalid input") } return nil }
View Source
var EmptyValidator = func(input string) error { return nil }
View Source
var FrequencyValidator = func(input string) error { return validateRangedFloat(input, -2.0, 2.0, false, true) }
View Source
var HelpStyle = lipgloss.NewStyle().Padding(0, 0, 0, 2).Foreground(SubduedColor)
View Source
var ManualContent string
View Source
var MaxTokensValidator = func(input string) error { if input == "" { return nil } min := 0 max := 1_000_000 val, err := strconv.Atoi(input) if err != nil { return err } if val <= min || val > max { logOutOfRange(val, min, max) return fmt.Errorf("value %d out of range (%d, %d)", val, min, max) } return nil }
View Source
var Slog *slog.Logger
View Source
var SubduedColor = lipgloss.AdaptiveColor{Light: "#9B9B9B", Dark: "#5C5C5C"}
View Source
var TemperatureValidator = func(input string) error { return validateRangedFloat(input, 0.0, 2.0, false, false) }
View Source
var TopPValidator = func(input string) error { return validateRangedFloat(input, 0.0, 1.0, false, false) }
Functions ¶
func AddNewSession ¶
func CalcChatPaneSize ¶
func CalcMaxSettingItemWidth ¶
func CalcModelsListSize ¶
func CalcPromptPaneSize ¶
func CalcSessionsListSize ¶
func CalcSessionsPaneSize ¶
func CalcSettingsPaneSize ¶
func CalcVisualModeViewSize ¶
func CleanContent ¶ added in v0.8.0
func DeleteFilesIfDevMode ¶
func DeleteFilesIfDevMode()
func GetAppDataPath ¶
func GetAppDirName ¶
func GetAppDirName() string
func GetFilteredModelList ¶
func GetManual ¶
func GetManual(w int, colors SchemeColors) string
func GetMessagesAsPrettyString ¶
func GetMessagesAsPrettyString( msgsToRender []LocalStoreMessage, w int, colors SchemeColors, isQuickChat bool, settings Settings, ) string
func GetNextProcessResultId ¶ added in v0.8.0
func GetNextProcessResultId(chatMsgs []LocalStoreMessage) int
func GetQuickChatDisclaimer ¶
func GetQuickChatDisclaimer(w int, colors SchemeColors) string
func GetVisualModeView ¶
func GetVisualModeView(msgsToRender []LocalStoreMessage, w int, colors SchemeColors, settings Settings) string
func IsProcessingActive ¶ added in v0.8.0
func IsProcessingActive(state ProcessingState) bool
func IsSystemMessageSupported ¶
func IsSystemMessageSupported(provider ApiProvider, model string) bool
func MakeErrorMsg ¶
func MakeFocusMsg ¶
func PurgeModelsCache ¶
func RemoveDuplicates ¶
func RemoveDuplicates[T comparable](slice []T) []T
func RenderBotChunk ¶ added in v0.8.0
func RenderBotChunk( chunk string, width int, colors SchemeColors) string
func RenderBotMessage ¶
func RenderBotMessage( msg LocalStoreMessage, width int, colors SchemeColors, isVisualMode bool, settings Settings, ) string
func RenderErrorMessage ¶
func RenderErrorMessage(msg string, width int, colors SchemeColors) string
func RenderToolCall ¶ added in v0.8.0
func RenderToolCall( msg LocalStoreMessage, width int, colors SchemeColors, isVisualMode bool, settings Settings) string
func RenderUserMessage ¶
func RenderUserMessage(userMessage LocalStoreMessage, width int, colors SchemeColors, isVisualMode bool) string
func SendAsyncDependencyReadyMsg ¶
func SendAsyncDependencyReadyMsg(dependency AsyncDependency) tea.Cmd
func SendCopyAllMsgs ¶
func SendCopyLastMsg ¶
func SendNotificationMsg ¶
func SendNotificationMsg(notification Notification) tea.Cmd
func SendProcessingStateChangedMsg ¶
func SendProcessingStateChangedMsg(processingState ProcessingState) tea.Cmd
func SendPromptReadyMsg ¶
func SendPromptReadyMsg(prompt string, attachments []Attachment) tea.Cmd
func SendViewModeChangedMsg ¶
func SortByNumberDesc ¶ added in v0.8.0
func StripAnsiCodes ¶
func TransformRequestHeaders ¶
func TransformRequestHeaders(provider ApiProvider, params map[string]any) map[string]any
func TrimListItem ¶
func UpdateSystemPrompt ¶
func WriteToResponseChannel ¶ added in v0.8.0
func WriteToResponseChannel(ctx context.Context, ch chan<- ProcessApiCompletionResponse, msg ProcessApiCompletionResponse)
Types ¶
type AddNewSessionMsg ¶
type AddNewSessionMsg struct {
IsTemporary bool
}
type ApiProvider ¶
type ApiProvider int
const ( OpenAi ApiProvider = iota Local Mistral Gemini Openrouter )
func GetOpenAiInferenceProvider ¶
func GetOpenAiInferenceProvider(providerType string, apiUrl string) ApiProvider
type AsyncDependency ¶
type AsyncDependency int
const ( SettingsPaneModule AsyncDependency = iota Orchestrator )
type AsyncDependencyReady ¶
type AsyncDependencyReady struct {
Dependency AsyncDependency
}
type Attachment ¶ added in v0.7.9
type ColorScheme ¶
type ColorScheme string
const ( OriginalPink ColorScheme = "pink" SmoothBlue ColorScheme = "blue" Groovebox ColorScheme = "groove" )
func (ColorScheme) GetColors ¶
func (s ColorScheme) GetColors() SchemeColors
type CompletionChunk ¶
type CompletionResponse ¶
type CompletionResponse struct {
Data CompletionChunk `json:"data"`
}
type CopyAllMsgs ¶
type CopyAllMsgs struct{}
type CopyLastMsg ¶
type CopyLastMsg struct{}
type ErrorEvent ¶
type ErrorEvent struct {
Message string
}
type FocusEvent ¶
type FocusEvent struct {
IsFocused bool
}
type LlmClient ¶
type LlmClient interface {
RequestCompletion(
ctx context.Context,
chatMsgs []LocalStoreMessage,
modelSettings Settings,
resultChan chan ProcessApiCompletionResponse,
) tea.Cmd
RequestModelsList(ctx context.Context) ProcessModelsResponse
}
type LocalStoreMessage ¶ added in v0.7.9
type ModelDescription ¶
type ModelsListResponse ¶
type ModelsListResponse struct {
Object string `json:"object"`
Data []ModelDescription `json:"data"`
}
func (ModelsListResponse) GetModelNamesFromResponse ¶
func (m ModelsListResponse) GetModelNamesFromResponse() []string
type ModelsLoaded ¶
type ModelsLoaded struct {
Models []string
}
type Notification ¶
type Notification int
const ( CopiedNotification Notification = iota CancelledNotification SysPromptChangedNotification PresetSavedNotification SessionSavedNotification )
type NotificationMsg ¶
type NotificationMsg struct {
Notification Notification
}
type OpenTextEditorMsg ¶
type ProcessApiCompletionResponse ¶
type ProcessApiCompletionResponse struct {
ID int
Result CompletionChunk // or whatever type you need
Err error
Final bool
}
type ProcessModelsResponse ¶
type ProcessModelsResponse struct {
Result ModelsListResponse
Err error
Final bool
}
type ProcessingState ¶ added in v0.8.0
type ProcessingState int
const ( Idle ProcessingState = iota ProcessingChunks AwaitingToolCallResult AwaitingFinalization Finalized Error )
type ProcessingStateChanged ¶
type ProcessingStateChanged struct {
State ProcessingState
}
type PrompInputMode ¶
type PrompInputMode int
const ( PromptInsertMode PrompInputMode = iota PromptNormalMode )
type PromptReady ¶
type PromptReady struct {
Prompt string
Attachments []Attachment
}
type SchemeColors ¶
type SchemeColors struct {
MainColor lipgloss.AdaptiveColor
AccentColor lipgloss.AdaptiveColor
HighlightColor lipgloss.AdaptiveColor
DefaultTextColor lipgloss.AdaptiveColor
ErrorColor lipgloss.AdaptiveColor
NormalTabBorderColor lipgloss.AdaptiveColor
ActiveTabBorderColor lipgloss.AdaptiveColor
RendererThemeOption glamour.TermRendererOption
}
type SwitchToPaneMsg ¶
type SwitchToPaneMsg struct {
Target Pane
}
type SystemPromptUpdatedMsg ¶
type SystemPromptUpdatedMsg struct {
SystemPrompt string
}
type TokenUsage ¶
type ToolCall ¶ added in v0.8.0
type ToolCall struct {
Id string `json:"id"`
Type string `json:"type"`
Function ToolFunction `json:"function"`
Result *string `json:"result"`
}
type ToolFunction ¶ added in v0.8.0
type ViewModeChanged ¶
type ViewModeChanged struct {
Mode ViewMode
}
Click to show internal directories.
Click to hide internal directories.