chatgpt-web
chatgpt-web copied to clipboard
疑问:接口返回的数据结构和官方说的不一样?
源码中的代码段(service/src/chatgpt/index.ts)中的代码段如下:
const response = await api.sendMessage(message, {
...options,
onProgress: (partialResponse) => {
process?.(partialResponse)
},
})
运行源码的返回如下: { response: { role: 'assistant', id: 'chatcmpl-79c2gjsvDXAURJKYNBgePFFP55rmO', parentMessageId: '375f64c1-9ff5-4988-8aeb-d06b4cbe4a0a', text: '你好,有什么我可以帮助你的吗?', delta: undefined, detail: { id: 'chatcmpl-79c2gjsvDXAURJKYNBgePFFP55rmO', object: 'chat.completion.chunk', created: 1682525542, model: 'gpt-3.5-turbo-0301', choices: [Array] } } }
但官方说明的返回如下: { "id":"chatcmpl-abc123", "object":"chat.completion", "created":1677858242, "model":"gpt-3.5-turbo-0301", "usage":{ "prompt_tokens":13, "completion_tokens":7, "total_tokens":20 }, "choices":[ { "message":{ "role":"assistant", "content":"\n\nThis is a test!" }, "finish_reason":"stop", "index":0 } ] }
是不是我弄错了什么了?为什么两个接口返回结构的不一样?我想得到total_tokens,应该对应源码中哪段获取呢?
这个是封装过的
这个是封装过的
那有没有雷同 api.sendMessage 一样作用的,但可以获得官方标准返回的方法?
This issue is stale because it has been open for 10 days with no activity.
This issue was closed because it has been inactive for 2 days since being marked as stale.