diff --git a/relay/channel/siliconflow/adaptor.go b/relay/channel/siliconflow/adaptor.go index 57e13d7e6..daffff180 100644 --- a/relay/channel/siliconflow/adaptor.go +++ b/relay/channel/siliconflow/adaptor.go @@ -37,11 +37,13 @@ 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) { // 解析extra到SFImageRequest里,以填入SiliconFlow特殊字段。若失败重建一个空的。 - extra, _ := common.Marshal(request.Extra) sfRequest := &SFImageRequest{} - err := common.Unmarshal(extra, sfRequest) - if err != nil { - sfRequest = &SFImageRequest{} + extra, err := common.Marshal(request.Extra) + if err == nil { + err = common.Unmarshal(extra, sfRequest) + if err != nil { + sfRequest = &SFImageRequest{} + } } sfRequest.Model = request.Model @@ -122,6 +124,8 @@ func (a *Adaptor) DoResponse(c *gin.Context, resp *http.Response, info *relaycom fallthrough case constant.RelayModeChatCompletions: fallthrough + case constant.RelayModeImagesGenerations: + fallthrough default: if info.IsStream { usage, err = openai.OaiStreamHandler(c, info, resp)