feat: Add token usage indicator to chat input

Add TokenUsageIndicator component with circular progress ring
Create useTokenUsage hook with Jotai atom for state
Add model context window lookups to data-provider
Consolidate token utilities (output limits, TOKEN_DEFAULTS)
Display input/output tokens and percentage of context used
This commit is contained in:
Marco Beretta 2025-12-14 00:36:45 +01:00
parent 4d7e6b4a58
commit 841a37e8cb
No known key found for this signature in database
GPG key ID: D918033D8E74CC11
11 changed files with 710 additions and 348 deletions

View file

@ -1,4 +1,5 @@
const { getModelMaxTokens } = require('@librechat/api');
const { TOKEN_DEFAULTS } = require('librechat-data-provider');
const BaseClient = require('../BaseClient');
class FakeClient extends BaseClient {
@ -41,7 +42,9 @@ class FakeClient extends BaseClient {
}
this.maxContextTokens =
this.options.maxContextTokens ?? getModelMaxTokens(this.modelOptions.model) ?? 4097;
this.options.maxContextTokens ??
getModelMaxTokens(this.modelOptions.model) ??
TOKEN_DEFAULTS.LEGACY_CONTEXT_FALLBACK;
}
buildMessages() {}
getTokenCount(str) {