Closed ssfun closed 1 month ago
可在 ChatGPT Next Web 中使用
https://cohere2openai.xxx.worker.dev/v1/chat/completions
您是否用workers.dev
而不是worker.dev
检查过您的 Worker 域?
域是正确的,这里手敲出错
更正,steam 为 true,直接 curl post 能通。Bob 和 ChatGPT-Next-Web 确实报 接口响应错误 - Internal Server Error
经过抓包验证,应该是缺失对 "presence_penalty"、"max_tokens"、"temperature"、"frequency_penalty"等参数的兼容,导致报 Internal Server Erro,请求增加兼容处理
进一步测试后,发现 1、单独设置 "presence_penalty"、"max_tokens"、"temperature"、"frequency_penalty" 字段时,请求能通(max_tokens只是不支持 4096,支持:1024、2048、3072) 2、 "presence_penalty"、"frequency_penalty",同时存在时,且值均为1时,请求不通
too many tokens: max tokens must be less than or equal to 4000, the maximum output for this model - received 4096.
,這意味著 max_tokens 只能等於或小於 4000,而不是 4096(這不是 worker 的問題,而是你的客戶端問題)。
invalid request: cannot specify both frequency_penalty and presence_penalty.
,對於 Cohere API,"presence_penalty" 和 "frequency_penalty" 不應該同時設置,這也是你的客戶端問題。
對於同時存在 "presence_penalty" 和 "frequency_penalty" 參數的情況,這是您的客戶端配置問題,您必須將其中一個設置為 0。
當 "presence_penalty" 和 "frequency_penalty" 都設置為 1 時,我不會放棄它們之間的任何值,因為這會導致質量問題。
感谢解疑,因为 Bob 不支持着两个参数的设置,最后我在 api.ts 中加了以下逻辑:
if (body.frequency_penalty === 1 && body.presence_penalty === 1) {
body.frequency_penalty = 0; // 当两个值均为1时,将 frequencyPenalty 重新赋值为0
}
目前正常了,感谢
使用 Bob 、ChatGPT-Next-Web 等OpenAI客户端请求时,报 Internal Server Error。
以下为请求抓包:
此时,请求不通,报:
去掉请求中的以下参数后,请求是通的,能得到正确结果:
希望能够增加对以上参数的兼容处理。