Commit d9f189c
fix: improve error message when beautifulsoup4/lxml not installed for load_web_page
Merge google#4853
## Description
The built-in `load_web_page` tool requires `beautifulsoup4` and `lxml`, which are available via the `[extensions]` optional dependency group. When a user installs `google-adk` without the `[extensions]` extra and calls `load_web_page`, they get a raw `ModuleNotFoundError: No module named 'bs4'` with no guidance on how to resolve it.
This change wraps the deferred imports in a `try/except` to provide a clear, actionable error message:
```
ImportError: load_web_page requires the "beautifulsoup4" and "lxml" packages.
Install them with: pip install google-adk[extensions]
```
Fixes google#4852
Co-authored-by: Liang Wu <wuliang@google.com>
COPYBARA_INTEGRATE_REVIEW=google#4853 from brucearctor:fix/load-web-page-import-error 27aa20e
PiperOrigin-RevId: 9334163791 parent 06959b9 commit d9f189c
2 files changed
Lines changed: 10 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
| 196 | + | |
196 | 197 | | |
197 | 198 | | |
198 | 199 | | |
| |||
220 | 221 | | |
221 | 222 | | |
222 | 223 | | |
| 224 | + | |
223 | 225 | | |
224 | 226 | | |
225 | 227 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
289 | | - | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
290 | 297 | | |
291 | 298 | | |
292 | 299 | | |
| |||
0 commit comments