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

[InferenceClient] Provide a way to deal with content-type header when sending raw bytes #2706

Open
Wauplin opened this issue Dec 11, 2024 · 0 comments

Comments

@Wauplin
Copy link
Contributor

Wauplin commented Dec 11, 2024

First reported by @freddyaboulton on slack (private).

For some tasks (e.g. automatic-speech-recognition) we are sending raw bytes in the HTTP request. On InferenceAPI, there is a "content-type-guess" logic to implicitly interpret the data that is sent. However, this logic can be flawed and moreover, the Inference Endpoints don't have this logic.

It currently possible to provide the Content-Type headers by providing a value when initializing the InferenceClient :

client = InferenceClient(url, headers={"Content-Type": "audio/mpeg"})
response = client.automatic_speech_recognition("audio.mp3")

However this is not well documented + it doesn't feel correct to initialize a client with a specific content type (it would mean that all requests made with the client have to send the same content type).


Opening the issue here but not clear to me what we'd like to do. A few solutions could be:

  • (low hanging fruit) keep what we have but document how to set content-type headers in each method docstring
  • infer the content type header based on file extension (but don't work if raw bytes are passed to the method)
  • add a parameter? (but how would it work with auto-generation?)

Open to suggestions on this

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

1 participant