mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-05 14:19:56 -05:00
ai: cache the models manifest, skip it offline, show a loading state
The Manage tab fetched the CDN manifest and its signature on every catalog request with a 30s timeout each, and the tab polls every 30s. On a black-holed or offline network every poll paid up to 60s before falling back to the bundled list, the frontend's 60s limit threw the response away, and the tab showed a blank page the whole time. get_models_catalog now skips the CDN while the have_internet flag is explicitly clear, reuses the last attempt (success or failure) for an hour, and uses a 5s timeout for the 2KB manifest. A skipped attempt is not cached so the CDN is tried as soon as internet comes up. The cache is per process and is cleared between tests by an autouse fixture. The Manage tab shows "Loading the model catalog" while the first response is pending, and on failure shows the error with a Retry button and a note that the API may still be starting, instead of rendering nothing. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
5b1b0559b5
commit
861e183bd2
5 changed files with 136 additions and 9 deletions
|
|
@ -15,3 +15,12 @@ def test_ai_config(test_directory, async_client):
|
|||
with ai_config_context() as config:
|
||||
config.initialize(api_app.shared_ctx.ai_config)
|
||||
yield config_path
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _clear_models_catalog_cache():
|
||||
"""Each test starts with an empty manifest cache."""
|
||||
from modules.ai import catalog
|
||||
catalog.clear_models_catalog_cache()
|
||||
yield
|
||||
catalog.clear_models_catalog_cache()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue