chatgpt-web
chatgpt-web copied to clipboard
切换成 Azure 后无法自动 Stop 对话
改了下代码支持 Azure OpenAI ,只改了请求的 url 拼接和 header,没有动其他逻辑。
我对比了 OpenAI 和 Azure OpenAI 响应的数据格式是一致的,但是为什么无法自动 Stop 呢。
Azure 响应:
data: {"id":"chatcmpl-6xGsJBcDHMv8KUJDuk14JV32ZL3BZ","object":"chat.completion.chunk","created":1679584239,"model":"gpt-35-turbo","choices":[{"index":0,"finish_reason":null,"delta":{"role":"assistant"}}],"usage":null}
data: {"id":"chatcmpl-6xGsJBcDHMv8KUJDuk14JV32ZL3BZ","object":"chat.completion.chunk","created":1679584239,"model":"gpt-35-turbo","choices":[{"index":0,"finish_reason":null,"delta":{"content":"你"}}],"usage":null}
data: {"id":"chatcmpl-6xGsJBcDHMv8KUJDuk14JV32ZL3BZ","object":"chat.completion.chunk","created":1679584239,"model":"gpt-35-turbo","choices":[{"index":0,"finish_reason":null,"delta":{"content":"好"}}],"usage":null}
data: {"id":"chatcmpl-6xGsJBcDHMv8KUJDuk14JV32ZL3BZ","object":"chat.completion.chunk","created":1679584239,"model":"gpt-35-turbo","choices":[{"index":0,"finish_reason":null,"delta":{"content":"!"}}],"usage":null}
data: {"id":"chatcmpl-6xGsJBcDHMv8KUJDuk14JV32ZL3BZ","object":"chat.completion.chunk","created":1679584239,"model":"gpt-35-turbo","choices":[{"index":0,"finish_reason":null,"delta":{"content":"有"}}],"usage":null}
data: {"id":"chatcmpl-6xGsJBcDHMv8KUJDuk14JV32ZL3BZ","object":"chat.completion.chunk","created":1679584239,"model":"gpt-35-turbo","choices":[{"index":0,"finish_reason":null,"delta":{"content":"什"}}],"usage":null}
data: {"id":"chatcmpl-6xGsJBcDHMv8KUJDuk14JV32ZL3BZ","object":"chat.completion.chunk","created":1679584239,"model":"gpt-35-turbo","choices":[{"index":0,"finish_reason":null,"delta":{"content":"么"}}],"usage":null}
data: {"id":"chatcmpl-6xGsJBcDHMv8KUJDuk14JV32ZL3BZ","object":"chat.completion.chunk","created":1679584239,"model":"gpt-35-turbo","choices":[{"index":0,"finish_reason":null,"delta":{"content":"我"}}],"usage":null}
data: {"id":"chatcmpl-6xGsJBcDHMv8KUJDuk14JV32ZL3BZ","object":"chat.completion.chunk","created":1679584239,"model":"gpt-35-turbo","choices":[{"index":0,"finish_reason":null,"delta":{"content":"可以"}}],"usage":null}
data: {"id":"chatcmpl-6xGsJBcDHMv8KUJDuk14JV32ZL3BZ","object":"chat.completion.chunk","created":1679584239,"model":"gpt-35-turbo","choices":[{"index":0,"finish_reason":null,"delta":{"content":"为"}}],"usage":null}
data: {"id":"chatcmpl-6xGsJBcDHMv8KUJDuk14JV32ZL3BZ","object":"chat.completion.chunk","created":1679584239,"model":"gpt-35-turbo","choices":[{"index":0,"finish_reason":null,"delta":{"content":"您"}}],"usage":null}
data: {"id":"chatcmpl-6xGsJBcDHMv8KUJDuk14JV32ZL3BZ","object":"chat.completion.chunk","created":1679584239,"model":"gpt-35-turbo","choices":[{"index":0,"finish_reason":null,"delta":{"content":"做"}}],"usage":null}
data: {"id":"chatcmpl-6xGsJBcDHMv8KUJDuk14JV32ZL3BZ","object":"chat.completion.chunk","created":1679584239,"model":"gpt-35-turbo","choices":[{"index":0,"finish_reason":null,"delta":{"content":"的"}}],"usage":null}
data: {"id":"chatcmpl-6xGsJBcDHMv8KUJDuk14JV32ZL3BZ","object":"chat.completion.chunk","created":1679584239,"model":"gpt-35-turbo","choices":[{"index":0,"finish_reason":null,"delta":{"content":"吗"}}],"usage":null}
data: {"id":"chatcmpl-6xGsJBcDHMv8KUJDuk14JV32ZL3BZ","object":"chat.completion.chunk","created":1679584239,"model":"gpt-35-turbo","choices":[{"index":0,"finish_reason":null,"delta":{"content":"?"}}],"usage":null}
data: {"id":"chatcmpl-6xGsJBcDHMv8KUJDuk14JV32ZL3BZ","object":"chat.completion.chunk","created":1679584239,"model":"gpt-35-turbo","choices":[{"index":0,"finish_reason":"stop","delta":{}}],"usage":null}
data: [DONE]
对话完成无法 Stop:
直到超时:
可以分享一下您是怎么改的吗?谢谢
可以分享一下您是怎么改的吗?谢谢
等我改好了提 PR
跟到 chatgpt 这个包里面,发现接收请求最后的 [DONE] 竟然没收到,不知道为啥,POSTMAN 调用是正常的
已解决,做了个 proxy https://github.com/stulzq/azure-openai-proxy