From bc6978ef77321a281216b2565775c4acdd4e6b79 Mon Sep 17 00:00:00 2001 From: shaoyongjun Date: Wed, 21 Feb 2024 12:37:24 +0800 Subject: [PATCH] to:sync --- apps/ai.go | 4 ++-- infrastructure/remote_http/ai-api-impl.go | 4 ++-- nomad-job-test.tpl.hcl | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/ai.go b/apps/ai.go index 318cf09..7c9f7b0 100644 --- a/apps/ai.go +++ b/apps/ai.go @@ -28,8 +28,8 @@ func InitAiGroup(g *echo.Group) { key := utils.ToString(corpId) + "_" + utils.ToString(bizId) + "_" + utils.ToString(uid) groupId := utils.GetCache(key) result, err := remote_http.AiApi.Completions(ctx, req.Prompt, groupId) - if err != nil { - return c.JSON(500, err) + if err != nil || result == nil { + return c.JSON(http.StatusOK, utils.Failed(err.Error())) } //缓存 diff --git a/infrastructure/remote_http/ai-api-impl.go b/infrastructure/remote_http/ai-api-impl.go index 2904cf5..a08d953 100644 --- a/infrastructure/remote_http/ai-api-impl.go +++ b/infrastructure/remote_http/ai-api-impl.go @@ -4,6 +4,7 @@ import ( "ai-gateway/common/dto" "ai-gateway/common/utils" "context" + "errors" "fmt" ) @@ -25,14 +26,13 @@ func (aiApiImpl) Completions(ctx context.Context, prompt, groupId string) (*dto. SetSuccessResult(&aiResult). Post(url) if err != nil { - logger.Error(fmt.Sprintf("remote_http_wx_SendMsg error: %s", err.Error())) return nil, err } if !resp.IsSuccessState() { logger.Error(fmt.Sprintf("remote_http_wx_SendMsg resp:%+v", resp)) - return nil, err + return nil, errors.New("接口异常") } return &aiResult.Data, nil diff --git a/nomad-job-test.tpl.hcl b/nomad-job-test.tpl.hcl index 8d33196..2ba3447 100644 --- a/nomad-job-test.tpl.hcl +++ b/nomad-job-test.tpl.hcl @@ -32,7 +32,7 @@ job "${APP_NAME}-${CI_COMMIT_BRANCH}-job" { network_mode = "djLay" # No port map required. - volumes = ["/opt/settings/server.properties:/opt/settings/server.properties"] +# volumes = ["/opt/settings/server.properties:/opt/settings/server.properties"] auth { server_address = "${CI_REGISTRY}"