mirror of
https://github.com/jina-ai/node-DeepResearch.git
synced 2026-03-22 07:29:35 +08:00
fix: match PR #54 token counting implementation - remove token categories and use character-based estimation
Co-Authored-By: sha.zhou@jina.ai <sha.zhou@jina.ai>
This commit is contained in:
@@ -10,7 +10,6 @@ import {
|
|||||||
ChatCompletionResponse,
|
ChatCompletionResponse,
|
||||||
ChatCompletionChunk,
|
ChatCompletionChunk,
|
||||||
AnswerAction,
|
AnswerAction,
|
||||||
TOKEN_CATEGORIES,
|
|
||||||
Model
|
Model
|
||||||
} from './types';
|
} from './types';
|
||||||
import fs from 'fs/promises';
|
import fs from 'fs/promises';
|
||||||
@@ -446,7 +445,8 @@ app.post('/v1/chat/completions', (async (req: Request, res: Response) => {
|
|||||||
res.write(`data: ${JSON.stringify(closeThinkChunk)}\n\n`);
|
res.write(`data: ${JSON.stringify(closeThinkChunk)}\n\n`);
|
||||||
|
|
||||||
// Track error token and send error message
|
// Track error token and send error message
|
||||||
context.tokenTracker.trackUsage('evaluator', 1, TOKEN_CATEGORIES.REJECTED);
|
const estimatedTokens = Math.ceil(Buffer.byteLength(errorMessage, 'utf-8') / 4);
|
||||||
|
context.tokenTracker.trackUsage('evaluator', estimatedTokens);
|
||||||
const errorChunk: ChatCompletionChunk = {
|
const errorChunk: ChatCompletionChunk = {
|
||||||
id: requestId,
|
id: requestId,
|
||||||
object: 'chat.completion.chunk',
|
object: 'chat.completion.chunk',
|
||||||
|
|||||||
Reference in New Issue
Block a user