Skip to content

Commit

Permalink
Deprecate DuckDuckGoWebSearchDriver
Browse files Browse the repository at this point in the history
  • Loading branch information
collindutter committed Dec 19, 2024
1 parent 4b53ef5 commit bbbe1ea
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Parsing `ActionCallDeltaMessageContent`s with empty string `partial_input`s.
- `Stream` util not properly propagating thread contextvars.

### Deprecated

- `DuckDuckGoWebSearchDriver`. `DuckDuckGoWebSearchDriver` relies on `duckduckgo_search` which is no longer maintained and has been archived.

## [1.0.0] - 2024-12-09

### Added
Expand Down
24 changes: 11 additions & 13 deletions docs/griptape-framework/drivers/web-search-drivers.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,6 @@ Example using `GoogleWebSearchDriver` directly:
--8<-- "docs/griptape-framework/drivers/src/web_search_drivers_1.py"
```

### DuckDuckGo

!!! info
This driver requires the `drivers-web-search-duckduckgo` [extra](../index.md#extras).

The [DuckDuckGoWebSearchDriver](../../reference/griptape/drivers/web_search/duck_duck_go_web_search_driver.md) uses the [duckduckgo_search](https://github.com/deedy5/duckduckgo_search) SDK for web searching.

Example of using `DuckDuckGoWebSearchDriver` directly:

```python
--8<-- "docs/griptape-framework/drivers/src/web_search_drivers_3.py"
```

### Tavily

!!! info
Expand All @@ -98,3 +85,14 @@ Example of using `ExaWebSearchDriver` directly:
```python
--8<-- "docs/griptape-framework/drivers/src/web_search_drivers_6.py"
```

### DuckDuckGo

!!! warning
`DuckDuckGoWebSearchDriver` is deprecated and will be removed in a future release.
`DuckDuckGoWebSearchDriver` relies on `duckduckgo_search` which is no longer maintained and has been archived.

!!! info
This driver requires the `drivers-web-search-duckduckgo` [extra](../index.md#extras).

The [DuckDuckGoWebSearchDriver](../../reference/griptape/drivers/web_search/duck_duck_go_web_search_driver.md) uses the [duckduckgo_search](https://github.com/deedy5/duckduckgo_search) SDK for web searching.
8 changes: 8 additions & 0 deletions griptape/drivers/web_search/duck_duck_go_web_search_driver.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import json
import warnings
from typing import TYPE_CHECKING

from attrs import define, field
Expand All @@ -25,6 +26,13 @@ def client(self) -> DDGS:
return import_optional_dependency("duckduckgo_search").DDGS()

def search(self, query: str, **kwargs) -> ListArtifact:
warnings.warn(
"`DuckDuckGoWebSearchDriver` is deprecated and will be removed in a future release. "
"`DuckDuckGoWebSearchDriver` relies on `duckduckgo_search` which is no longer maintained and has been archived.",
DeprecationWarning,
stacklevel=2,
)

try:
results = self.client.text(
query, region=f"{self.language}-{self.country}", max_results=self.results_count, **kwargs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,7 @@ def test_search_returns_results(self, driver):
def test_search_raises_error(self, driver_with_error):
with pytest.raises(Exception, match="Error searching 'test' with DuckDuckGo: test_error"):
driver_with_error.search("test")

def test_search_deprecation_warning(self, driver):
with pytest.warns(DeprecationWarning):
driver.search("test")

0 comments on commit bbbe1ea

Please sign in to comment.