Skip to content

Commit bdc216d

Browse files
committed
Address review feedback and make engine readable from env
1 parent 5ba7110 commit bdc216d

File tree

4 files changed

+6
-17
lines changed

4 files changed

+6
-17
lines changed

dev/Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
```bash
4141
export AZURE_OPENAI_API_KEY="<your key>" # required AZURE OPENAI USAGE
4242
export SERPER_API_KEY="<your key>" # required for Google Serper API
43-
export SEARCHAPI_API_KEY="<your key>" # required to perform web searaches on any search engines.
43+
export SEARCHAPI_API_KEY="<your key>" # required to perform web searches on any search engines.
4444
python usecases/ProfAgent.py
4545
```
4646

docs/components/action/tools.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,21 @@ admin = Admin(
2727

2828
### 2. SearchApi Search
2929

30-
SearchApi is SERP a solution to get real-time search results into strucuted JSON response from various search engines. [SearchApi](https://searchapi.io/) supports all the major engines like Google, Bing, Baidu, etc.
30+
[SearchApi.io](https://searchapi.io/) provides a real-time API to access search results from Google (default), Google Scholar, Bing, Baidu, and other search engines.
3131

3232
#### Setup API
3333

3434
```python
3535
import os
3636

3737
os.environ['SEARCHAPI_API_KEY'] = "<replace-with-your-api-key>"
38+
os.environ['SEARCHAPI_ENGINE'] = "bing" # defaults to google.
3839
```
3940

4041
Get your API key by creating an account or logging into your account on [SearchApi](https://searchapi.io/).
4142

4243
```python
43-
from openagi.actions.tools.serper_search import SearchApiSearch
44+
from openagi.actions.tools.searchapi_search import SearchApiSearch
4445
from openagi.agent import Admin
4546
from openagi.llms.openai import OpenAIModel
4647
from openagi.planner.task_decomposer import TaskPlanner

example/job_search.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from openagi.actions.tools.serp_search import GoogleSerpAPISearch
2-
from openagi.actions.tools.searchapi_search import SearchApiSearch
32
from openagi.actions.tools.ddg_search import DuckDuckGoSearch
43
from openagi.agent import Admin
54
from openagi.llms.azure import AzureChatOpenAIModel

src/openagi/actions/tools/searchapi_search.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,14 @@ class SearchApiSearch(BaseAction):
1515
query: str = Field(
1616
..., description="User query of type string used to fetch web search results from a search engine."
1717
)
18-
engine: str = Field(
19-
default="google",
20-
description="Engine to search the given query on. Defaults to Google Search."
21-
)
22-
23-
@field_validator("engine")
24-
@classmethod
25-
def actions_validator(cls, engine):
26-
if not engine or not isinstance(engine, str):
27-
logging.warning("Engine is set to google (default).")
28-
engine = "google"
29-
return engine
3018

3119
def execute(self):
3220
base_url = "https://www.searchapi.io/api/v1/search"
3321
searchapi_api_key = os.environ["SEARCHAPI_API_KEY"]
22+
engine = os.environ.get("SEARCHAPI_ENGINE") or "google"
3423
search_dict = {
3524
"q": self.query,
36-
"engine": self.engine,
25+
"engine": engine,
3726
"api_key": searchapi_api_key
3827
}
3928
logging.debug(f"{search_dict=}")

0 commit comments

Comments
 (0)