File tree Expand file tree Collapse file tree 1 file changed +13
-9
lines changed
pydantic_ai_slim/pydantic_ai/common_tools Expand file tree Collapse file tree 1 file changed +13
-9
lines changed Original file line number Diff line number Diff line change 22
33import functools
44from dataclasses import KW_ONLY , dataclass
5+ from typing import TYPE_CHECKING
56
67import anyio
78import anyio .to_thread
1011
1112from pydantic_ai .tools import Tool
1213
13- try :
14+ if TYPE_CHECKING :
15+ from ddgs import DDGS
16+ else :
1417 try :
15- from ddgs import DDGS
16- except ImportError : # Fallback for older versions of ddgs
17- from duckduckgo_search import DDGS
18- except ImportError as _import_error :
19- raise ImportError (
20- 'Please install `ddgs` to use the DuckDuckGo search tool, '
21- 'you can use the `duckduckgo` optional group — `pip install "pydantic-ai-slim[duckduckgo]"`'
22- ) from _import_error
18+ try :
19+ from ddgs import DDGS
20+ except ImportError : # Fallback for older versions of ddgs
21+ from duckduckgo_search import DDGS
22+ except ImportError as _import_error :
23+ raise ImportError (
24+ 'Please install `ddgs` to use the DuckDuckGo search tool, '
25+ 'you can use the `duckduckgo` optional group — `pip install "pydantic-ai-slim[duckduckgo]"`'
26+ ) from _import_error
2327
2428__all__ = ('duckduckgo_search_tool' ,)
2529
You can’t perform that action at this time.
0 commit comments