Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: audio and octet stream response #209

Closed
VisargD opened this issue Feb 15, 2024 · 0 comments · Fixed by #210
Closed

Fix: audio and octet stream response #209

VisargD opened this issue Feb 15, 2024 · 0 comments · Fixed by #210
Assignees
Labels
bug Something isn't working

Comments

@VisargD
Copy link
Collaborator

VisargD commented Feb 15, 2024

There are 2 issues with gateway's audio and octet-stream resonse forwarding.

  • For audio response, it has a hardcoded audio/mpeg content-type check. But OpenAI sends some other audio content types also. Example: audio/aac, audio/flac, etc. Due to the hardcoded check, the other types goes to JSON response handler instead of audio response handler

    } else if (responseContentType === CONTENT_TYPES.AUDIO_MPEG) {
    return handleAudioResponse(response)
    } else if (responseContentType === CONTENT_TYPES.APPLICATION_OCTET_STREAM) {

  • In handleAudioResponse function, JSON.stringifiy(response.body) is not required to forward the response as it is. JSON.stringify needs to be removed

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

  • In handleOctetStreamResponse function, JSON.stringifiy(response.body) is not required to forward the response as it is. JSON.stringify needs to be removed

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

@VisargD VisargD added the bug Something isn't working label Feb 15, 2024
@VisargD VisargD self-assigned this Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant