mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-14 10:25:37 +00:00
fix(proxy): only create Router when models or search_tools exist (#20661)
Previously, PR #19818 (via #20205) removed the model_list check entirely, causing Router to be created even with no models AND no search_tools. This fix adds back a conditional check that creates the Router only when: - There are models to route, OR - There are search_tools configured This preserves the PR #19818 goal (search-tools-only deployments) while avoiding unnecessary Router creation when there's nothing to route. Fixes test_add_and_delete_deployments[0-None]
This commit is contained in:
@@ -3249,18 +3249,19 @@ class ProxyConfig:
|
||||
_model_list: list = self.decrypt_model_list_from_db(
|
||||
new_models=models_list
|
||||
)
|
||||
# Create router even with empty model list to support search_tools
|
||||
# Router can function with model_list=[] and only search_tools
|
||||
verbose_proxy_logger.debug(f"_model_list: {_model_list}")
|
||||
llm_router = litellm.Router(
|
||||
model_list=_model_list,
|
||||
router_general_settings=RouterGeneralSettings(
|
||||
async_only_mode=True # only init async clients
|
||||
),
|
||||
search_tools=search_tools,
|
||||
ignore_invalid_deployments=True,
|
||||
)
|
||||
verbose_proxy_logger.debug(f"updated llm_router: {llm_router}")
|
||||
# Only create router if we have models or search_tools to route
|
||||
# Router can function with model_list=[] if search_tools are configured
|
||||
if len(_model_list) > 0 or search_tools:
|
||||
verbose_proxy_logger.debug(f"_model_list: {_model_list}")
|
||||
llm_router = litellm.Router(
|
||||
model_list=_model_list,
|
||||
router_general_settings=RouterGeneralSettings(
|
||||
async_only_mode=True # only init async clients
|
||||
),
|
||||
search_tools=search_tools,
|
||||
ignore_invalid_deployments=True,
|
||||
)
|
||||
verbose_proxy_logger.debug(f"updated llm_router: {llm_router}")
|
||||
else:
|
||||
verbose_proxy_logger.debug(f"len new_models: {len(models_list)}")
|
||||
if search_tools is not None and llm_router is not None:
|
||||
|
||||
Reference in New Issue
Block a user