Adapted from the Griptape AI Framework documentation.
__all__ = ['ExaWebSearchDriver']
module-attribute
Bases:
BaseWebSearchDriver
Source Code in griptape/drivers/web_search/exa_web_search_driver.py
@define class ExaWebSearchDriver(BaseWebSearchDriver): api_key: str = field(kw_only=True, default=None) highlights: bool = field(default=False, kw_only=True) use_autoprompt: bool = field(default=False, kw_only=True) params: dict[str, Any] = field(factory=dict, kw_only=True, metadata={"serializable": True}) _client: Optional[Exa] = field(default=None, kw_only=True, alias="client") @lazy_property() def client(self) -> Exa: return import_optional_dependency("exa_py").Exa(api_key=self.api_key) def search(self, query: str, **kwargs) -> ListArtifact[JsonArtifact]: response = self.client.search_and_contents( # pyright: ignore[reportCallIssue] highlights=self.highlights, # pyright: ignore[reportArgumentType] use_autoprompt=self.use_autoprompt, query=query, num_results=self.results_count, text=True, **self.params, **kwargs, ) results = [ {"title": result.title, "url": result.url, "highlights": result.highlights, "text": result.text} for result in response.results ] return ListArtifact([JsonArtifact(result) for result in results])
_client = field(default=None, kw_only=True, alias='client')
class-attribute instance-attributeapi_key = field(kw_only=True, default=None)
class-attribute instance-attributehighlights = field(default=False, kw_only=True)
class-attribute instance-attributeparams = field(factory=dict, kw_only=True, metadata={'serializable': True})
class-attribute instance-attributeuse_autoprompt = field(default=False, kw_only=True)
class-attribute instance-attribute
client()
Source Code in griptape/drivers/web_search/exa_web_search_driver.py
@lazy_property() def client(self) -> Exa: return import_optional_dependency("exa_py").Exa(api_key=self.api_key)
search(query, **kwargs)
Source Code in griptape/drivers/web_search/exa_web_search_driver.py
def search(self, query: str, **kwargs) -> ListArtifact[JsonArtifact]: response = self.client.search_and_contents( # pyright: ignore[reportCallIssue] highlights=self.highlights, # pyright: ignore[reportArgumentType] use_autoprompt=self.use_autoprompt, query=query, num_results=self.results_count, text=True, **self.params, **kwargs, ) results = [ {"title": result.title, "url": result.url, "highlights": result.highlights, "text": result.text} for result in response.results ] return ListArtifact([JsonArtifact(result) for result in results])
- On this page
- client()
- search(query, **kwargs)
Could this page be better? Report a problem or suggest an addition!