feat: AudioRequest add metadata support custom params
This commit is contained in:
17
dto/audio.go
17
dto/audio.go
@@ -1,19 +1,22 @@
|
|||||||
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"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AudioRequest struct {
|
type AudioRequest struct {
|
||||||
Model string `json:"model"`
|
Model string `json:"model"`
|
||||||
Input string `json:"input"`
|
Input string `json:"input"`
|
||||||
Voice string `json:"voice"`
|
Voice string `json:"voice"`
|
||||||
Instructions string `json:"instructions,omitempty"`
|
Instructions string `json:"instructions,omitempty"`
|
||||||
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