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

Content retrieval (and anything calling .get) only works for JSON #421

Open
DanL12186 opened this issue Jan 19, 2024 · 1 comment
Open

Comments

@DanL12186
Copy link

DanL12186 commented Jan 19, 2024

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 a JSON::ParserError error, because get() in http.rb calls jsonparsel() which calls JSON.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:

>> client.files.content(id: "file-xyz123")
JSON::ParserError: 451: unexpected token at '?PNG

Simply returning the response if it's not JSON would resolve this.

To Reproduce
Steps to reproduce the behavior:

  1. Have the API generate a file for you
  2. Call client.files.content(id: file_id)
  3. See error

Expected behavior
It should retrieve non-JSON content like generated PNGs successfully

Desktop (please complete the following information):

  • OS: MacOS X 10.15.7
  • Browser Chrome
  • Version 121
@leoplct
Copy link

leoplct commented Mar 23, 2024

Same issue.
The API supports the parameter purpose="assistants" and accepts several formats.

UPLOAD FILE: https://platform.openai.com/docs/assistants/tools/passing-files-to-code-interpreter
Accepted formats: https://platform.openai.com/docs/assistants/tools/supported-files

Here the library code: https://github.com/alexrudall/ruby-openai/blob/main/lib/openai/files.rb

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

No branches or pull requests

2 participants