-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SearchApi and SearchApiTool components
- Loading branch information
1 parent
c7394b3
commit f672a11
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from langchain_community.tools.searchapi import SearchAPIRun | ||
from langchain_community.utilities.searchapi import SearchApiAPIWrapper | ||
|
||
from langflow import CustomComponent | ||
from langflow.field_typing import Tool | ||
|
||
|
||
class SearchApiToolComponent(CustomComponent): | ||
display_name: str = "SearchApi Tool" | ||
description: str = "Real-time search engine results API." | ||
documentation: str = "https://www.searchapi.io/docs/google" | ||
field_config = { | ||
"engine": { | ||
"display_name": "Engine", | ||
"field_type": "str", | ||
"info": "The search engine to use.", | ||
}, | ||
"api_key": { | ||
"display_name": "API Key", | ||
"field_type": "str", | ||
"required": True, | ||
"password": True, | ||
"info": "The API key to use SearchApi.", | ||
}, | ||
} | ||
|
||
def build( | ||
self, | ||
engine: str, | ||
api_key: str, | ||
) -> Tool: | ||
search_api_wrapper = SearchApiAPIWrapper(engine=engine, searchapi_api_key=api_key) | ||
|
||
tool = SearchAPIRun(api_wrapper=search_api_wrapper) | ||
|
||
self.status = tool | ||
return tool |