From d0e296adf82ffd169554ef8ab97f1005dabd0bbb Mon Sep 17 00:00:00 2001 From: HyiKi Date: Mon, 5 Aug 2024 15:41:13 +0800 Subject: [PATCH 1/4] fix: baidu error_code 336006 --- app/client/platforms/baidu.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/client/platforms/baidu.ts b/app/client/platforms/baidu.ts index 188b78bf9..29c020df4 100644 --- a/app/client/platforms/baidu.ts +++ b/app/client/platforms/baidu.ts @@ -77,7 +77,8 @@ export class ErnieApi implements LLMApi { async chat(options: ChatOptions) { const messages = options.messages.map((v) => ({ - role: v.role, + // "error_code": 336006, "error_msg": "the role of message with odd index in the messages must be assistant", + role: v.role === "system" ? "assistant" : v.role, content: getMessageTextContent(v), })); From 9ab45c396919d37221521a737f41b5591c52c856 Mon Sep 17 00:00:00 2001 From: HyiKi Date: Mon, 5 Aug 2024 20:50:36 +0800 Subject: [PATCH 2/4] fix: baidu error_code 336006 change the summary role from system to user --- app/client/platforms/baidu.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/app/client/platforms/baidu.ts b/app/client/platforms/baidu.ts index 29c020df4..3be147f49 100644 --- a/app/client/platforms/baidu.ts +++ b/app/client/platforms/baidu.ts @@ -77,17 +77,24 @@ export class ErnieApi implements LLMApi { async chat(options: ChatOptions) { const messages = options.messages.map((v) => ({ - // "error_code": 336006, "error_msg": "the role of message with odd index in the messages must be assistant", - role: v.role === "system" ? "assistant" : v.role, + // "error_code": 336006, "error_msg": "the role of message with even index in the messages must be user or function", + role: v.role === "system" ? "user" : v.role, content: getMessageTextContent(v), })); // "error_code": 336006, "error_msg": "the length of messages must be an odd number", if (messages.length % 2 === 0) { - messages.unshift({ - role: "user", - content: " ", - }); + if (messages.at(0)?.role === "user") { + messages.splice(1, 0, { + role: "assistant", + content: " ", + }); + } else { + messages.unshift({ + role: "user", + content: " ", + }); + } } const modelConfig = { From d7e2ee63d87bb713231e11d3ff2dabb3b1904e0c Mon Sep 17 00:00:00 2001 From: HyiKi Date: Tue, 6 Aug 2024 10:45:25 +0800 Subject: [PATCH 3/4] fix: tencent InvalidParameter error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix "Messages 中 system 角色必须位于列表的最开始" --- app/client/platforms/tencent.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/client/platforms/tencent.ts b/app/client/platforms/tencent.ts index e9e49d3f0..579008a9b 100644 --- a/app/client/platforms/tencent.ts +++ b/app/client/platforms/tencent.ts @@ -91,8 +91,9 @@ export class HunyuanApi implements LLMApi { async chat(options: ChatOptions) { const visionModel = isVisionModel(options.config.model); - const messages = options.messages.map((v) => ({ - role: v.role, + const messages = options.messages.map((v, index) => ({ + // "Messages 中 system 角色必须位于列表的最开始" + role: index !== 0 && v.role === "system" ? "user" : v.role, content: visionModel ? v.content : getMessageTextContent(v), })); From 685f5479a8fd0ef1ba88f959b9557a4b81736434 Mon Sep 17 00:00:00 2001 From: sijinhui Date: Tue, 6 Aug 2024 14:06:10 +0800 Subject: [PATCH 4/4] change docker image url --- .github/workflows/dockerToHub.yml | 6 +++--- docker-compose.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dockerToHub.yml b/.github/workflows/dockerToHub.yml index cb204e7c8..75efe7c1c 100644 --- a/.github/workflows/dockerToHub.yml +++ b/.github/workflows/dockerToHub.yml @@ -25,7 +25,7 @@ jobs: github-server-url: 'https://gh.sivpn.cn' - name: build and deploy to Docker Hub run: | - echo ${{ secrets.DOCKER_PASSWORD }} | docker login registry.gitlab.si.icu -u ${{ secrets.DOCKER_USERNAME }} --password-stdin + echo ${{ secrets.DOCKER_PASSWORD }} | docker login registry.si.icu -u ${{ secrets.DOCKER_USERNAME }} --password-stdin echo "${{ secrets.DOCKER_ENV }}" > .env - name: Get current date run: echo "DATE_TAG=$(date +'%Y%m%d')" >> $GITHUB_ENV @@ -35,8 +35,8 @@ jobs: context: . push: true tags: | - registry.gitlab.si.icu/sijinhui/chatgpt-next-web:latest - registry.gitlab.si.icu/sijinhui/chatgpt-next-web:${{ env.DATE_TAG }} + registry.si.icu/sijinhui/chatgpt-next-web:latest + registry.si.icu/sijinhui/chatgpt-next-web:${{ env.DATE_TAG }} - name: clean build history run: | yes | docker system prune --filter "until=720h" diff --git a/docker-compose.yml b/docker-compose.yml index dad72662d..164c541a1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,7 @@ services: chatgpt-next-web: container_name: chatgpt-next-web restart: always - image: registry.gitlab.si.icu/sijinhui/chatgpt-next-web + image: registry.si.icu/sijinhui/chatgpt-next-web build: context: . dockerfile: Dockerfile