-
Notifications
You must be signed in to change notification settings - Fork 257
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
Incompatibility between OpenAI and HF's Chat Completion response_format
#932
Comments
Cc @drbh @Narsil @OlivierDehaene on the TGI side |
I have the same issue, I could easily add the Gemini and ChatGPT API, but with the Huggingface API I have to change my code and define JSON schemas, because both Gemini and GPT-4 work without a schema defined too. Can we get JSON responses without passing any value for the response_format ? Now I do this, I don't need to pass any schema and it works well (for Gemini/ChatGPT): |
If you try to simply use the OpenAI format, you get this error:
If you try to pass the required HF format to openai-node:
The request will fail with the error:
So, I assume the schema is still not properly sent. Any way to use HF chat completion with response_format json or json_schema through openai-node? EDIT: It seems to work, the problem was with the JSON schema. This works in OpenAI I had to change it to this for HF:
|
Hi there!
OpenAI and HF api seem to have diverged on chat_completion
response_format
. That of the OpenAI has atype
attribute which takes one of three valuestext
,json_object
(free-form JSON generation which isn't in TGI yet) andjson_schema
, and for the last one it has anotherjson_schema
attribute which itself containsname
,schema
,description
andstrict
attributes.On the other hand, HF's
response_format: ChatCompletionInputGrammarType
containstype
andvalue
attributes.This might break the OpenAI api usability on HF models. Could we have compatibility between these two on this matter? Or does it need probably breaking changes in TGI and huggingface_hub?
@Wauplin
The text was updated successfully, but these errors were encountered: