forked from phoenix/litellm-mirror
fix pattern match router
This commit is contained in:
parent
63c63612c2
commit
d28c6b390c
1 changed files with 8 additions and 3 deletions
|
@ -5,6 +5,8 @@ Class to handle llm wildcard routing and regex pattern matching
|
||||||
import re
|
import re
|
||||||
from typing import Dict, List, Optional
|
from typing import Dict, List, Optional
|
||||||
|
|
||||||
|
from litellm._logging import verbose_router_logger
|
||||||
|
|
||||||
|
|
||||||
class PatternMatchRouter:
|
class PatternMatchRouter:
|
||||||
"""
|
"""
|
||||||
|
@ -72,9 +74,12 @@ class PatternMatchRouter:
|
||||||
Returns:
|
Returns:
|
||||||
Optional[List[Deployment]]: llm deployments
|
Optional[List[Deployment]]: llm deployments
|
||||||
"""
|
"""
|
||||||
for pattern, llm_deployments in self.patterns.items():
|
try:
|
||||||
if re.match(pattern, request):
|
for pattern, llm_deployments in self.patterns.items():
|
||||||
return llm_deployments
|
if re.match(pattern, request):
|
||||||
|
return llm_deployments
|
||||||
|
except Exception as e:
|
||||||
|
verbose_router_logger.error(f"Error in PatternMatchRouter.route: {str(e)}")
|
||||||
return None # No matching pattern found
|
return None # No matching pattern found
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue