Skip to content

Commit 08ad19b

Browse files
committed
Move base url inside the method
1 parent f09e05f commit 08ad19b

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/openagi/actions/tools/searchapi_search.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

1313
class SearchApiSearch(BaseAction):
1414
"""SearchApi provides an easy to use API for querying web search engines and much more."""
15-
base_url = "https://www.searchapi.io/api/v1/search"
16-
1715
query: str = Field(
1816
..., description="User query of type string used to fetch web search results from a search engine."
1917
)
@@ -31,14 +29,15 @@ def actions_validator(cls, engine):
3129
return engine
3230

3331
def execute(self):
32+
base_url = "https://www.searchapi.io/api/v1/search"
3433
searchapi_api_key = os.environ["SEARCHAPI_API_KEY"]
3534
search_dict = {
3635
"q": self.query,
3736
"engine": self.engine,
3837
"api_key": searchapi_api_key
3938
}
4039
logging.debug(f"{search_dict=}")
41-
url = f"{self.base_url}?{urlencode(search_dict)}"
40+
url = f"{base_url}?{urlencode(search_dict)}"
4241
response = requests.request("GET", url)
4342
json_response = response.json()
4443

0 commit comments

Comments
 (0)