()
| 532 | } |
| 533 | |
| 534 | func (cli *ChatCLI) getTokenEstimatorForCurrentLLM() func(string) int { |
| 535 | // Função padrão - estimativa conservadora |
| 536 | return func(text string) int { |
| 537 | // Aproximadamente 4 caracteres por token para a maioria dos modelos |
| 538 | return len(text) / 4 |
| 539 | } |
| 540 | } |
| 541 | |
| 542 | // refreshClientOnAuthError checks if the error is a 401/auth error from an OAuth provider. |
| 543 | // If so, it invalidates the auth cache, refreshes credentials, and recreates the client. |