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
anddownload_tool
. You can also installllama-hub
as a package.
Using a Data Loader
Section titled “Using a Data Loader”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))
Using an Agent Tool Spec
Section titled “Using an Agent Tool Spec”In this example we show how to load an agent tool.
from llama_index.tools.google import GmailToolSpec
tool_spec = GmailToolSpec()
# plug into your agentfrom llama_index.core.agent.workflow import FunctionAgentfrom 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")