diff --git a/README.md b/README.md index 5f01658..207ef5f 100644 --- a/README.md +++ b/README.md @@ -231,9 +231,9 @@ Authorization: Bearer [refresh_token] } ], "usage": { - "prompt_tokens": 0, - "completion_tokens": 0, - "total_tokens": 0 + "prompt_tokens": 1, + "completion_tokens": 1, + "total_tokens": 2 }, "created": 1710152062 } @@ -293,9 +293,9 @@ Authorization: Bearer [refresh_token] } ], "usage": { - "prompt_tokens": 0, - "completion_tokens": 0, - "total_tokens": 0 + "prompt_tokens": 1, + "completion_tokens": 1, + "total_tokens": 2 }, "created": 100920 } @@ -357,9 +357,9 @@ Authorization: Bearer [refresh_token] } ], "usage": { - "prompt_tokens": 0, - "completion_tokens": 0, - "total_tokens": 0 + "prompt_tokens": 1, + "completion_tokens": 1, + "total_tokens": 2 }, "created": 1710123627 } @@ -382,4 +382,8 @@ tcp_nopush on; tcp_nodelay on; # 设置保持连接的超时时间,这里设置为120秒。如果在这段时间内,客户端和服务器之间没有进一步的通信,连接将被关闭。 keepalive_timeout 120; -``` \ No newline at end of file +``` + +### Token统计 + +由于推理侧不再kimi-free-api,因此token不可统计,将以固定数字返回。 \ No newline at end of file diff --git a/package.json b/package.json index 8490bbc..b571d99 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kimi-free-api", - "version": "0.0.13", + "version": "0.0.14", "description": "Kimi Free API Server", "type": "module", "main": "dist/index.js", diff --git a/src/api/controllers/chat.ts b/src/api/controllers/chat.ts index 06303bd..0708f5c 100644 --- a/src/api/controllers/chat.ts +++ b/src/api/controllers/chat.ts @@ -506,7 +506,7 @@ function checkResult(result: AxiosResponse, refreshToken: string) { */ async function receiveStream(convId: string, stream: any) { return new Promise((resolve, reject) => { - // 第一条消息初始化 + // 消息初始化 const data = { id: convId, model: MODEL_NAME, @@ -514,7 +514,7 @@ async function receiveStream(convId: string, stream: any) { choices: [ { index: 0, message: { role: 'assistant', content: '' }, finish_reason: 'stop' } ], - usage: { prompt_tokens: 0, completion_tokens: 0, total_tokens: 0 }, + usage: { prompt_tokens: 1, completion_tokens: 1, total_tokens: 2 }, created: util.unixTimestamp() }; let refContent = ''; @@ -612,7 +612,7 @@ function createTransStream(convId: string, stream: any, endCallback?: Function) } : {}, finish_reason: 'stop' } ], - usage: { prompt_tokens: 0, completion_tokens: 0, total_tokens: 0 }, + usage: { prompt_tokens: 1, completion_tokens: 1, total_tokens: 2 }, created })}\n\n`; !transStream.closed && transStream.write(data);