0319 - 小程序中实现 ChatGPT 的流式响应

要在小程序中实现 ChatGPT 的流式响应,还挺麻烦,涉及的环节比较多:

  • 小程序 wx.request 中开启 enableChunked;

  • 请求 OpenAI 接口时,开启 stream;

  • Axios 指定返回类型为 stream;

  • nginx 服务器配置中,开启 chunked_transfer_encoding,关闭 proxy_buffering