Skip to content

Commit c2cd59f

Browse files
committed
处理token统计为0导致部分客户端无法识别问题
1 parent e2f569d commit c2cd59f

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,9 @@ Authorization: Bearer [refresh_token]
192192
}
193193
],
194194
"usage": {
195-
"prompt_tokens": 0,
196-
"completion_tokens": 0,
197-
"total_tokens": 0
195+
"prompt_tokens": 1,
196+
"completion_tokens": 1,
197+
"total_tokens": 2
198198
},
199199
"created": 1710603111
200200
}
@@ -217,4 +217,8 @@ tcp_nopush on;
217217
tcp_nodelay on;
218218
# 设置保持连接的超时时间,这里设置为120秒。如果在这段时间内,客户端和服务器之间没有进一步的通信,连接将被关闭。
219219
keepalive_timeout 120;
220-
```
220+
```
221+
222+
### Token统计
223+
224+
由于推理侧不再kimi-free-api,因此token不可统计,将以固定数字返回。

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "emohaa-free-api",
3-
"version": "0.0.2",
3+
"version": "0.0.3",
44
"description": "Emohaa Free API Server",
55
"type": "module",
66
"main": "dist/index.js",

src/api/controllers/chat.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ async function receiveStream(convId: string, stream: any) {
236236
choices: [
237237
{ index: 0, message: { role: 'assistant', content: '' }, finish_reason: 'stop' }
238238
],
239-
usage: { prompt_tokens: 0, completion_tokens: 0, total_tokens: 0 },
239+
usage: { prompt_tokens: 1, completion_tokens: 1, total_tokens: 2 },
240240
created: util.unixTimestamp()
241241
};
242242
const parser = createParser(event => {
@@ -295,7 +295,7 @@ function createTransStream(convId: string, stream: any, endCallback?: Function)
295295
index: 0, delta: {}, finish_reason: 'stop'
296296
}
297297
],
298-
usage: { prompt_tokens: 0, completion_tokens: 0, total_tokens: 0 },
298+
usage: { prompt_tokens: 1, completion_tokens: 1, total_tokens: 2 },
299299
created
300300
})}\n\n`;
301301
!transStream.closed && transStream.write(data);

0 commit comments

Comments
 (0)