inference
inference copied to clipboard
Chatglm3模型聊天Response中token消耗为-1
Describe the bug
Chatglm3模型返回的token消耗数为-1
To Reproduce
请求参数:
{
"model": "chatglm3",
"messages": [
{"role": "user", "content": "你能做什么"}
],
"temperature": 0.7,
"max_tokens":1024,
"tools": [{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "获取当前天气",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "城市,例如北京"
},
"format": {
"type": "string",
"enum": ["celsius", "fahrenheit"],
"description": "使用的温度单位。从所在的城市进行推断。"
}
},
"required": ["location", "format"]
}
}
}]
}
响应结果:
{
"id": "chatcmpl-e55f7f14-604f-4a65-a292-8b3749d062d0",
"model": "chatglm3",
"object": "chat.completion",
"created": 1714367499,
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "我是一个能够调用各种外部工具的助理,可以通过各种工具来得到一些额外信息,比如天气,新闻,股票等等。如果您需要任何此类信息,我将很高兴地帮助您。",
"tool_calls": []
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": -1,
"completion_tokens": -1,
"total_tokens": -1
}
}
查看到了相关代码貌似没有实现token计算:
Chatgml3 does not return the token usage, so return -1 values.
我看Chatglm3的官方示例好像支持token usage。请问后续准备支持吗?
This issue is stale because it has been open for 7 days with no activity.
This issue was closed because it has been inactive for 5 days since being marked as stale.