Route chat management calls to the service root (#47138) - #47303
Merged
SunMarc merged 6 commits intoJul 22, 2026
Conversation
transformers chat reuses base_url for the serve management endpoints, so with the documented base_url ending in /v1 the health check requests /v1/health and model loading posts to /v1/load_model. The serve app mounts /health, /load_model and /reset at the service root; only the OpenAI-compatible inference API lives under /v1. Derive the management base url by stripping a trailing /v1 segment and use it for check_health and print_model_load, while the AsyncInferenceClient keeps the full base_url. A base_url without /v1 is unchanged, and a /v1 under a reverse-proxy prefix keeps the prefix. Signed-off-by: Dhruv Sharma <dhruv7477@gmail.com>
Member
|
cc @SunMarc @remi-or @LysandreJik for serving, see also the original issue at #47138! |
SunMarc
reviewed
Jul 22, 2026
Signed-off-by: Dhruv Sharma <dhruv7477@gmail.com>
SunMarc
reviewed
Jul 22, 2026
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
…place Signed-off-by: Dhruv Sharma <dhruv7477@gmail.com>
Contributor
CI recapDashboard: View test results in Grafana |
SunMarc
approved these changes
Jul 22, 2026
SunMarc
enabled auto-merge
July 22, 2026 15:30
stevhliu
pushed a commit
to stevhliu/transformers
that referenced
this pull request
Jul 30, 2026
…uggingface#47303) * Route chat management calls to the service root (huggingface#47138) transformers chat reuses base_url for the serve management endpoints, so with the documented base_url ending in /v1 the health check requests /v1/health and model loading posts to /v1/load_model. The serve app mounts /health, /load_model and /reset at the service root; only the OpenAI-compatible inference API lives under /v1. Derive the management base url by stripping a trailing /v1 segment and use it for check_health and print_model_load, while the AsyncInferenceClient keeps the full base_url. A base_url without /v1 is unchanged, and a /v1 under a reverse-proxy prefix keeps the prefix. Signed-off-by: Dhruv Sharma <dhruv7477@gmail.com> * Address review: rename helper to get_service_root_url, drop mocked tests Signed-off-by: Dhruv Sharma <dhruv7477@gmail.com> * Build the service root url with urlunparse instead of ParseResult._replace Signed-off-by: Dhruv Sharma <dhruv7477@gmail.com> --------- Signed-off-by: Dhruv Sharma <dhruv7477@gmail.com>
Sainava
pushed a commit
to Sainava/Sai-transformers
that referenced
this pull request
Aug 3, 2026
…uggingface#47303) * Route chat management calls to the service root (huggingface#47138) transformers chat reuses base_url for the serve management endpoints, so with the documented base_url ending in /v1 the health check requests /v1/health and model loading posts to /v1/load_model. The serve app mounts /health, /load_model and /reset at the service root; only the OpenAI-compatible inference API lives under /v1. Derive the management base url by stripping a trailing /v1 segment and use it for check_health and print_model_load, while the AsyncInferenceClient keeps the full base_url. A base_url without /v1 is unchanged, and a /v1 under a reverse-proxy prefix keeps the prefix. Signed-off-by: Dhruv Sharma <dhruv7477@gmail.com> * Address review: rename helper to get_service_root_url, drop mocked tests Signed-off-by: Dhruv Sharma <dhruv7477@gmail.com> * Build the service root url with urlunparse instead of ParseResult._replace Signed-off-by: Dhruv Sharma <dhruv7477@gmail.com> --------- Signed-off-by: Dhruv Sharma <dhruv7477@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do?
Fixes #47138
transformers chatreusesbase_urlfor the serve management endpoints. With the documentedbase_urlending in/v1, the health check requests/v1/healthand model loading posts to/v1/load_model. The serve app mounts/health,/load_modeland/resetat the service root; only the OpenAI-compatible inference API lives under/v1. Ran the numbers on both sides to be sure:server.pyregisters the management routes at root, andchat.pybuilds both management URLs from the rawbase_url.The fix derives a management base url by stripping a trailing
/v1segment and routescheck_healthandprint_model_loadthrough it, while theAsyncInferenceClientkeeps the fullbase_urlfor inference. Deliberately boring on the edges: abase_urlwithout/v1behaves exactly as before, and a/v1behind a reverse-proxy prefix keeps the prefix (https://host/proxy/v1manages athttps://host/proxy).Tests cover the url derivation and both management calls, mocked, so they run anywhere with no model download.
Who can review?
CLI / serving: @Rocketknight1