0.99.65

parent a9adc7e8
...@@ -4891,7 +4891,13 @@ class AutoselectHandler: ...@@ -4891,7 +4891,13 @@ class AutoselectHandler:
continue continue
# Loop detection on non-streaming response # Loop detection on non-streaming response
content = response.get('choices', [{}])[0].get('message', {}).get('content', '') or '' if isinstance(response, dict):
content = response.get('choices', [{}])[0].get('message', {}).get('content', '') or ''
else:
try:
content = response.choices[0].message.content or ''
except (AttributeError, IndexError):
content = ''
if not content: if not content:
logger.warning(f"Model '{selected_model_id}' returned empty content — escalating") logger.warning(f"Model '{selected_model_id}' returned empty content — escalating")
failed_models.append(selected_model_id) failed_models.append(selected_model_id)
......
...@@ -17,13 +17,15 @@ import httpx ...@@ -17,13 +17,15 @@ import httpx
router = APIRouter() router = APIRouter()
_config = None _config = None
_templates = None _templates = None
_server_config = None
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
def init(config, templates): def init(config, templates, server_config=None):
global _config, _templates global _config, _templates, _server_config
_config = config _config = config
_templates = templates _templates = templates
_server_config = server_config
def get_user_auth_files_dir(user_id) -> Path: def get_user_auth_files_dir(user_id) -> Path:
...@@ -69,7 +71,7 @@ async def dashboard_index(request: Request): ...@@ -69,7 +71,7 @@ async def dashboard_index(request: Request):
"providers_count": len(_config.providers) if _config else 0, "providers_count": len(_config.providers) if _config else 0,
"rotations_count": len(_config.rotations) if _config else 0, "rotations_count": len(_config.rotations) if _config else 0,
"autoselect_count": len(_config.autoselect) if _config else 0, "autoselect_count": len(_config.autoselect) if _config else 0,
"server_config": server_config or {}, "server_config": _server_config or {},
"users_count": users_count, "users_count": users_count,
} }
) )
......
...@@ -209,7 +209,7 @@ def _init_all_routers(): ...@@ -209,7 +209,7 @@ def _init_all_routers():
_api_routes.init(config, _get_user_handler, _app_state['rotation_handler']) _api_routes.init(config, _get_user_handler, _app_state['rotation_handler'])
_mcp_routes.init(server_config, _get_user_handler) _mcp_routes.init(server_config, _get_user_handler)
_user_api_routes.init(config, _get_user_handler) _user_api_routes.init(config, _get_user_handler)
_dash_providers.init(config, templates) _dash_providers.init(config, templates, server_config)
_dash_settings.init(config, templates) _dash_settings.init(config, templates)
_dash_admin.init(config, templates) _dash_admin.init(config, templates)
_dash_payments.init(config, templates) _dash_payments.init(config, templates)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment