Skip to content

Conversation

gregszero
Copy link

@gregszero gregszero commented Oct 29, 2024

This pull request includes changes to the get method in the HTTP module within the lib/openai/http.rb file. The main purpose of these changes is to improve error handling when parsing JSON responses to address issue #421

Error handling improvements:

  • lib/openai/http.rb: Modified the get method to handle JSON::ParserError exceptions. If parsing the response body as JSON fails, the raw response body will be returned instead.

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?

there’s another PR addressing this issue, but since I found a solution that works for me, I believe the community could also benefit from this change

@gregszero gregszero marked this pull request as draft October 29, 2024 21:38
@gregszero gregszero marked this pull request as ready for review October 29, 2024 22:14
@thisismydesign
Copy link

@alexrudall Any chance or merging this?

@alexrudall
Copy link
Owner

I believe #566 resolves this issue - if you are able to could you give it a test @thisismydesign , @gregszero ? Thank you!

@thisismydesign
Copy link

@alexrudall Thanks for the fix, my specific file handling issue is already resolved as it turns out.

@alexrudall
Copy link
Owner

Fixed in ruby-openai v8

@alexrudall alexrudall closed this Mar 14, 2025
@manav-jain
Copy link

@alexrudall I am using v8.1.0 I am still facing JSON parsing issue when trying to access file content.

openai_client.files.content(id: batch['output_file_id'])

is returning:
Error getting batch results: unexpected characters after the JSON document (after ) at line 2, column 1 [parse.c:713]

@MarhicJeromeGIT
Copy link

@manav-jain FYI as I am having the same issue, I am opening a tentative fix PR here : #593

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.

5 participants