Find answers from the community

Updated 6 months ago

Agents

At a glance

The post asks whether LlamaIndex can be used to create agents, or if it is preferred to use LangChain instead. Community members respond that LlamaIndex can indeed be used to create agents, and provide documentation and resources on how to do so. They explain that LlamaIndex has a FunctionTool feature that allows turning any function into a tool, similar to LangChain's tool definition. Community members also mention the LlamaHub, which has a collection of community-contributed agent tools.

Useful resources
Can llama index be used to create agents or is it preferred to use langchain instead?
L
e
7 comments
Tons of notebooks and resources there
@Logan M thanks. Is it just me or all the documentation shows query engines as tools.
That's a main tool yea.

You can turn any function into a tool using FunctionTool tho (it's somewhere in the docs)

Plain Text
from llama_index.tools import FunctionTool

def add(a: int, b: int) -> int:
  """Add two numbers."""
  return a+ b

tool = FunctionTool.from_defaults(fn=add)


Here, the tool name is the function name, the description is the docstring. The type hints are also important

We also have community tools on llama hub (just set the filter to agent tools)

https://llamahub.ai/
oh wow. I didn't know it would read the docstring. That's pretty cool. Thanks a ton
For some reason, I was expecting a langchain like tool definition
FunctionTool has arguments to override the description and name if you wanted (so similar to langchain). But I think parsing the function is cleaner πŸ˜‰

LlamaHub has a few neat tools too. The OpenApi one is my favorite -- parsing and using apis right from the yml spec!
Add a reply
Sign up and join the conversation on Discord