Skip to content

Commit

Permalink
处理token统计为0导致部分客户端无法识别问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinlic committed Mar 16, 2024
1 parent e2f569d commit c2cd59f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,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": 1710603111
}
Expand All @@ -217,4 +217,8 @@ tcp_nopush on;
tcp_nodelay on;
# 设置保持连接的超时时间,这里设置为120秒。如果在这段时间内,客户端和服务器之间没有进一步的通信,连接将被关闭。
keepalive_timeout 120;
```
```

### Token统计

由于推理侧不再kimi-free-api,因此token不可统计,将以固定数字返回。
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "emohaa-free-api",
"version": "0.0.2",
"version": "0.0.3",
"description": "Emohaa Free API Server",
"type": "module",
"main": "dist/index.js",
Expand Down
4 changes: 2 additions & 2 deletions src/api/controllers/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,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()
};
const parser = createParser(event => {
Expand Down Expand Up @@ -295,7 +295,7 @@ function createTransStream(convId: string, stream: any, endCallback?: Function)
index: 0, delta: {}, 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);
Expand Down

0 comments on commit c2cd59f

Please sign in to comment.