@@ -105,41 +105,28 @@ def _has_chat_ml_format(data: Dict) -> bool:
105
105
return False
106
106
107
107
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 constructs the complete endpoint URL.
111
- """
112
- # Make a copy of the data to avoid modifying the original and normalize the message content
113
108
normalized_data = self ._normalize_content_messages (data )
114
109
115
- # Format the model name to include the provider
110
+ # Format the model name
116
111
if "model" in normalized_data :
117
112
model_name = normalized_data ["model" ]
118
113
if not model_name .startswith ("hosted_vllm/" ):
119
114
normalized_data ["model" ] = f"hosted_vllm/{ model_name } "
120
115
121
- # Construct the complete endpoint URL
116
+ # Construct the complete endpoint URL without duplicating paths
122
117
if "base_url" in normalized_data :
123
118
base_url = normalized_data ["base_url" ].rstrip ("/" )
124
- original_endpoint = normalized_data .pop ("original_endpoint" , "" )
125
-
126
- # Ensure we have /v1 in the path
127
- if not base_url .endswith ("/v1" ):
128
- base_url = f"{ base_url } /v1"
129
-
130
- # Add the original endpoint if it exists
131
- if original_endpoint :
132
- normalized_data ["base_url" ] = f"{ base_url } /{ original_endpoint } "
133
- else :
134
- normalized_data ["base_url" ] = base_url
119
+ normalized_data ["base_url" ] = base_url
135
120
136
121
ret_data = normalized_data
137
122
if self ._has_chat_ml_format (normalized_data ):
138
123
ret_data = self ._chat_ml_normalizer .normalize (normalized_data )
139
124
else :
140
125
ret_data = ChatCompletionRequest (** normalized_data )
126
+
141
127
if ret_data .get ("stream" , False ):
142
128
ret_data ["stream_options" ] = {"include_usage" : True }
129
+
143
130
return ret_data
144
131
145
132
def denormalize (self , data : ChatCompletionRequest ) -> Dict :
0 commit comments