fixed bug for function call for openai

This commit is contained in:
RockYang 2024-07-16 06:24:40 +08:00
parent f22c6bf658
commit 24a21bf2ee
3 changed files with 6 additions and 13 deletions

View File

@ -8,6 +8,8 @@ package admin
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
import ( import (
"context"
"fmt"
"geekai/core" "geekai/core"
"geekai/core/types" "geekai/core/types"
"geekai/handler" "geekai/handler"
@ -16,11 +18,8 @@ import (
"geekai/store/vo" "geekai/store/vo"
"geekai/utils" "geekai/utils"
"geekai/utils/resp" "geekai/utils/resp"
"context"
"fmt"
"github.com/go-redis/redis/v8" "github.com/go-redis/redis/v8"
"github.com/golang-jwt/jwt/v5" "github.com/golang-jwt/jwt/v5"
"github.com/mojocn/base64Captcha"
"time" "time"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
@ -56,12 +55,6 @@ func (h *ManagerHandler) Login(c *gin.Context) {
return return
} }
// add captcha
if !base64Captcha.DefaultMemStore.Verify(data.CaptchaId, data.Captcha, true) {
resp.ERROR(c, "验证码错误!")
return
}
var manager model.AdminUser var manager model.AdminUser
res := h.DB.Model(&model.AdminUser{}).Where("username = ?", data.Username).First(&manager) res := h.DB.Model(&model.AdminUser{}).Where("username = ?", data.Username).First(&manager)
if res.Error != nil { if res.Error != nil {

View File

@ -65,7 +65,7 @@ func (h *ChatHandler) sendOpenAiMessage(
if !strings.Contains(line, "data:") || len(line) < 30 { if !strings.Contains(line, "data:") || len(line) < 30 {
continue continue
} }
logger.Info(line)
var responseBody = types.ApiResponse{} var responseBody = types.ApiResponse{}
err = json.Unmarshal([]byte(line[6:]), &responseBody) err = json.Unmarshal([]byte(line[6:]), &responseBody)
if err != nil { // 数据解析出错 if err != nil { // 数据解析出错
@ -74,7 +74,7 @@ func (h *ChatHandler) sendOpenAiMessage(
if len(responseBody.Choices) == 0 { // Fixed: 兼容 Azure API 第一个输出空行 if len(responseBody.Choices) == 0 { // Fixed: 兼容 Azure API 第一个输出空行
continue continue
} }
if responseBody.Choices[0].Delta.Content == nil { if responseBody.Choices[0].Delta.Content == nil && responseBody.Choices[0].Delta.ToolCalls == nil {
continue continue
} }

View File

@ -1,5 +1,5 @@
VUE_APP_API_HOST=http://172.22.11.69:5678 VUE_APP_API_HOST=http://localhost:5678
VUE_APP_WS_HOST=ws://172.22.11.69:5678 VUE_APP_WS_HOST=ws://localhost:5678
VUE_APP_USER=18575670125 VUE_APP_USER=18575670125
VUE_APP_PASS=12345678 VUE_APP_PASS=12345678
VUE_APP_ADMIN_USER=admin VUE_APP_ADMIN_USER=admin