Skip to content

Python scraper based on AI

Add documentation explaining __new__ usage in Nvidia class

copilot-swe-agent[bot]8cf81c986afe
diff --git a/scrapegraphai/models/nvidia.py b/scrapegraphai/models/nvidia.py
index 301d18a3..7fcb0d32 100644
--- a/scrapegraphai/models/nvidia.py
+++ b/scrapegraphai/models/nvidia.py
@@ -8,6 +8,11 @@ class Nvidia:
A wrapper for the ChatNVIDIA class that provides default configuration
and could be extended with additional methods if needed.
+ Note: This class uses __new__ instead of __init__ because langchain_nvidia_ai_endpoints
+ is an optional dependency. We cannot inherit from ChatNVIDIA at class definition time
+ since the module may not be installed. The __new__ method allows us to lazily import
+ and return a ChatNVIDIA instance only when Nvidia() is instantiated.
+
Args:
llm_config (dict): Configuration parameters for the language model.
"""