alexrudall / ruby-openai

OpenAI API + Ruby! 🤖❤️ NEW: Assistant Vector Stores
MIT License
2.61k stars 302 forks source link

Fix files content endpoint #474

Open willywg opened 1 month ago

willywg commented 1 month ago

This PR addresses issues #421 and #450.

It fixes the client.files.content API endpoint. The current implementation requires parsing the response body to JSON. However, some responses (like files generated by the Assistant API) need to be handled as pure response body content, such as a PNG file.

All Submissions:

mepatterson commented 2 weeks ago

+1 since the Batches examples in the docs fail when retrieving the final content results for this same reason.

alexrudall commented 2 weeks ago

Thanks @willywg @mepatterson -- in my understanding Faraday should only try to handle as json if the response header is Content-Type: application/json or similar -- wonder if we could do something similar so that users don't need to do anything different? In your examples OpenAI sends application/octet-stream so I think this could work

mepatterson commented 2 weeks ago

Makes sense to me