From 012f40078a59e6f725f57cdb013451fe0b268206 Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Thu, 14 Mar 2024 15:22:09 +0100 Subject: Filter not working provider from RetryProvider --- g4f/__init__.py | 9 ++++++--- g4f/gui/client/js/chat.v1.js | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'g4f') diff --git a/g4f/__init__.py b/g4f/__init__.py index 441225f1..dce116c4 100644 --- a/g4f/__init__.py +++ b/g4f/__init__.py @@ -69,11 +69,14 @@ def get_model_and_provider(model : Union[Model, str], if isinstance(model, Model): model = model.name - if ignored and isinstance(provider, BaseRetryProvider): - provider.providers = [p for p in provider.providers if p.__name__ not in ignored] - if not ignore_working and not provider.working: raise ProviderNotWorkingError(f'{provider.__name__} is not working') + + if not ignore_working and isinstance(provider, BaseRetryProvider): + provider.providers = [p for p in provider.providers if p.working] + + if ignored and isinstance(provider, BaseRetryProvider): + provider.providers = [p for p in provider.providers if p.__name__ not in ignored] if not ignore_stream and not provider.supports_stream and stream: raise StreamNotSupportedError(f'{provider.__name__} does not support "stream" argument') diff --git a/g4f/gui/client/js/chat.v1.js b/g4f/gui/client/js/chat.v1.js index c90a594d..59d0351a 100644 --- a/g4f/gui/client/js/chat.v1.js +++ b/g4f/gui/client/js/chat.v1.js @@ -938,10 +938,10 @@ async function load_provider_models() { provider = providerSelect.options[providerSelect.selectedIndex].value; response = await fetch('/backend-api/v2/models/' + provider); models = await response.json(); + modelProvider.innerHTML = ''; if (models.length > 0) { modelSelect.classList.add("hidden"); modelProvider.classList.remove("hidden"); - modelProvider.innerHTML = ''; models.forEach((model) => { let option = document.createElement('option'); option.value = option.text = model.model; -- cgit v1.2.3