Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

Enhance error handling in __getattr__ to catch ImportError in addition to AttributeError for improved robustness.

Magnus Müllerb87657dd22a9
diff --git a/browser_use/llm/__init__.py b/browser_use/llm/__init__.py
index e46c208db..badaef2eb 100644
--- a/browser_use/llm/__init__.py
+++ b/browser_use/llm/__init__.py
@@ -115,7 +115,7 @@ def __getattr__(name: str):
# Cache in our clean cache dict
_model_cache[name] = attr
return attr
- except AttributeError:
+ except (AttributeError, ImportError):
pass
raise AttributeError(f"module '{__name__}' has no attribute '{name}'")