Commit 2ae6060a by CalciumIon

feat: support audio response_format #580

parent e9aeb881
...@@ -132,6 +132,19 @@ func (a *Adaptor) ConvertAudioRequest(c *gin.Context, info *relaycommon.RelayInf ...@@ -132,6 +132,19 @@ func (a *Adaptor) ConvertAudioRequest(c *gin.Context, info *relaycommon.RelayInf
writer.WriteField("model", request.Model) writer.WriteField("model", request.Model)
// 获取所有表单字段
formData := c.Request.PostForm
// 遍历表单字段并打印输出
for key, values := range formData {
if key == "model" {
continue
}
for _, value := range values {
writer.WriteField(key, value)
}
}
// 添加文件字段 // 添加文件字段
file, header, err := c.Request.FormFile("file") file, header, err := c.Request.FormFile("file")
if err != nil { if err != nil {
......
...@@ -33,15 +33,18 @@ func getAndValidAudioRequest(c *gin.Context, info *relaycommon.RelayInfo) (*dto. ...@@ -33,15 +33,18 @@ func getAndValidAudioRequest(c *gin.Context, info *relaycommon.RelayInfo) (*dto.
} }
} }
default: default:
err = c.Request.ParseForm()
if err != nil {
return nil, err
}
formData := c.Request.PostForm
if audioRequest.Model == "" { if audioRequest.Model == "" {
audioRequest.Model = c.PostForm("model") audioRequest.Model = formData.Get("model")
} }
if audioRequest.Model == "" { if audioRequest.Model == "" {
return nil, errors.New("model is required") return nil, errors.New("model is required")
} }
if audioRequest.ResponseFormat == "" {
audioRequest.ResponseFormat = "json"
}
} }
return audioRequest, nil return audioRequest, nil
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment