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

client.files.content(id: "file-123") failing for image_files because of JSON parse #450

Open
Lasvad opened this issue Apr 4, 2024 · 1 comment

Comments

@Lasvad
Copy link

Lasvad commented Apr 4, 2024

Describe the bug
Reading files such as pngs that are generated by code interpreter seem to fail as the response is expected to be JSON

Doc reference this to read file content: client.files.content(id: "file-123")

example

Code interpreter returns...

"content"=>
  [{"type"=>"image_file", "image_file"=>{"file_id"=>"file-stub"}},
   {"type"=>"text",
    "text"=>
     {"value"=>

using the cmd

client.files.content(id: "file-stub")

returns

(JSON::ParserError)s/ruby-3.2.2/lib/ruby/3.2.0/json/common.rb:216:in `parse': unexpected token at '\x89PNG

I've tried to use File.write, TempFile, StringIO but the JSON parse error continues.

To Reproduce
Steps to reproduce the behavior:

  1. Use Assistant to create a png with code interpreter
  2. Try to read the file_id that is provided in the response
  3. Error shows when using client.files.content(id: "file-123")

Expected behavior
Need a way to parse image_files files from OpenAI

Screenshots
image

Desktop (please complete the following information):

  • OS: Mac
  • Browser N/A

Additional context
ruby 3.2.2
Rails 7.0.4.3

@DanL12186
Copy link

DanL12186 commented May 1, 2024

Duplicate of this issue

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