Documentation
¶
Overview ¶
Go Multi-Agent - Metrics Display
ChatCLI - Metrics Timer
Copyright (c) 2024 Edilson Freitas
License: MIT
ChatCLI - Metrics Token Counter
Copyright (c) 2024 Edilson Freitas
License: MIT
Index ¶
- Constants
- func ClearLine() string
- func CountTokens(text, model string) int
- func FormatDuration(d time.Duration) string
- func FormatDurationShort(d time.Duration) string
- func FormatTimerComplete(d time.Duration) string
- func FormatTimerStatus(d time.Duration, model, msg string) string
- func FormatTokenStatus(tc *TokenCounter) string
- func FormatTokenStatusCompact(tc *TokenCounter) string
- func FormatTokens(tokens int) string
- func FormatTurnInfo(t, m int, d time.Duration, tc *TokenCounter) string
- func FormatWarning(msg string) string
- func GetDotsAnimation() string
- func GetSpinnerFrame() string
- func ProgressBar(percent float64, width int) string
- type Spinner
- type Timer
- type TokenCounter
- func (tc *TokenCounter) AddTokens(promptTokens, completionTokens int)
- func (tc *TokenCounter) AddTurn(prompt string, response string)
- func (tc *TokenCounter) GetLastTurnTokens() (prompt, completion int)
- func (tc *TokenCounter) GetModelLimit() int
- func (tc *TokenCounter) GetTotalTokens() int
- func (tc *TokenCounter) GetTurns() int
- func (tc *TokenCounter) GetUsagePercent() float64
- func (tc *TokenCounter) IsCritical() bool
- func (tc *TokenCounter) IsNearLimit() bool
- func (tc *TokenCounter) IsUsingRealUsage() bool
- func (tc *TokenCounter) Reset()
- func (tc *TokenCounter) UpdateLastTurnFromAPI(promptTokens, completionTokens int)
Constants ¶
const ( ColorReset = "\033[0m" ColorGreen = "\033[32m" ColorYellow = "\033[33m" ColorRed = "\033[31m" ColorCyan = "\033[36m" ColorGray = "\033[90m" ColorBold = "\033[1m" )
Variables ¶
This section is empty.
Functions ¶
func CountTokens ¶ added in v1.49.0
CountTokens conta tokens usando BPE (tiktoken) com fallback
func FormatDuration ¶
func FormatDurationShort ¶
func FormatTimerComplete ¶
func FormatTokenStatus ¶
func FormatTokenStatus(tc *TokenCounter) string
func FormatTokenStatusCompact ¶
func FormatTokenStatusCompact(tc *TokenCounter) string
func FormatTokens ¶
func FormatTurnInfo ¶
func FormatTurnInfo(t, m int, d time.Duration, tc *TokenCounter) string
func FormatWarning ¶
func GetDotsAnimation ¶ added in v1.49.0
func GetDotsAnimation() string
func GetSpinnerFrame ¶ added in v1.49.0
func GetSpinnerFrame() string
func ProgressBar ¶
ProgressBar gera barra de progresso com caracteres seguros
Types ¶
type Spinner ¶ added in v1.49.0
type Spinner struct {
// contains filtered or unexported fields
}
func NewSpinner ¶ added in v1.49.0
func NewSpinner() *Spinner
type Timer ¶
type Timer struct {
// contains filtered or unexported fields
}
Timer representa um cronometro de execução com display em tempo real
type TokenCounter ¶
type TokenCounter struct {
// contains filtered or unexported fields
}
TokenCounter rastreia o uso de tokens na sessão
func NewTokenCounter ¶
func NewTokenCounter(provider, modelName string, overrideLimit int) *TokenCounter
NewTokenCounter cria um novo contador de tokens.
func (*TokenCounter) AddTokens ¶
func (tc *TokenCounter) AddTokens(promptTokens, completionTokens int)
AddTokens adiciona tokens diretamente (quando API retorna usage real)
func (*TokenCounter) AddTurn ¶
func (tc *TokenCounter) AddTurn(prompt string, response string)
AddTurn registra um turno de conversa usando tiktoken (fallback)
func (*TokenCounter) GetLastTurnTokens ¶
func (tc *TokenCounter) GetLastTurnTokens() (prompt, completion int)
func (*TokenCounter) GetModelLimit ¶
func (tc *TokenCounter) GetModelLimit() int
func (*TokenCounter) GetTotalTokens ¶
func (tc *TokenCounter) GetTotalTokens() int
func (*TokenCounter) GetTurns ¶
func (tc *TokenCounter) GetTurns() int
func (*TokenCounter) GetUsagePercent ¶
func (tc *TokenCounter) GetUsagePercent() float64
func (*TokenCounter) IsCritical ¶
func (tc *TokenCounter) IsCritical() bool
func (*TokenCounter) IsNearLimit ¶
func (tc *TokenCounter) IsNearLimit() bool
func (*TokenCounter) IsUsingRealUsage ¶ added in v1.49.0
func (tc *TokenCounter) IsUsingRealUsage() bool
IsUsingRealUsage retorna se o último turno usou tokens reais da API
func (*TokenCounter) Reset ¶
func (tc *TokenCounter) Reset()
func (*TokenCounter) UpdateLastTurnFromAPI ¶ added in v1.49.0
func (tc *TokenCounter) UpdateLastTurnFromAPI(promptTokens, completionTokens int)
UpdateLastTurnFromAPI atualiza o último turno com tokens reais da API Chame após AddTurn() para sobrescrever a estimativa com valores reais