fix: Improve error handling for NVIDIA model component (#7484)
fix: ignore ConnectionError in NVIDIA model component in case there's no internet connection - Added logging for connection issues when accessing the NVIDIA API. - Implemented exception handling for ConnectionError, MaxRetryError, and NameResolutionError to improve robustness and user feedback.
This commit is contained in:
parent
cde01b3696
commit
eeb443bdc1
1 changed files with 10 additions and 0 deletions
|
|
@ -1,5 +1,9 @@
|
|||
from typing import Any
|
||||
|
||||
from loguru import logger
|
||||
from requests.exceptions import ConnectionError # noqa: A004
|
||||
from urllib3.exceptions import MaxRetryError, NameResolutionError
|
||||
|
||||
from langflow.base.models.model import LCModelComponent
|
||||
from langflow.field_typing import LanguageModel
|
||||
from langflow.field_typing.range_spec import RangeSpec
|
||||
|
|
@ -19,6 +23,12 @@ class NVIDIAModelComponent(LCModelComponent):
|
|||
except ImportError as e:
|
||||
msg = "Please install langchain-nvidia-ai-endpoints to use the NVIDIA model."
|
||||
raise ImportError(msg) from e
|
||||
except (ConnectionError, MaxRetryError, NameResolutionError):
|
||||
logger.warning(
|
||||
"Failed to connect to NVIDIA API. Model list may be unavailable."
|
||||
" Please check your internet connection and API credentials."
|
||||
)
|
||||
all_models = []
|
||||
|
||||
inputs = [
|
||||
*LCModelComponent._base_inputs,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue