feat: AudioRequest add metadata support custom params
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
package dto
|
package dto
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/QuantumNous/new-api/types"
|
"github.com/QuantumNous/new-api/types"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -14,6 +16,7 @@ type AudioRequest struct {
|
|||||||
ResponseFormat string `json:"response_format,omitempty"`
|
ResponseFormat string `json:"response_format,omitempty"`
|
||||||
Speed float64 `json:"speed,omitempty"`
|
Speed float64 `json:"speed,omitempty"`
|
||||||
StreamFormat string `json:"stream_format,omitempty"`
|
StreamFormat string `json:"stream_format,omitempty"`
|
||||||
|
Metadata json.RawMessage `json:"metadata,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *AudioRequest) GetTokenCountMeta() *types.TokenCountMeta {
|
func (r *AudioRequest) GetTokenCountMeta() *types.TokenCountMeta {
|
||||||
|
|||||||
@@ -75,6 +75,13 @@ func (a *Adaptor) ConvertAudioRequest(c *gin.Context, info *relaycommon.RelayInf
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 同步扩展字段的厂商自定义metadata
|
||||||
|
if len(request.Metadata) > 0 {
|
||||||
|
if err = json.Unmarshal(request.Metadata, &volcRequest); err != nil {
|
||||||
|
return nil, fmt.Errorf("error unmarshalling metadata to volcengine request: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
jsonData, err := json.Marshal(volcRequest)
|
jsonData, err := json.Marshal(volcRequest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error marshalling volcengine request: %w", err)
|
return nil, fmt.Errorf("error marshalling volcengine request: %w", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user