fix: testing channel reject if not 200

This commit is contained in:
ckt1031 2023-07-10 23:09:15 +08:00
parent bde43cc358
commit 4b2cb573b6
2 changed files with 5 additions and 1 deletions

View File

@ -55,6 +55,10 @@ func testChannel(channel *model.Channel, request ChatRequest) error {
return err return err
} }
if resp.StatusCode != 200 {
return errors.New("invalid status code: " + strconv.Itoa(resp.StatusCode))
}
var response TextResponse var response TextResponse
isStream := strings.HasPrefix(resp.Header.Get("Content-Type"), "text/event-stream") isStream := strings.HasPrefix(resp.Header.Get("Content-Type"), "text/event-stream")
var streamResponseText string var streamResponseText string

View File

@ -23,7 +23,7 @@ var buildFS embed.FS
var indexPage []byte var indexPage []byte
func main() { func main() {
godotenv.Load() godotenv.Load(".env")
common.SetupGinLog() common.SetupGinLog()
common.SysLog("One API " + common.Version + " started") common.SysLog("One API " + common.Version + " started")