fix: preserve user-selected model when updating available options (#9495)

This commit is contained in:
Ítalo Johnny 2025-08-22 13:35:26 -03:00 committed by GitHub
commit 2f06fa9d4d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 3 deletions

View file

@ -177,8 +177,9 @@ class AnthropicModelComponent(LCModelComponent):
except (ImportError, ValueError, requests.exceptions.RequestException) as e:
logger.exception(f"Error getting model names: {e}")
ids = ANTHROPIC_MODELS
build_config.setdefault("model_name", {})
build_config["model_name"]["options"] = ids
build_config["model_name"]["value"] = ids[0]
build_config["model_name"].setdefault("value", ids[0])
build_config["model_name"]["combobox"] = True
except Exception as e:
msg = f"Error getting model names: {e}"

View file

@ -145,8 +145,9 @@ class GoogleGenerativeAIComponent(LCModelComponent):
except (ImportError, ValueError, requests.exceptions.RequestException) as e:
logger.exception(f"Error getting model names: {e}")
ids = GOOGLE_GENERATIVE_AI_MODELS
build_config.setdefault("model_name", {})
build_config["model_name"]["options"] = ids
build_config["model_name"]["value"] = ids[0]
build_config["model_name"].setdefault("value", ids[0])
except Exception as e:
msg = f"Error getting model names: {e}"
raise ValueError(msg) from e

View file

@ -114,8 +114,9 @@ class GroqModel(LCModelComponent):
except (ImportError, ValueError, requests.exceptions.RequestException) as e:
logger.exception(f"Error getting model names: {e}")
ids = GROQ_MODELS
build_config.setdefault("model_name", {})
build_config["model_name"]["options"] = ids
build_config["model_name"]["value"] = ids[0]
build_config["model_name"].setdefault("value", ids[0])
except Exception as e:
msg = f"Error getting model names: {e}"
raise ValueError(msg) from e