mirror of
				https://github.com/yangjian102621/geekai.git
				synced 2025-11-04 08:13:43 +08:00 
			
		
		
		
	chore: print error detail when call http api failed with mj
This commit is contained in:
		@@ -5,6 +5,8 @@ import (
 | 
				
			|||||||
	logger2 "chatplus/logger"
 | 
						logger2 "chatplus/logger"
 | 
				
			||||||
	"errors"
 | 
						"errors"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
 | 
						"io"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/imroc/req/v3"
 | 
						"github.com/imroc/req/v3"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -63,7 +65,8 @@ func (c *Client) Imagine(prompt string) (ImageRes, error) {
 | 
				
			|||||||
		SetErrorResult(&errRes).
 | 
							SetErrorResult(&errRes).
 | 
				
			||||||
		Post(apiURL)
 | 
							Post(apiURL)
 | 
				
			||||||
	if err != nil {
 | 
						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() {
 | 
						if r.IsErrorState() {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -35,7 +35,9 @@ func NewServicePool(db *gorm.DB, redisCli *redis.Client, manager *oss.UploaderMa
 | 
				
			|||||||
		if config.Enabled == false {
 | 
							if config.Enabled == false {
 | 
				
			||||||
			continue
 | 
								continue
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		config.ApiURL = "https://api.chat-plus.net"
 | 
							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)
 | 
							client := plus.NewClient(config)
 | 
				
			||||||
		name := fmt.Sprintf("mj-service-plus-%d", k)
 | 
							name := fmt.Sprintf("mj-service-plus-%d", k)
 | 
				
			||||||
		servicePlus := plus.NewService(name, taskQueue, notifyQueue, 10, 600, db, client)
 | 
							servicePlus := plus.NewService(name, taskQueue, notifyQueue, 10, 600, db, client)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user