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:fix response format bug #277

Closed
wants to merge 0 commits into from
Closed

Conversation

guaguaguaxia
Copy link
Contributor

fix this issue:#243

Comment on lines 670 to 673
if self.response_format == ResponseFormat.JSON:
data = json.loads(rbody)
else:
data = rbody

Choose a reason for hiding this comment

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

I checked and the Content-Type header on the response is always set correctly (at least for the audio transcription responses), so we can deduce whether to json-decode without any other code changes.
For the json and verbose_json response formats, the Content-Type is 'application/json', while for text, srt, and vtt, the Content-Type is 'text/plain; charset=utf-8'`.

Suggested change
if self.response_format == ResponseFormat.JSON:
data = json.loads(rbody)
else:
data = rbody
if rheaders.get('Content-Type') == 'application/json':
data = json.loads(rbody)
else:
data = rbody

@guaguaguaxia
Copy link
Contributor Author

@MattFisher please review in #282, i don't know how i close this PR 😭

@guaguaguaxia
Copy link
Contributor Author

@MattFisher because i force rollback my code so github close this PR automatically,so please review in #282

@guaguaguaxia
Copy link
Contributor Author

@logankilpatrick @mpokrass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants