metaphor_search_tool
langroid/agent/tools/metaphor_search_tool.py
A tool to trigger a Metaphor search for a given query,
(https://docs.exa.ai/reference/getting-started)
and return the top results with their titles, links, summaries.
Since the tool is stateless (i.e. does not need
access to agent state), it can be enabled for any agent, without having to define a
special method inside the agent: agent.enable_message(MetaphorSearchTool)
NOTE: To use this tool, you need to:
-
set the METAPHOR_API_KEY environment variables in your
.env
file, e.g.METAPHOR_API_KEY=your_api_key_here
(Note as of 28 Jan 2023, Metaphor renamed to Exa, so you can also useEXA_API_KEY=your_api_key_here
) -
install langroid with the
metaphor
extra, e.g.pip install langroid[metaphor]
orpoetry add langroid[metaphor]
(it installs themetaphor-python
package from pypi).
For more information, please refer to the official docs: https://metaphor.systems/
MetaphorSearchTool
¶
Bases: ToolMessage
handle()
¶
Conducts a search using the metaphor API based on the provided query and number of results by triggering a metaphor_search.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
A formatted string containing the titles, links, and summaries of each search result, separated by two newlines. |