Add methods for caching model data in Backend class: implement _get_cache_data and _apply_cache_data to enhance data sharing between backend instances.

This commit is contained in:
vegu-ai-tools
2025-11-29 21:24:07 +02:00
parent 647e2f277c
commit f455a11096

View File

@@ -89,6 +89,15 @@ class Backend(backends.Backend):
if choices_changed_create or choices_changed_edit:
await super().on_status_change()
def _get_cache_data(self) -> dict:
"""Return models list to cache for sharing with other backends."""
return {"models": self.models}
def _apply_cache_data(self, data: dict):
"""Apply cached models list to this backend instance."""
if "models" in data:
self.models = data["models"]
async def test_connection(self, timeout: int = 2) -> backends.BackendStatus:
try:
auth = self._get_auth()