Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix #2484.
With the introduction of
base_url
in #2384 and a refacto in #2410, some bugs have been introduced on the logic to resolve the chat completion URL. This PR fixes definitely this with a dedicated_resolve_chat_completion_url
method. I added a bunch of parametrized tests to check every possible cases. It is now possible to:InferenceClient(model=...)
InferenceClient().chat_completion(model=...)
InferenceClient(model=...)
,InferenceClient(base_url=...)
orInferenceClient().chat_completion(model=...)
/
or not/v1
or not (for OpenAI compatibility)/v1/chat/completions
or notInferenceClient
and a model_id inchat_completion
(already the case before)With all of these use cases tested and working, I think this is fixed for good :)
Two minor unrelated changes:
src/huggingface_hub/utils/_http.py
(after oversight in Refacto error parsing (HfHubHttpError) #2474)Failing test is unrelated.