Skip to content

Commit

Permalink
[major] Fix azure's printer effect and stop issue
Browse files Browse the repository at this point in the history
之前azure 解决了3.5的这些问题, 我就移除了针对这个model的特殊处理. 最近它们又把bug加回来了
  • Loading branch information
haibbo committed Apr 28, 2023
1 parent 0bdee5d commit 9a72fa5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
- 我没有自己的域名可以使用吗?
- 也可以, 参考: https://github.com/haibbo/cf-openai-azure-proxy/issues/3
- 实现打印机模式:
- Azure OpenAI Service's 回复是一段一段回复的(当前仅GPT-4有此问题, GPT-3的问题Azure已经解决)
- Azure OpenAI Service's 回复是一段一段回复的
- 返回给客户端的时候, 本项目拆出一条条的消息, 依次给, 达到打印机模式
- 项目也支持 Docker 部署(基于 wrangler)

Expand Down
5 changes: 2 additions & 3 deletions cf-openai-azure-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ async function handleRequest(request) {

const response = await fetch(fetchAPI, payload);

// Since Azure has fixed gpt-3's printer effect, do not have to stream it.
if (modelName.startsWith('gpt-3') || body?.stream != true){
if (body?.stream != true){
return response
}

Expand Down Expand Up @@ -102,7 +101,7 @@ async function stream(readable, writable) {
// Loop through all but the last line, which may be incomplete.
for (let i = 0; i < lines.length - 1; i++) {
await writer.write(encoder.encode(lines[i] + delimiter));
await sleep(50);
await sleep(30);
}

buffer = lines[lines.length - 1];
Expand Down

0 comments on commit 9a72fa5

Please sign in to comment.