Skip to content

Commit

Permalink
Fix ValueError in DuckDuckGoWebSearchDriver
Browse files Browse the repository at this point in the history
  • Loading branch information
collindutter committed Dec 20, 2024
1 parent d8ace6f commit cf33154
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Support for `BranchTask` in `StructureVisualizer`.
- `EvalEngine` for evaluating the performance of an LLM's output against a given input.
- `BaseFileLoader.save()` method for saving an Artifact to a destination.
- `DuckDuckGoWebSearchDriver.backend` for setting the backend to use for DuckDuckGo searches.

### Changed

Expand All @@ -31,6 +32,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `StructureVisualizer.query_params` for setting query parameters on the url generated by `StructureVisualizer.to_url()`.
- Parsing `ActionCallDeltaMessageContent`s with empty string `partial_input`s.
- `Stream` util not properly propagating thread contextvars.
- `ValueError` with `DuckDuckGoWebSearchDriver`.

### Deprecated

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

## [1.0.0] - 2024-12-09

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
class DuckDuckGoWebSearchDriver(BaseWebSearchDriver):
language: str = field(default="en", kw_only=True)
country: str = field(default="us", kw_only=True)
backend: str = field(default="api", kw_only=True)
_client: DDGS = field(default=None, kw_only=True, alias="client", metadata={"serializable": False})

@lazy_property()
Expand All @@ -27,7 +28,11 @@ def client(self) -> DDGS:
def search(self, query: str, **kwargs) -> ListArtifact:
try:
results = self.client.text(
query, region=f"{self.language}-{self.country}", max_results=self.results_count, **kwargs
query,
region=f"{self.language}-{self.country}",
max_results=self.results_count,
backend=self.backend,
**kwargs,
)
return ListArtifact(
[
Expand Down
1 change: 1 addition & 0 deletions tests/integration/test_code_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"docs/griptape-framework/structures/src/observability_1.py",
"docs/griptape-framework/structures/src/observability_2.py",
"docs/griptape-framework/data/src/loaders_9.py",
"docs/griptape-framework/drivers/src/web_search_drivers_3.py",
]


Expand Down

0 comments on commit cf33154

Please sign in to comment.