Skip to content

Commit 2a832f1

Browse files
Updating to ddgs package for DuckDuckGoSearchAPIWrapper (#156)
Description: Using the latest ddgs package to avoid the warning. This will still work with the older version, therefore not a breaking change. Issue: langchain-ai/langchain#31892
1 parent fdc25a3 commit 2a832f1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

libs/community/langchain_community/utilities/duckduckgo_search.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,19 @@ class DuckDuckGoSearchAPIWrapper(BaseModel):
4646
def validate_environment(cls, values: Dict) -> Any:
4747
"""Validate that python package exists in environment."""
4848
try:
49-
from duckduckgo_search import DDGS # noqa: F401
49+
from ddgs import DDGS # noqa: F401
5050
except ImportError:
5151
raise ImportError(
52-
"Could not import duckduckgo-search python package. "
53-
"Please install it with `pip install -U duckduckgo-search`."
52+
"Could not import ddgs python package. "
53+
"Please install it with `pip install -U ddgs`."
5454
)
5555
return values
5656

5757
def _ddgs_text(
5858
self, query: str, max_results: Optional[int] = None
5959
) -> List[Dict[str, str]]:
6060
"""Run query through DuckDuckGo text search and return results."""
61-
from duckduckgo_search import DDGS
61+
from ddgs import DDGS
6262

6363
with DDGS() as ddgs:
6464
ddgs_gen = ddgs.text(
@@ -77,7 +77,7 @@ def _ddgs_news(
7777
self, query: str, max_results: Optional[int] = None
7878
) -> List[Dict[str, str]]:
7979
"""Run query through DuckDuckGo news search and return results."""
80-
from duckduckgo_search import DDGS
80+
from ddgs import DDGS
8181

8282
with DDGS() as ddgs:
8383
ddgs_gen = ddgs.news(
@@ -95,7 +95,7 @@ def _ddgs_images(
9595
self, query: str, max_results: Optional[int] = None
9696
) -> List[Dict[str, str]]:
9797
"""Run query through DuckDuckGo image search and return results."""
98-
from duckduckgo_search import DDGS
98+
from ddgs import DDGS
9999

100100
with DDGS() as ddgs:
101101
ddgs_gen = ddgs.images(

0 commit comments

Comments
 (0)