chore: print error detail when call http api failed with mj

This commit is contained in:
RockYang 2024-01-21 22:30:24 +08:00
parent 412f8ecc6c
commit 66c7717f04
2 changed files with 7 additions and 2 deletions

View File

@ -5,6 +5,8 @@ import (
logger2 "chatplus/logger"
"errors"
"fmt"
"io"
"github.com/imroc/req/v3"
)
@ -63,7 +65,8 @@ func (c *Client) Imagine(prompt string) (ImageRes, error) {
SetErrorResult(&errRes).
Post(apiURL)
if err != nil {
return ImageRes{}, fmt.Errorf("请求 API 出错:%v", err)
errStr, _ := io.ReadAll(r.Body)
return ImageRes{}, fmt.Errorf("请求 API 出错:%v%v", err, string(errStr))
}
if r.IsErrorState() {

View File

@ -35,7 +35,9 @@ func NewServicePool(db *gorm.DB, redisCli *redis.Client, manager *oss.UploaderMa
if config.Enabled == false {
continue
}
if config.ApiURL != "https://gpt.bemore.lol" && config.ApiURL != "https://api.chat-plus.net" {
config.ApiURL = "https://api.chat-plus.net"
}
client := plus.NewClient(config)
name := fmt.Sprintf("mj-service-plus-%d", k)
servicePlus := plus.NewService(name, taskQueue, notifyQueue, 10, 600, db, client)