tool
Adapted from the Griptape AI Framework documentation.
Bases:
BaseTool
Source Code in griptape/tools/web_search/tool.py
@define class WebSearchTool(BaseTool): web_search_driver: BaseWebSearchDriver = field(kw_only=True) @activity( config={ "description": "Can be used for searching the web via the {{ _self.web_search_driver.__class__.__name__}}.", "schema": Schema( { Literal( "query", description="Search engine request that returns a list of pages with titles, descriptions, and URLs", ): str, }, ), }, ) def search(self, values: dict) -> ListArtifact | ErrorArtifact: # `BaseWebSearchDriver.query` already has a parameter named `query`, so we need to pop it from the values # to avoid passing it twice. query = values.pop("query") try: return self.web_search_driver.search(query, **values) except Exception as e: return ErrorArtifact(f"Error searching '{query}' with {self.web_search_driver.__class__.__name__}: {e}")
web_search_driver = field(kw_only=True)
class-attribute instance-attribute
search(values)
Source Code in griptape/tools/web_search/tool.py
@activity( config={ "description": "Can be used for searching the web via the {{ _self.web_search_driver.__class__.__name__}}.", "schema": Schema( { Literal( "query", description="Search engine request that returns a list of pages with titles, descriptions, and URLs", ): str, }, ), }, ) def search(self, values: dict) -> ListArtifact | ErrorArtifact: # `BaseWebSearchDriver.query` already has a parameter named `query`, so we need to pop it from the values # to avoid passing it twice. query = values.pop("query") try: return self.web_search_driver.search(query, **values) except Exception as e: return ErrorArtifact(f"Error searching '{query}' with {self.web_search_driver.__class__.__name__}: {e}")
- On this page
- search(values)
Could this page be better? Report a problem or suggest an addition!