mirror of
https://github.com/LLM-Red-Team/kimi-free-api.git
synced 2024-11-01 20:29:19 +08:00
处理token统计为0导致部分客户端无法识别问题
This commit is contained in:
parent
e530317486
commit
eef674eac8
22
README.md
22
README.md
@ -231,9 +231,9 @@ Authorization: Bearer [refresh_token]
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"usage": {
|
"usage": {
|
||||||
"prompt_tokens": 0,
|
"prompt_tokens": 1,
|
||||||
"completion_tokens": 0,
|
"completion_tokens": 1,
|
||||||
"total_tokens": 0
|
"total_tokens": 2
|
||||||
},
|
},
|
||||||
"created": 1710152062
|
"created": 1710152062
|
||||||
}
|
}
|
||||||
@ -293,9 +293,9 @@ Authorization: Bearer [refresh_token]
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"usage": {
|
"usage": {
|
||||||
"prompt_tokens": 0,
|
"prompt_tokens": 1,
|
||||||
"completion_tokens": 0,
|
"completion_tokens": 1,
|
||||||
"total_tokens": 0
|
"total_tokens": 2
|
||||||
},
|
},
|
||||||
"created": 100920
|
"created": 100920
|
||||||
}
|
}
|
||||||
@ -357,9 +357,9 @@ Authorization: Bearer [refresh_token]
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"usage": {
|
"usage": {
|
||||||
"prompt_tokens": 0,
|
"prompt_tokens": 1,
|
||||||
"completion_tokens": 0,
|
"completion_tokens": 1,
|
||||||
"total_tokens": 0
|
"total_tokens": 2
|
||||||
},
|
},
|
||||||
"created": 1710123627
|
"created": 1710123627
|
||||||
}
|
}
|
||||||
@ -383,3 +383,7 @@ tcp_nodelay on;
|
|||||||
# 设置保持连接的超时时间,这里设置为120秒。如果在这段时间内,客户端和服务器之间没有进一步的通信,连接将被关闭。
|
# 设置保持连接的超时时间,这里设置为120秒。如果在这段时间内,客户端和服务器之间没有进一步的通信,连接将被关闭。
|
||||||
keepalive_timeout 120;
|
keepalive_timeout 120;
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Token统计
|
||||||
|
|
||||||
|
由于推理侧不再kimi-free-api,因此token不可统计,将以固定数字返回。
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "kimi-free-api",
|
"name": "kimi-free-api",
|
||||||
"version": "0.0.13",
|
"version": "0.0.14",
|
||||||
"description": "Kimi Free API Server",
|
"description": "Kimi Free API Server",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
@ -506,7 +506,7 @@ function checkResult(result: AxiosResponse, refreshToken: string) {
|
|||||||
*/
|
*/
|
||||||
async function receiveStream(convId: string, stream: any) {
|
async function receiveStream(convId: string, stream: any) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// 第一条消息初始化
|
// 消息初始化
|
||||||
const data = {
|
const data = {
|
||||||
id: convId,
|
id: convId,
|
||||||
model: MODEL_NAME,
|
model: MODEL_NAME,
|
||||||
@ -514,7 +514,7 @@ async function receiveStream(convId: string, stream: any) {
|
|||||||
choices: [
|
choices: [
|
||||||
{ index: 0, message: { role: 'assistant', content: '' }, finish_reason: 'stop' }
|
{ 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()
|
created: util.unixTimestamp()
|
||||||
};
|
};
|
||||||
let refContent = '';
|
let refContent = '';
|
||||||
@ -612,7 +612,7 @@ function createTransStream(convId: string, stream: any, endCallback?: Function)
|
|||||||
} : {}, finish_reason: 'stop'
|
} : {}, finish_reason: 'stop'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
usage: { prompt_tokens: 0, completion_tokens: 0, total_tokens: 0 },
|
usage: { prompt_tokens: 1, completion_tokens: 1, total_tokens: 2 },
|
||||||
created
|
created
|
||||||
})}\n\n`;
|
})}\n\n`;
|
||||||
!transStream.closed && transStream.write(data);
|
!transStream.closed && transStream.write(data);
|
||||||
|
Loading…
Reference in New Issue
Block a user