From c2c455c9807f0d92f4b4c4ba956fef8cf5ff9145 Mon Sep 17 00:00:00 2001 From: glzjin Date: Tue, 1 Aug 2023 23:51:28 +0800 Subject: [PATCH 1/2] fix: fix zhipu streaming (#349) * Fix #348 * chore: update implementation --------- Co-authored-by: JustSong --- controller/relay-zhipu.go | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/controller/relay-zhipu.go b/controller/relay-zhipu.go index 33d141c7..20a4fa42 100644 --- a/controller/relay-zhipu.go +++ b/controller/relay-zhipu.go @@ -194,8 +194,8 @@ func zhipuStreamHandler(c *gin.Context, resp *http.Response) (*OpenAIErrorWithSt if atEOF && len(data) == 0 { return 0, nil, nil } - if i := strings.Index(string(data), "\n"); i >= 0 { - return i + 1, data[0:i], nil + if i := strings.Index(string(data), "\n\n"); i >= 0 && strings.Index(string(data), ":") >= 0 { + return i + 2, data[0:i], nil } if atEOF { return len(data), data, nil @@ -208,14 +208,19 @@ func zhipuStreamHandler(c *gin.Context, resp *http.Response) (*OpenAIErrorWithSt go func() { for scanner.Scan() { data := scanner.Text() - data = strings.Trim(data, "\"") - if len(data) < 5 { // ignore blank line or wrong format - continue - } - if data[:5] == "data:" { - dataChan <- data[5:] - } else if data[:5] == "meta:" { - metaChan <- data[5:] + lines := strings.Split(data, "\n") + for i, line := range lines { + if len(line) < 5 { + continue + } + if line[:5] == "data:" { + dataChan <- line[5:] + if i != len(lines)-1 { + dataChan <- "\n" + } + } else if line[:5] == "meta:" { + metaChan <- line[5:] + } } } stopChan <- true From afcd1bd27b939bef31d70712ff2222c394fdfbf7 Mon Sep 17 00:00:00 2001 From: a497625414 <55976729+a497625414@users.noreply.github.com> Date: Wed, 2 Aug 2023 19:11:21 +0800 Subject: [PATCH 2/2] docs: update deploy-on-sealos (#351) --- README.en.md | 3 ++- README.md | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.en.md b/README.en.md index 1c5968bc..c43ee3af 100644 --- a/README.en.md +++ b/README.en.md @@ -173,7 +173,8 @@ If you encounter a blank page after deployment, refer to [#97](https://github.co Deploy on Sealos
-Please refer to [this tutorial](https://github.com/c121914yu/FastGPT/blob/main/docs/deploy/one-api/sealos.md). +[![](https://raw.githubusercontent.com/labring-actions/templates/main/Deploy-on-Sealos.svg)](https://cloud.sealos.io/?openapp=system-fastdeploy?templateName=one-api) +
diff --git a/README.md b/README.md index 55b2ecec..a7c06fc5 100644 --- a/README.md +++ b/README.md @@ -211,9 +211,9 @@ docker run --name chatgpt-web -d -p 3002:3002 -e OPENAI_API_BASE_URL=https://ope 部署到 Sealos
-> Sealos 可视化部署,仅需 1 分钟。 +> Sealos 可视化一键部署。 -参考这个[教程](https://github.com/c121914yu/FastGPT/blob/main/docs/deploy/one-api/sealos.md)中 1~5 步。 +[![](https://raw.githubusercontent.com/labring-actions/templates/main/Deploy-on-Sealos.svg)](https://cloud.sealos.io/?openapp=system-fastdeploy?templateName=one-api)