Skip to content

Commit

Permalink
Merge pull request #210 from Portkey-AI/fix/audio-response
Browse files Browse the repository at this point in the history
Fix: audio and octet stream response
  • Loading branch information
VisargD authored Feb 15, 2024
2 parents 33b1122 + 803ec03 commit 438d624
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ export const CONTENT_TYPES = {
MULTIPART_FORM_DATA: "multipart/form-data",
EVENT_STREAM: "text/event-stream",
AUDIO_MPEG: "audio/mpeg",
APPLICATION_OCTET_STREAM: "application/octet-stream"
APPLICATION_OCTET_STREAM: "application/octet-stream",
GENERIC_AUDIO_PATTERN: "audio"
}
2 changes: 1 addition & 1 deletion src/handlers/handlerUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ export function responseHandler(response: Response, streamingMode: boolean, prox
return handleJSONToStreamResponse(response, proxyProvider, responseTransformerFunction)
} else if (streamingMode && response.status === 200) {
return handleStreamingMode(response, proxyProvider, responseTransformerFunction, requestURL)
} else if (responseContentType === CONTENT_TYPES.AUDIO_MPEG) {
} else if (responseContentType?.startsWith(CONTENT_TYPES.GENERIC_AUDIO_PATTERN)) {
return handleAudioResponse(response)
} else if (responseContentType === CONTENT_TYPES.APPLICATION_OCTET_STREAM) {
return handleOctetStreamResponse(response)
Expand Down
4 changes: 2 additions & 2 deletions src/handlers/streamHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ export async function handleNonStreamingMode(response: Response, responseTransfo
}

export async function handleAudioResponse(response: Response) {
return new Response(JSON.stringify(response.body), response);
return new Response(response.body, response);
}

export async function handleOctetStreamResponse(response: Response) {
return new Response(JSON.stringify(response.body), response);
return new Response(response.body, response);
}


Expand Down

0 comments on commit 438d624

Please sign in to comment.