Tool

Integrate Metaphor for Web Search and Content Retrieval

Metaphor Tool connects LlamaIndex agents to Metaphor API for internet search and HTML content retrieval, enabling natural language web queries and document

Works with metaphor

67
Spark score
out of 100
Updated 2 days ago
Version 0.14.23
Models

Add to Favorites

Why it matters

Enhance your AI agent's capabilities by integrating the Metaphor tool to perform web searches, retrieve HTML content, and find similar documents, enabling more informed decision-making and content summarization.

Outcomes

What it gets done

01

Connect to the Metaphor API for internet data access.

02

Search the web for articles based on natural language queries.

03

Retrieve and process HTML content from search results.

04

Find documents similar to a given URL.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/li-tool-tools-metaphor | bash

Overview

Metaphor Tool

Metaphor Tool is a LlamaIndex integration that connects AI agents to the Metaphor search API. It enables agents to search the internet with natural language queries, retrieve HTML content from web pages, find similar documents by URL, and combine search with retrieval in a single operation. The tool is officially deprecated in favor of Exa Tool. This tool is deprecated in favor of Exa Tool. New projects should use Exa Tool instead.

What it does

Metaphor Tool is a LlamaIndex integration that connects AI agents to the Metaphor search API, enabling them to search the internet using natural language queries and retrieve HTML content from discovered web pages. It provides functions including: search for articles using natural language, retrieve documents from search results, combine search and retrieval in one step, find similar documents to a given URL, and access the current date.

When to use - and when NOT to

Do NOT use this tool: it is officially deprecated in favor of Exa Tool. The source material explicitly states this integration is no longer recommended for new projects. Additionally, avoid this tool if you need structured data extraction rather than HTML content, or if your use case does not involve LlamaIndex agents.

Inputs and outputs

Users provide a Metaphor API key obtained from the Metaphor developer dashboard. The tool accepts natural language search queries and URLs for similarity searches.

Integrations

Metaphor Tool integrates with LlamaIndex FunctionAgent for agent-based workflows and OpenAI language models (such as GPT-4) for natural language understanding and response generation. It connects to the Metaphor API service for internet search capabilities.

from llama_index.tools.metaphor import MetaphorToolSpec
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI

metaphor_tool = MetaphorToolSpec(
    api_key="your-key",
)
agent = FunctionAgent(
    tools=metaphor_tool.to_tool_list(),
    llm=OpenAI(model="gpt-4.1"),
)

print(
    await agent.run(
        "Can you summarize the news published in the last month on superconductors"
    )
)

Who it's for

This tool is designed to be used as a way to load data as a Tool in a Agent. However, given its deprecated status, developers should migrate to Exa Tool for new implementations.

Source README

Metaphor Tool

================================================================================

NOTE: Deprecated in favor of Exa Tool.

================================================================================

This tool connects to Metaphor to easily enable
your agent to search and get HTML content from the Internet.

To begin, you need to obtain an API key on the Metaphor developer dashboard.

Usage

This tool has more a extensive example usage documented in a Jupyter notebook here

Here's an example usage of the MetaphorToolSpec.

from llama_index.tools.metaphor import MetaphorToolSpec
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI

metaphor_tool = MetaphorToolSpec(
    api_key="your-key",
)
agent = FunctionAgent(
    tools=metaphor_tool.to_tool_list(),
    llm=OpenAI(model="gpt-4.1"),
)

print(
    await agent.run(
        "Can you summarize the news published in the last month on superconductors"
    )
)

search: Search for a list of articles relating to a natural language query
retrieve_documents: Retrieve a list of documents returned from metaphor_search.
search_and_retrieve_documents: Combines search and retrieve_documents to directly return a list of documents related to a search
find_similar: Find similar documents to a given URL.
current_date: Utility for the Agent to get todays date

This loader is designed to be used as a way to load data as a Tool in a Agent.

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.