fix: ensure account manager initialized for count_tokens
- Add ensureInitialized() call before count_tokens handler - Use hybrid approach: local estimation for text, API for images/docs - This prevents "No accounts available" error on first request
This commit is contained in:
@@ -278,7 +278,7 @@ export function createCountTokensHandler(accountManager) {
|
||||
const result = await countTokens(
|
||||
{ messages, model, system, tools, tool_choice, thinking },
|
||||
accountManager,
|
||||
{ useAPI: true } // Use API for accurate token counting
|
||||
{ useAPI: false } // Use local estimation by default, API for complex content (images/docs)
|
||||
);
|
||||
|
||||
res.json(result);
|
||||
|
||||
Reference in New Issue
Block a user