Skip to content

Commit b4e38da

Browse files
committed
adress pr comments
1 parent 6929430 commit b4e38da

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

pydantic_ai_slim/pydantic_ai/common_tools/duckduckgo.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import functools
44
from dataclasses import KW_ONLY, dataclass
5-
from typing import TYPE_CHECKING
65

76
import anyio
87
import anyio.to_thread
@@ -11,19 +10,16 @@
1110

1211
from pydantic_ai.tools import Tool
1312

14-
if TYPE_CHECKING:
15-
from ddgs import DDGS
16-
else:
13+
try:
1714
try:
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
15+
from ddgs.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
2723

2824
__all__ = ('duckduckgo_search_tool',)
2925

0 commit comments

Comments
 (0)