Back to Llama Index

Building an Agent with Seltz Web Knowledge

llama-index-integrations/tools/llama-index-tools-seltz/examples/seltz.ipynb

0.14.211.5 KB
Original Source

Building an Agent with Seltz Web Knowledge

This tutorial walks through using the Seltz tool integration to give LLM agents access to fast, up-to-date web knowledge with sources.

Seltz provides context-engineered web content designed for LLMs, AI agents, and RAG pipelines.

To get started, you will need:

python
%pip install llama-index-tools-seltz llama-index
python
import os

os.environ["OPENAI_API_KEY"] = "sk-..."
os.environ["SELTZ_API_KEY"] = "..."
python
from llama_index.tools.seltz import SeltzToolSpec

seltz_tool = SeltzToolSpec(api_key=os.environ["SELTZ_API_KEY"])

tool_list = seltz_tool.to_tool_list()
for tool in tool_list:
    print(tool.metadata.name)

Testing the Seltz search tool

Let's test the search tool directly before using it in an agent.

python
results = seltz_tool.search("What is LlamaIndex?", max_documents=3)

for doc in results:
    print(f"URL: {doc.metadata['url']}")
    print(f"Content: {doc.text[:200]}...")
    print()

Using the search tool in an Agent

Now let's create an agent that can use Seltz to answer questions with up-to-date web knowledge.

python
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI

agent = FunctionAgent(
    tools=tool_list,
    llm=OpenAI(model="gpt-4o"),
)
python
response = await agent.run(
    "What are the latest developments in AI reasoning?"
)
print(response)