Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions dto/audio.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ type AudioRequest struct {
Speed *float64 `json:"speed,omitempty"`
StreamFormat string `json:"stream_format,omitempty"`
Metadata json.RawMessage `json:"metadata,omitempty"`
// vllm-omini
TaskType json.RawMessage `json:"task_type,omitempty"`
Language json.RawMessage `json:"language,omitempty"`
RefAudio json.RawMessage `json:"ref_audio,omitempty"`
RefText json.RawMessage `json:"ref_text,omitempty"`
XVectorOnlyMode json.RawMessage `json:"x_vector_only_mode,omitempty"`
MaxNewTokens json.RawMessage `json:"max_new_tokens,omitempty"`
InitialCodecChunkFrames json.RawMessage `json:"initial_codec_chunk_frames,omitempty"`
Comment on lines +26 to +28

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Use typed pointer scalars for scalar extension parameters.

Line 26-Line 28 are optional scalar-style request params but currently use json.RawMessage. This loses type guarantees and conflicts with the DTO scalar-field rule.

💡 Suggested change
-	XVectorOnlyMode         json.RawMessage `json:"x_vector_only_mode,omitempty"`
-	MaxNewTokens            json.RawMessage `json:"max_new_tokens,omitempty"`
-	InitialCodecChunkFrames json.RawMessage `json:"initial_codec_chunk_frames,omitempty"`
+	XVectorOnlyMode         *bool `json:"x_vector_only_mode,omitempty"`
+	MaxNewTokens            *int  `json:"max_new_tokens,omitempty"`
+	InitialCodecChunkFrames *int  `json:"initial_codec_chunk_frames,omitempty"`

As per coding guidelines, dto/**/*.go optional scalar fields MUST use pointer types with omitempty to preserve explicit zero values.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
XVectorOnlyMode json.RawMessage `json:"x_vector_only_mode,omitempty"`
MaxNewTokens json.RawMessage `json:"max_new_tokens,omitempty"`
InitialCodecChunkFrames json.RawMessage `json:"initial_codec_chunk_frames,omitempty"`
XVectorOnlyMode *bool `json:"x_vector_only_mode,omitempty"`
MaxNewTokens *int `json:"max_new_tokens,omitempty"`
InitialCodecChunkFrames *int `json:"initial_codec_chunk_frames,omitempty"`
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@dto/audio.go` around lines 26 - 28, The three optional scalar fields
XVectorOnlyMode, MaxNewTokens, and InitialCodecChunkFrames in the dto.audio
struct currently use json.RawMessage which loses type guarantees; change them to
typed pointer scalar fields (e.g., *bool for XVectorOnlyMode and *int for
MaxNewTokens and InitialCodecChunkFrames or the correct scalar types used
elsewhere in the codebase), keep the `json:"...,omitempty"` tags, and remove
json.RawMessage so the DTO follows the scalar-pointer rule and preserves
explicit zero values.

// TODO:ensure that the logic remains correct after the stream is started.
//Stream json.RawMessage `json:"stream,omitempty"`
}

func (r *AudioRequest) GetTokenCountMeta() *types.TokenCountMeta {
Expand Down
2 changes: 1 addition & 1 deletion relay/channel/openai/adaptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ func (a *Adaptor) ConvertEmbeddingRequest(c *gin.Context, info *relaycommon.Rela
func (a *Adaptor) ConvertAudioRequest(c *gin.Context, info *relaycommon.RelayInfo, request dto.AudioRequest) (io.Reader, error) {
a.ResponseFormat = request.ResponseFormat
if info.RelayMode == relayconstant.RelayModeAudioSpeech {
jsonData, err := json.Marshal(request)
jsonData, err := common.Marshal(request)
if err != nil {
return nil, fmt.Errorf("error marshalling object: %w", err)
}
Expand Down