From 42bc23cacf0192aba4fb2a476529f314ce34e8b2 Mon Sep 17 00:00:00 2001 From: RockYang Date: Tue, 16 Jul 2024 06:24:40 +0800 Subject: [PATCH] fixed bug for function call for openai --- api/handler/admin/admin_handler.go | 11 ++--------- api/handler/chatimpl/openai_handler.go | 4 ++-- web/.env.development | 4 ++-- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/api/handler/admin/admin_handler.go b/api/handler/admin/admin_handler.go index 3fceab8e..eaaaf8fd 100644 --- a/api/handler/admin/admin_handler.go +++ b/api/handler/admin/admin_handler.go @@ -8,6 +8,8 @@ package admin // * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ import ( + "context" + "fmt" "geekai/core" "geekai/core/types" "geekai/handler" @@ -16,11 +18,8 @@ import ( "geekai/store/vo" "geekai/utils" "geekai/utils/resp" - "context" - "fmt" "github.com/go-redis/redis/v8" "github.com/golang-jwt/jwt/v5" - "github.com/mojocn/base64Captcha" "time" "github.com/gin-gonic/gin" @@ -56,12 +55,6 @@ func (h *ManagerHandler) Login(c *gin.Context) { return } - // add captcha - if !base64Captcha.DefaultMemStore.Verify(data.CaptchaId, data.Captcha, true) { - resp.ERROR(c, "验证码错误!") - return - } - var manager model.AdminUser res := h.DB.Model(&model.AdminUser{}).Where("username = ?", data.Username).First(&manager) if res.Error != nil { diff --git a/api/handler/chatimpl/openai_handler.go b/api/handler/chatimpl/openai_handler.go index 97f76531..9c4c57ea 100644 --- a/api/handler/chatimpl/openai_handler.go +++ b/api/handler/chatimpl/openai_handler.go @@ -65,7 +65,7 @@ func (h *ChatHandler) sendOpenAiMessage( if !strings.Contains(line, "data:") || len(line) < 30 { continue } - + logger.Info(line) var responseBody = types.ApiResponse{} err = json.Unmarshal([]byte(line[6:]), &responseBody) if err != nil { // 数据解析出错 @@ -74,7 +74,7 @@ func (h *ChatHandler) sendOpenAiMessage( if len(responseBody.Choices) == 0 { // Fixed: 兼容 Azure API 第一个输出空行 continue } - if responseBody.Choices[0].Delta.Content == nil { + if responseBody.Choices[0].Delta.Content == nil && responseBody.Choices[0].Delta.ToolCalls == nil { continue } diff --git a/web/.env.development b/web/.env.development index ba889b03..27102ba0 100644 --- a/web/.env.development +++ b/web/.env.development @@ -1,5 +1,5 @@ -VUE_APP_API_HOST=http://172.22.11.69:5678 -VUE_APP_WS_HOST=ws://172.22.11.69:5678 +VUE_APP_API_HOST=http://localhost:5678 +VUE_APP_WS_HOST=ws://localhost:5678 VUE_APP_USER=18575670125 VUE_APP_PASS=12345678 VUE_APP_ADMIN_USER=admin