Documentation
¶
Overview ¶
* ChatCLI - Command Line Interface for LLM interaction * Copyright (c) 2024 Edilson Freitas * License: MIT
Index ¶
- Constants
- type ConfigManager
- func (cm *ConfigManager) GetBool(key string, defaultValue bool) bool
- func (cm *ConfigManager) GetDuration(key string, defaultValue time.Duration) time.Duration
- func (cm *ConfigManager) GetInt(key string, defaultValue int) int
- func (cm *ConfigManager) GetString(key string) string
- func (cm *ConfigManager) Load()
- func (cm *ConfigManager) Reload(logger *zap.Logger)
- func (cm *ConfigManager) Set(key string, value interface{})
- type ConfigVersion
- type MigrationFunc
- type MigrationRegistry
- func (r *MigrationRegistry) Backup(values map[string]interface{}) (string, error)
- func (r *MigrationRegistry) GetCurrentVersion() (ConfigVersion, error)
- func (r *MigrationRegistry) Migrate(values map[string]interface{}) (map[string]interface{}, error)
- func (r *MigrationRegistry) NeedsMigration() (bool, int, int, error)
- func (r *MigrationRegistry) Register(fromVersion int, fn MigrationFunc)
- func (r *MigrationRegistry) Rollback(backupPath string) error
- func (r *MigrationRegistry) SetVersion(version int) error
Constants ¶
const ( // Valores padrão para StackSpot StackSpotBaseURL = "https://genai-inference-app.stackspot.com/v1" // ATUALIZADO StackSpotDefaultModel = "StackSpotAI" StackSpotResponseTimeout = 2 * time.Second DefaultLogFile = "~/.chatcli/app.log" DefaultStackSpotRealm = "zup" DefaultStackSpotAgentID = "default" // Valores padrão para OpenAI DefaultOpenAIModel = "gpt-5.2" DefaultOpenAiAssistModel = "gpt-4o-mini" OpenAIAPIURL = "https://api.openai.com/v1/chat/completions" OpenAIResponsesAPIURL = "https://api.openai.com/v1/responses" // OAuth (ChatGPT plan) endpoint — used when authenticated via OAuth instead of API key OpenAIOAuthResponsesURL = "https://chatgpt.com/backend-api/codex/responses" // Valores padrão para ClaudeAI DefaultClaudeAIModel = "claude-sonnet-4-5" ClaudeAIAPIURL = "https://api.anthropic.com/v1/messages" ClaudeAIAPIVersionDefault = "2023-06-01" // Versão padrão da APIClaudeAI // Valores padrão para Google Gemini DefaultGoogleAIModel = "gemini-2.0-flash-lite" GoogleAIAPIURL = "https://generativelanguage.googleapis.com/v1beta" DefaultGoogleAITimeout = 5 * time.Minute // Valores padrão para xAI DefaultXAIModel = "grok-code-fast-1" XAIAPIURL = "https://api.x.ai/v1/chat/completions" // Valores padrão para GitHub Copilot DefaultCopilotModel = "gpt-4o" CopilotAPIURL = "https://api.githubcopilot.com/chat/completions" // Valores padrão para Ollama DefaultOllamaModel = "gpt-oss:20b" OllamaDefaultBaseURL = "http://localhost:11434" OllamaFilterThinkingDefault = "true" // Provedor padrão DefaultLLMProvider = "OPENAI" // Definição do tamanho de historico DefaultMaxHistorySize = 100 * 1024 * 1024 // 100MB DefaultHistoryFile = ".chatcli_history" // Constantes para os possíveis valores do campo Status em ResponseData StatusProcessing = "processing" StatusCompleted = "completed" StatusError = "error" // Configurado MaxlogSize Default DefaultMaxLogSize = 100 // 100MB // Modos de processamento de arquivos ModeFull = "full" // Envia o conteúdo completo (comportamento atual) ModeSummary = "summary" // Envia apenas uma descrição estrutural ModeChunked = "chunked" // Divide em partes menores para processamento em sequência ModeSmartChunk = "smart" // Seleciona partes relevantes com base na consulta do usuário // Configuração de retry DefaultMaxRetries = 5 // Máximo de tentativas para retry DefaultInitialBackoff = 3 * time.Second // Backoff inicial para retry DefaultPluginTimeout = 15 * time.Minute // Agent plugin max turns AgentPluginMaxTurnsEnv = "CHATCLI_AGENT_PLUGIN_MAX_TURNS" DefaultAgentMaxTurns = 50 MaxAgentMaxTurns = 200 // limite de segurança )
Valores padrão para configuração da aplicação
const CurrentConfigVersion = 1
CurrentConfigVersion is the latest config schema version.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigManager ¶ added in v1.29.0
type ConfigManager struct {
// contains filtered or unexported fields
}
ConfigManager centraliza o acesso a todas as configurações. A ordem de prioridade é: Flags (aplicado no main) > Variáveis de Ambiente > Arquivo .env > Padrões.
var Global *ConfigManager
Global é a instância singleton do ConfigManager.
func New ¶ added in v1.29.0
func New(logger *zap.Logger) *ConfigManager
New cria uma nova instância do ConfigManager.
func (*ConfigManager) GetBool ¶ added in v1.29.0
func (cm *ConfigManager) GetBool(key string, defaultValue bool) bool
GetBool retorna um valor de configuração como bool.
func (*ConfigManager) GetDuration ¶ added in v1.29.0
GetDuration retorna um valor de configuração como time.Duration.
func (*ConfigManager) GetInt ¶ added in v1.29.0
func (cm *ConfigManager) GetInt(key string, defaultValue int) int
GetInt retorna um valor de configuração como int.
func (*ConfigManager) GetString ¶ added in v1.29.0
func (cm *ConfigManager) GetString(key string) string
GetString retorna um valor de configuração como string.
func (*ConfigManager) Load ¶ added in v1.29.0
func (cm *ConfigManager) Load()
Load carrega as configurações de todas as fontes.
func (*ConfigManager) Reload ¶ added in v1.29.0
func (cm *ConfigManager) Reload(logger *zap.Logger)
Reload recarrega as configurações do arquivo .env e das variáveis de ambiente.
func (*ConfigManager) Set ¶ added in v1.29.0
func (cm *ConfigManager) Set(key string, value interface{})
Set injeta um valor, tipicamente de uma flag (maior prioridade).
type ConfigVersion ¶ added in v1.66.0
type ConfigVersion struct {
Version int `json:"version"`
MigratedAt time.Time `json:"migrated_at"`
MigratedFrom int `json:"migrated_from,omitempty"`
BackupPath string `json:"backup_path,omitempty"`
}
ConfigVersion tracks the config schema version on disk.
type MigrationFunc ¶ added in v1.66.0
MigrationFunc transforms config from version N to N+1.
type MigrationRegistry ¶ added in v1.66.0
type MigrationRegistry struct {
// contains filtered or unexported fields
}
MigrationRegistry holds all registered migrations.
func NewMigrationRegistry ¶ added in v1.66.0
func NewMigrationRegistry(configDir string, logger *zap.Logger) *MigrationRegistry
NewMigrationRegistry creates a registry with built-in migrations.
func (*MigrationRegistry) Backup ¶ added in v1.66.0
func (r *MigrationRegistry) Backup(values map[string]interface{}) (string, error)
Backup saves the current config to a timestamped backup file.
func (*MigrationRegistry) GetCurrentVersion ¶ added in v1.66.0
func (r *MigrationRegistry) GetCurrentVersion() (ConfigVersion, error)
GetCurrentVersion reads the version from disk.
func (*MigrationRegistry) Migrate ¶ added in v1.66.0
func (r *MigrationRegistry) Migrate(values map[string]interface{}) (map[string]interface{}, error)
Migrate runs all pending migrations sequentially.
func (*MigrationRegistry) NeedsMigration ¶ added in v1.66.0
func (r *MigrationRegistry) NeedsMigration() (bool, int, int, error)
NeedsMigration checks if migration is required.
func (*MigrationRegistry) Register ¶ added in v1.66.0
func (r *MigrationRegistry) Register(fromVersion int, fn MigrationFunc)
Register adds a migration from fromVersion to fromVersion+1.
func (*MigrationRegistry) Rollback ¶ added in v1.66.0
func (r *MigrationRegistry) Rollback(backupPath string) error
Rollback restores config from a backup file.
func (*MigrationRegistry) SetVersion ¶ added in v1.66.0
func (r *MigrationRegistry) SetVersion(version int) error
SetVersion writes the version to disk.