mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-05-04 04:39:05 +00:00
fix: 修复PR的潜在问题
1. 解析ImageRequest的Extra时,处理err 2. DoResponse方法添加RelayModeImagesGenerations(fallthrough)
This commit is contained in:
@@ -37,12 +37,14 @@ func (a *Adaptor) ConvertAudioRequest(c *gin.Context, info *relaycommon.RelayInf
|
|||||||
|
|
||||||
func (a *Adaptor) ConvertImageRequest(c *gin.Context, info *relaycommon.RelayInfo, request dto.ImageRequest) (any, error) {
|
func (a *Adaptor) ConvertImageRequest(c *gin.Context, info *relaycommon.RelayInfo, request dto.ImageRequest) (any, error) {
|
||||||
// 解析extra到SFImageRequest里,以填入SiliconFlow特殊字段。若失败重建一个空的。
|
// 解析extra到SFImageRequest里,以填入SiliconFlow特殊字段。若失败重建一个空的。
|
||||||
extra, _ := common.Marshal(request.Extra)
|
|
||||||
sfRequest := &SFImageRequest{}
|
sfRequest := &SFImageRequest{}
|
||||||
err := common.Unmarshal(extra, sfRequest)
|
extra, err := common.Marshal(request.Extra)
|
||||||
|
if err == nil {
|
||||||
|
err = common.Unmarshal(extra, sfRequest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
sfRequest = &SFImageRequest{}
|
sfRequest = &SFImageRequest{}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sfRequest.Model = request.Model
|
sfRequest.Model = request.Model
|
||||||
sfRequest.Prompt = request.Prompt
|
sfRequest.Prompt = request.Prompt
|
||||||
@@ -122,6 +124,8 @@ func (a *Adaptor) DoResponse(c *gin.Context, resp *http.Response, info *relaycom
|
|||||||
fallthrough
|
fallthrough
|
||||||
case constant.RelayModeChatCompletions:
|
case constant.RelayModeChatCompletions:
|
||||||
fallthrough
|
fallthrough
|
||||||
|
case constant.RelayModeImagesGenerations:
|
||||||
|
fallthrough
|
||||||
default:
|
default:
|
||||||
if info.IsStream {
|
if info.IsStream {
|
||||||
usage, err = openai.OaiStreamHandler(c, info, resp)
|
usage, err = openai.OaiStreamHandler(c, info, resp)
|
||||||
|
|||||||
Reference in New Issue
Block a user