Skip to content
Merged
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
11 changes: 6 additions & 5 deletions azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,12 @@ var jsonRoutes = map[string]bool{
"/openai/images/generations": true,
}

// audioMultipartRoutes have mime/multipart payloads. These are less generic - we're very much
// multipartRoutes have mime/multipart payloads. These are less generic - we're very much
// expecting a transcription or translation payload for these.
var audioMultipartRoutes = map[string]bool{
var multipartRoutes = map[string]bool{
"/openai/audio/transcriptions": true,
"/openai/audio/translations": true,
"/openai/images/edits": true,
}

// getReplacementPathWithDeployment parses the request body to extract out the Model parameter (or equivalent)
Expand All @@ -150,8 +151,8 @@ func getReplacementPathWithDeployment(req *http.Request) (string, error) {
return getJSONRoute(req)
}

if audioMultipartRoutes[req.URL.Path] {
return getAudioMultipartRoute(req)
if multipartRoutes[req.URL.Path] {
return getMultipartRoute(req)
}

// No need to relocate the path. We've already tacked on /openai when we setup the endpoint.
Expand Down Expand Up @@ -181,7 +182,7 @@ func getJSONRoute(req *http.Request) (string, error) {
return strings.Replace(req.URL.Path, "/openai/", "/openai/deployments/"+escapedDeployment+"/", 1), nil
}

func getAudioMultipartRoute(req *http.Request) (string, error) {
func getMultipartRoute(req *http.Request) (string, error) {
// body is a multipart/mime body type instead.
mimeBytes, err := io.ReadAll(req.Body)

Expand Down