Fix vllm_api_general_chat endpoint join for base URLs without trailing slash#313
Open
Copilot wants to merge 2 commits into
Open
Fix vllm_api_general_chat endpoint join for base URLs without trailing slash#313Copilot wants to merge 2 commits into
Copilot wants to merge 2 commits into
Conversation
4 tasks
Copilot
AI
changed the title
[WIP] Fix URL missing trailing slash in vllm_api_general_chat configuration
Fix vllm_api_general_chat endpoint join for base URLs without trailing slash
May 29, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes incorrect URL construction in VLLMCustomAPIChat when a custom base URL contains a subpath but lacks a trailing slash, ensuring requests hit the intended /v1/chat/completions endpoint and preventing empty predictions/incorrect metrics.
Changes:
- Normalize
base_urlto always end with/beforeurllib.parse.urljoininVLLMCustomAPIChat._get_url. - Add a unit test case covering a custom subpath URL without a trailing slash.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
ais_bench/benchmark/models/api_models/vllm_custom_api_chat.py |
Normalizes base_url prior to joining the chat-completions endpoint to avoid dropping the last path segment. |
tests/UT/models/api_models/test_vllm_custom_api_chat.py |
Adds a regression assertion for subpath base URLs without a trailing slash. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+86
to
+89
| # 测试自定义URL不带末尾/的情况 | ||
| model.base_url = "http://127.0.0.1:9000/member1/deepseek_v4" | ||
| url = model._get_url() | ||
| self.assertEqual(url, "http://127.0.0.1:9000/member1/deepseek_v4/v1/chat/completions") |
| model.base_url = "http://127.0.0.1:9000/member1/deepseek_v4" | ||
| url = model._get_url() | ||
| self.assertEqual(url, "http://127.0.0.1:9000/member1/deepseek_v4/v1/chat/completions") | ||
|
|
Comment on lines
96
to
99
| endpoint = "v1/chat/completions" | ||
| url = urllib.parse.urljoin(self.base_url, endpoint) | ||
| normalized_base_url = f"{self.base_url.rstrip('/')}/" | ||
| url = urllib.parse.urljoin(normalized_base_url, endpoint) | ||
| self.logger.debug(f"Request url: {url}") |
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.
Thanks for your contribution; we appreciate it a lot. The following instructions will make your pull request healthier and help you get feedback more easily. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.
感谢您的贡献,我们非常重视。以下说明将使您的拉取请求更健康,更易于获得反馈。如果您不理解某些项目,请不要担心,只需提交拉取请求并从维护人员那里寻求帮助即可。
PR Type / PR类型
Related Issue | 关联 Issue
🔍 Motivation / 变更动机
vllm_api_general_chatincorrectly builds request URLs whenurlcontains a path but has no trailing/, causing requests to drop the last path segment (e.g.,.../deepseek_v4->.../member1/v1/chat/completions).This leads to empty predictions and abnormal token/time metrics because the intended endpoint is not reached.
📝 Modification / 修改内容
URL normalization before endpoint join
VLLMCustomAPIChat._get_url, normalizebase_urlto.../beforeurllib.parse.urljoin.http://host/pathandhttp://host/path/resolve tohttp://host/path/v1/chat/completions.Focused unit coverage for regression
tests/UT/models/api_models/test_vllm_custom_api_chat.py::test_get_urlfor a custom path URL without trailing slash.📐 Associated Test Results / 关联测试结果
N/A
No backward-incompatible interface changes. This is a URL construction correctness fix.
None expected.
🌟 Use cases (Optional) / 使用案例(可选)
N/A
✅ Checklist / 检查列表
Before PR:
After PR:
👥 Collaboration Info / 协作信息
🌟 Useful CI Command / 实用的CI命令
/gemini review/gemini summary/gemini help/readthedocs build