讯飞响应 sid 错误码提示返回

This commit is contained in:
ybyang 2024-11-25 15:49:52 +08:00
parent ff24d0fab8
commit e7cc50d8cb

View File

@ -10,6 +10,7 @@ import (
"io"
"net/http"
"net/url"
"strconv"
"strings"
"time"
@ -206,6 +207,10 @@ func Handler(c *gin.Context, meta *meta.Meta, textRequest model.GeneralOpenAIReq
case stop = <-stopChan:
}
}
if xunfeiResponse.Header.Code != 0 {
return openai.ErrorWrapper(errors.New("xunfei response error: sid: "+xunfeiResponse.Header.Sid), strconv.Itoa(xunfeiResponse.Header.Code), http.StatusInternalServerError), nil
}
if len(xunfeiResponse.Payload.Choices.Text) == 0 {
return openai.ErrorWrapper(errors.New("xunfei empty response detected"), "xunfei_empty_response_detected", http.StatusInternalServerError), nil
}