metrics

package
v1.50.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: MIT Imports: 7 Imported by: 0

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

View Source
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 ClearLine

func ClearLine() string

func CountTokens added in v1.49.0

func CountTokens(text, model string) int

CountTokens conta tokens usando BPE (tiktoken) com fallback

func FormatDuration

func FormatDuration(d time.Duration) string

func FormatDurationShort

func FormatDurationShort(d time.Duration) string

func FormatTimerComplete

func FormatTimerComplete(d time.Duration) string

func FormatTimerStatus

func FormatTimerStatus(d time.Duration, model, msg string) string

func FormatTokenStatus

func FormatTokenStatus(tc *TokenCounter) string

func FormatTokenStatusCompact

func FormatTokenStatusCompact(tc *TokenCounter) string

func FormatTokens

func FormatTokens(tokens int) string

func FormatTurnInfo

func FormatTurnInfo(t, m int, d time.Duration, tc *TokenCounter) string

func FormatWarning

func FormatWarning(msg string) string

func GetDotsAnimation added in v1.49.0

func GetDotsAnimation() string

func GetSpinnerFrame added in v1.49.0

func GetSpinnerFrame() string

func ProgressBar

func ProgressBar(percent float64, width int) string

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

func (*Spinner) Next added in v1.49.0

func (s *Spinner) Next() string

type Timer

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

Timer representa um cronometro de execução com display em tempo real

func NewTimer

func NewTimer() *Timer

NewTimer cria um novo timer

func (*Timer) Elapsed

func (t *Timer) Elapsed() time.Duration

Elapsed retorna o tempo decorrido (funciona mesmo com timer rúdando)

func (*Timer) IsRunning

func (t *Timer) IsRunning() bool

IsRunning retorna se o timer está em execução

func (*Timer) Start

func (t *Timer) Start(ctx context.Context, displayFunc func(duration time.Duration))

Start inicia o timer e opcionalmente atualiza o display em tempo real

func (*Timer) Stop

func (t *Timer) Stop() time.Duration

Stop para o timer e retorna a duração total

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

Jump to

Keyboard shortcuts

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