Find answers from the community

Updated 3 months ago

Hi,

Hi,

Does anyone know how to make a python function into a tool? Similar to Assistants of OpenAI where you can turn any funtion into a tool and then the assistant intellignetly uses that tool, how can I do that with llamaIndex (like perhpas data agents) without using OpenAI?

Thank you
L
M
4 comments
Plain Text
from llama_index.core.tools import FunctionTool

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

tool = FunctionTool.from_defaults(fn=add)
Thank you so much, this is great and I really appreciate it! Would you mind sharing a link to its doc or any further examples? Thanks again πŸ™‚
Thank you so much for taking the time and sharing these resources with me! πŸ™‚
Add a reply
Sign up and join the conversation on Discord