Closed RamonKaspar closed 1 month ago
Hi @RamonKaspar, thanks for reporting this issue. This doesn't seem to be an issue with the InferenceClient
but rather the server not handling this. cc @drbh @OlivierDehaene could you have a look at this issue to know why the payload is considered as an unprocessable entity by TGI? Maybe returning why the payload is an unprocessable entity would help (similar to what pydantic does).
Btw, I've tried to run the same code with:
client = OpenAI(
base_url="https://api-inference.huggingface.co/models/meta-llama/Meta-Llama-3-8B-Instruct/v1",
api_key=os.getenv("HF_TOKEN")
)
and the issue is the same. This proves that the problem is not client side (since both clients result in the same error) but server-side.
@RamonKaspar what is the output from openai client using an openai endpoint (model="gpt-4o-mini",
?) when sending a tool with empty enum? I've investigated the error with @drbh and it doesn't seem be an error to us. The user provides as input a tool that is impossible to satisfy given the enum is empty. The server raises an exception since it cannot provide any input.
However, we do agree the error message expected value at line 1 column 53
is not explicit enough and should ideally be improved further. This is not something to fix in huggingface_hub
itself but client-side in TGI.
Hi @Wauplin ,
Using the OpenAI client with the gpt-4o-mini
model and an empty enum for the format parameter successfully executes the function, filling in "Fahrenheit" as the format:
Function(arguments='{"location":"San Francisco, CA","format":"Fahrenheit"}', name='get_current_weather')
I understand that an empty enum technically represents a constraint that isn’t satisfiable. However, my initial report was motivated by the inconsistency between the Huggingface and OpenAI clients, especially since the HF documentation suggests that they should function interchangeably...
Thanks for the example @RamonKaspar. For what I understand, this is not an inconsistency between OpenAI and Huggingface clients but an inconsistency between OpenAI and TGI (text-generation-inference) servers on how to deal with empty tools.
What the documentation means about OpenAI/InferenceClient interchangeability is that for the same server, one can use both clients with the same result. If you use OpenAI client with https://api-inference.huggingface.co/models/meta-llama/Meta-Llama-3-8B-Instruct/v1
(i.e. HF server), you get the same issue.
Therefore, what I would suggest is to close this issue and re-open one in TGI. I'm not sure there's something to change server-side as this seems more a bug on OpenAI side that does not fulfill the constraint when not applicable (and still doesn't raise a warning/error).
Describe the bug
The
huggingface_hub
inference client does not support an emptyenum
list in tool parameters, while the OpenAI client does. This causes compatibility issues when switching between the two clients.Reproduction
When running the following code using the OpenAI client, everything works fine (the client handles the empty
enum
list). However, using the HFInferenceClient
results in an exception.Logs
System info