_add_deployment_model_to_endpoint_for_llm_passthrough_route

This commit is contained in:
Ishaan Jaffer 2025-10-16 14:31:13 -07:00
parent da72a812c9
commit 74a35914c6

View file

@ -2740,6 +2740,21 @@ class Router:
)
)
raise e
def _add_deployment_model_to_endpoint_for_llm_passthrough_route(
self, kwargs: Dict[str, Any],
model: str,
model_name: str
) -> Dict[str, Any]:
"""
Add the deployment model to the endpoint for LLM passthrough route.
e.g for bedrock invoke users can pass endpoint as /model/special-bedrock-model/invoke
it should be actually sent as /model/us.anthropic.claude-3-5-sonnet-20240620-v1:0/invoke
"""
if "endpoint" in kwargs and kwargs["endpoint"]:
kwargs["endpoint"] = kwargs["endpoint"].replace(model, model_name)
return kwargs
async def _ageneric_api_call_with_fallbacks_helper(
self, model: str, original_generic_function: Callable, **kwargs
@ -2772,6 +2787,7 @@ class Router:
model_name = data["model"]
self.total_calls[model_name] += 1
self._add_deployment_model_to_endpoint_for_llm_passthrough_route(kwargs=kwargs, model=model, model_name=model_name)
### get custom
response = original_generic_function(
**{
@ -2850,6 +2866,12 @@ class Router:
self.total_calls[model_name] += 1
# For passthrough routes, use the actual model from deployment
# and swap model name in endpoint if present
if "endpoint" in kwargs and kwargs["endpoint"]:
kwargs["endpoint"] = kwargs["endpoint"].replace(model, model_name)
kwargs["model"] = model_name
# Perform pre-call checks for routing strategy
self.routing_strategy_pre_call_checks(deployment=deployment)