Skip to content

LlamaHub Demostration

Here we give a simple overview of how to use data loaders and tools (for agents) within LlamaHub.

NOTES:

  • You can learn how to use everything in LlamaHub by clicking into each module and looking at the code snippet.
  • Also, you can find a full list of agent tools here.
  • In this guide we’ll show how to use download_loader and download_tool. You can also install llama-hub as a package.

In this example we show how to use SimpleWebPageReader.

NOTE: for any module on LlamaHub, to use with download_ functions, note down the class name.

%pip install llama-index-agent-openai
%pip install llama-index-readers-web
%pip install llama-index-tools-google
from llama_index.readers.web import SimpleWebPageReader
reader = SimpleWebPageReader(html_to_text=True)
docs = reader.load_data(urls=["https://eugeneyan.com/writing/llm-patterns/"])
print(docs[0].get_content()[:400])
# [eugeneyan](/)
* [Start Here](/start-here/ "Start Here")
* [Writing](/writing/ "Writing")
* [Speaking](/speaking/ "Speaking")
* [Prototyping](/prototyping/ "Prototyping")
* [About](/about/ "About")
# Patterns for Building LLM-based Systems & Products
[ [llm](/tag/llm/) [engineering](/tag/engineering/)
[production](/tag/production/) ] · 66 min read
> Discussions on [HackerNews](htt

Now you can plug these docs into your downstream LlamaIndex pipeline.

from llama_index.core import VectorStoreIndex
index = VectorStoreIndex.from_documents(docs)
query_engine = index.as_query_engine()
response = query_engine.query("What are ways to evaluate LLMs?")
print(str(response))

In this example we show how to load an agent tool.

from llama_index.tools.google import GmailToolSpec
tool_spec = GmailToolSpec()
# plug into your agent
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI
agent = FunctionAgent(
tools=tool_spec.to_tool_list(),
llm=OpenAI(model="gpt-4.1-mini"),
)
await agent.run("What is my most recent email")