Find answers from the community

Updated 2 months ago

Agents

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