You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I try to download/retrieve a binary file (eg. PNG image) created by an assistant, it get automatically cast to a string, so it can't be correctly parsed/displayed.
Hit this as well, and also using requests directly as a work-around for now. Related, the general OpenAI API documentation for this should probably cover the format/expectations of what's coming back in the /content request.
Note that you do not have to drop down to using raw requests here, the SDK exposes methods for accessing the raw response directly using .with_raw_response properties. e.g.
response=client.files.with_raw_response.retrieve_content('file-XXX')
response# APIResponseresponse.content# raw bytes
The reason we cast to a string is because you can upload files that are not a binary content and if you need the binary content you can use the above method.
We'll look into if there are any ways to make this easier & to document it better.
When I try to download/retrieve a binary file (eg. PNG image) created by an assistant, it get automatically cast to a string, so it can't be correctly parsed/displayed.
Eg:
There doesn't seem to be a clean way in the API to retrieve a file as raw bytes from what I can see.
This is important for code interpreter scenarios where the agent returns binary files that need to be rendered, like Images.
For others having this issue, you can just request the files directly using
requests
like:The text was updated successfully, but these errors were encountered: