Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit 972b498

Browse files
committed
Remove the endpoint suffix fixes
Signed-off-by: Radoslav Dimitrov <[email protected]>
1 parent ff72833 commit 972b498

File tree

2 files changed

+7
-25
lines changed

2 files changed

+7
-25
lines changed

src/codegate/providers/vllm/adapter.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,28 +105,26 @@ def _has_chat_ml_format(data: Dict) -> bool:
105105
return False
106106

107107
def normalize(self, data: Dict) -> ChatCompletionRequest:
108+
"""
109+
Normalize the input data to the format expected by LiteLLM.
110+
Ensures the model name has the hosted_vllm prefix and base_url has /v1.
111+
"""
112+
# Make a copy of the data to avoid modifying the original and normalize the message content
108113
normalized_data = self._normalize_content_messages(data)
109114

110-
# Format the model name
115+
# Format the model name to include the provider
111116
if "model" in normalized_data:
112117
model_name = normalized_data["model"]
113118
if not model_name.startswith("hosted_vllm/"):
114119
normalized_data["model"] = f"hosted_vllm/{model_name}"
115120

116-
# Construct the complete endpoint URL without duplicating paths
117-
if "base_url" in normalized_data:
118-
base_url = normalized_data["base_url"].rstrip("/")
119-
normalized_data["base_url"] = base_url
120-
121121
ret_data = normalized_data
122122
if self._has_chat_ml_format(normalized_data):
123123
ret_data = self._chat_ml_normalizer.normalize(normalized_data)
124124
else:
125125
ret_data = ChatCompletionRequest(**normalized_data)
126-
127126
if ret_data.get("stream", False):
128127
ret_data["stream_options"] = {"include_usage": True}
129-
130128
return ret_data
131129

132130
def denormalize(self, data: ChatCompletionRequest) -> Dict:

src/codegate/providers/vllm/provider.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,6 @@ def _get_base_url(self) -> str:
4545
base_url = f"{base_url}/v1"
4646
return base_url
4747

48-
def _get_endpoint_from_request(self, request: Request) -> str:
49-
"""
50-
Extract the endpoint path from the request
51-
"""
52-
path_parts = request.url.path.split("/")
53-
# Find the index of 'vllm' in the path
54-
try:
55-
vllm_index = path_parts.index(self.provider_route_name)
56-
# Get everything after 'vllm' but before any duplicates
57-
endpoint = path_parts[vllm_index + 1].split("/")[0] # Take just the first part
58-
return endpoint
59-
except ValueError:
60-
return ""
61-
6248
def models(self):
6349
resp = httpx.get(f"{self.base_url}/v1/models")
6450
jsonresp = resp.json()
@@ -117,11 +103,9 @@ async def create_completion(
117103
body = await request.body()
118104
data = json.loads(body)
119105

120-
# Add the vLLM base URL and original endpoint to the request
106+
# Add the vLLM base URL to the request
121107
base_url = self._get_base_url()
122-
endpoint = self._get_endpoint_from_request(request)
123108
data["base_url"] = base_url
124-
data["original_endpoint"] = endpoint
125109

126110
is_fim_request = self._is_fim_request(request, data)
127111
try:

0 commit comments

Comments
 (0)