Commit bb6e3d3
feat(provider): switch to dynamic model metadata loading (#1149)
* feat(provider): switch to dynamic model metadata loading
- Replace hardcoded provider model catalogs with dynamic loading from model-metadata JSON (with caching and provider-specific postprocessing)
- Remove Gemini custom ordering to respect metadata order.
- Add text-output filtering so unsupported generation-only models are not shown in the UI
- Clean up dead reasoning code paths
- Add regression tests for loader parsing/caching and Anthropic thinking rendering/parity.
* fix: Address review comments
* refactor(loader): tighten model-metadata parsing with typed pydantic schemas
Replace ad-hoc dict handling with typed nested Pydantic models and centralized normalization/validation for metadata rows, while preserving tolerant parsing behavior and existing loader outputs.
* feat(models): load account models in background and surface load errors
* refactor: improve pydantic usage to parse JSON provider info
* refactor: finalize pydantic refactor
* style: correct ruff issue
* refactor(models): move async model loading from view to presenter
Relocate threading, error handling, cache-invalidation logic, and the
deferred-model-selection state machine from BaseConversation (view) to
BaseConversationPresenter, restoring MVP separation. The view now only
renders received models and delegates all orchestration to the presenter.
Also fix a typo (clas → class) in dynamic_model_loader.py and update
ConversationTab._restore_draft_block to use set_pending_model instead of
calling engine.get_model() directly, which would fail before async loading
completes.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(models): address code review issues in dynamic model loading
- Fix type mismatch: store str(e) in _LAST_LOAD_ERROR instead of Exception
- Add threading.Lock to protect _CACHE and _LAST_LOAD_ERROR from races
- Remove import wx from presenter; view wraps callback with wx.CallAfter
- Show error modal only when model list is empty (not on stale cache hit)
- Remove bare except Exception around SetStatusText
- Annotate _pending_model_account_id and account_id params as UUID
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix: clear cache in test
* feat(models): add model list refresh action and F5 shortcut
Adds a “Refresh model list” item to the model context menu and binds F5 in the model list to reload models by invalidating cached engine models first.
* fix(openrouter): sort models by created timestamp like other providers
Parse OpenRouter created into ProviderAIModel.created and sort descending by created date instead of model name, with tests for ordering and invalid timestamp fallback.
* refactor(models): move TTL cache to BaseEngine for all providers
Centralizes model-list caching/invalidation and error fallback in BaseEngine so OpenRouter/Ollama also honor TTL; simplifies dynamic_model_loader to fetch/parse only and updates cache behavior tests.
* refactor(cache): centralize engine model cache with persistent registry cleanup
- Move model-list caching to BaseEngine with per-account disk persistence, TTL expiry, and stale fallback on refresh failure.
- Add registry-based cache tracking/pruning plus account-removal cache cleanup, with tests for restart reuse, expiry reload, version mismatch, write failures, and registry maintenance.
* refactor(provider): unify OpenRouter model conversion with dynamic loader
- extract shared model-row conversion and modality fallback logic into dynamic_model_loader
- route OpenRouter /models parsing through shared converter and support pricing metadata
- expand unit tests for modality precedence/fallback and context-length edge cases
* fix(provider-engine): address review feedback on model cache safety
Catch disk-cache read OSErrors for graceful fallback, avoid deleting cache files still referenced by other accounts, and add a 30s timeout to OpenRouter model discovery calls.
* fix: address review feedback on model/cache loading reliability
Reorder account removal cleanup to be best-effort, harden model-loading concurrency and cache invalidation atomicity, and propagate provider metadata fetch failures with explicit fallbacks where needed (OpenRouter/DeepSeek/Anthropic). Also align related tests with the new behavior.
* fix(models): address review comments on refresh, timestamps, and model UI
Serialize BaseEngine model-list refresh, handle invalid created timestamps in dynamic metadata, guard model-list callback on destroy with translator context, and tighten parse_model_metadata tests to surface validation errors.
* refactor(models): simplify model details text and trim loader/test noise
* fix(accounts,ui): invalidate default on remove, provider-id draft lookup, defer pending model pop
* feat(ui): model list cache TTL in preferences and model-loader join on shutdown
* feat(models): filter completion params and UI by catalog sampling metadata
* refactor(models): centralize catalog sampling policy and engine strip hook
- Add basilisk/model_catalog_sampling.py for supported_parameters / unsupported_parameters rules, main-tab visibility map, and OpenAI-style param stripping.
- BaseEngine._strip_catalog_sampling_params(); chat engines call it instead of importing strip helpers directly.
- UI: replace _sampling_visibility_ignore_advanced with gate_on_advanced_mode on refresh_sampling_controls_visibility; align widget rows with MAIN_UI_SAMPLING_PARAM_KEYS + zip(..., strict=True).
- Tests: tests/test_model_catalog_sampling.py (replaces old completion-params test file).
* refactor(models): centralize SigmaNight metadata URLs and catalog tagging
- Add model_metadata_catalog constants for data/*.json URLs and source labels
- Point OpenAI/Anthropic/Gemini/Mistral/xAI/DeepSeek MODELS_JSON_URL at catalog
- Tag ProviderAIModel.extra_info[metadata_catalog] (SigmaNight vs OpenRouter)
- Show metadata catalog in model details; document in model_catalog_sampling
- Extend loader/OpenRouter/reasoning tests; fix get_provider_models monkeypatch
* refactor(sampling): decouple catalog stripping from default chat kwargs
* refactor(provider_engine): extract model list disk cache from BaseEngine
Move JSON payload I/O, path hashing, directory prune, and registry-backed
delete/register helpers into engine_model_list_cache. BaseEngine keeps RAM
cache, refresh coordination, and TTL-driven orchestration.
* refactor(models): extract provider_ai_model_display and thin base conversation view
* refactor: re-consolidate model catalog modules and engine metadata URLs
* refactor(deepseek): drop bundled model fallback; load catalog JSON only
* chore(provider-engine): document model-list cache
* test(provider_engine): avoid GeminiEngine import for Win ARM64 CI
---------
Co-authored-by: clemetb49 <clement.boussiron@gmail.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 97a3a84 commit bb6e3d3
37 files changed
Lines changed: 4140 additions & 987 deletions
File tree
- basilisk
- config
- model_catalog
- presenters
- provider_engine
- views
- tests
- config
- presenters
- provider_engine
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
32 | 35 | | |
33 | 36 | | |
34 | 37 | | |
| |||
568 | 571 | | |
569 | 572 | | |
570 | 573 | | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
571 | 589 | | |
572 | 590 | | |
573 | 591 | | |
| |||
577 | 595 | | |
578 | 596 | | |
579 | 597 | | |
580 | | - | |
581 | 598 | | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
582 | 625 | | |
583 | 626 | | |
584 | 627 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
24 | 27 | | |
25 | 28 | | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
29 | 38 | | |
30 | 39 | | |
31 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
0 commit comments