Skip to content

Commit

Permalink
Add SearchApi and SearchApiTool components
Browse files Browse the repository at this point in the history
  • Loading branch information
ogabrielluiz committed Mar 24, 2024
1 parent c7394b3 commit f672a11
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/backend/langflow/components/tools/SearchAPITool.py
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

0 comments on commit f672a11

Please sign in to comment.