-
-
Notifications
You must be signed in to change notification settings - Fork 339
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
Content retrieval (and anything calling .get) only works for JSON #421
Comments
Same issue. UPLOAD FILE: https://platform.openai.com/docs/assistants/tools/passing-files-to-code-interpreter Here the library code: https://github.com/alexrudall/ruby-openai/blob/main/lib/openai/files.rb |
Having the same issue trying to send files. No matter the type of file I'm trying to send it tries to JSON parse it.
|
@thisismydesign Figure you've worked this out, but in case you're having issues, you can easily work around it just by using a built-in or gem-based HTTP library to make a call to the files endpoint RestClient.get(
"https://api.openai.com/v1/files/#{file_id}/content",
{Authorization: "Bearer #{ACCESS_TOKEN}"}
) |
Describe the bug
Attempting to retrieve the content of files via the API doesn't work unless the files are in
JSON
format; you'll get aJSON::ParserError
error, becauseget()
inhttp.rb
callsjsonparsel()
which callsJSON.parse(response)
for every request.For example, when trying to retrieve an image so we can attach it via ActiveStorage in order to easily display it to the user:
Simply returning the response if it's not JSON would resolve this.
To Reproduce
Steps to reproduce the behavior:
client.files.content(id: file_id)
Expected behavior
It should retrieve non-JSON content like generated PNGs successfully
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: