Find answers from the community

Updated 11 months ago

Can we have nest chat agents? Agent use

Can we have nest chat agents? Agent use another agent as tools?
L
r
9 comments
yea you can. You can make anything a tool using FunctionTool
@Logan M seem cannot find any example notebook on this?
Do u by chance know how to pass customised prompt for each tool? Like if this tool is used please use this prompt
It doesn't really work like that?

Here's an example

Plain Text
from llama_index.tools import FunctionTool

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

tool = Function_tool.from_defaults(fn)


Here, the name of the tool is the function name, and the description is the docstring. You could override that in from_defaults() call as well. The type hints are also important

So you can wrap virtually anything into a tool, and do whatever you want once that tool gets called
I think I am looking for much more complex case where this function is another OpenAIAgent , I am not sure the wrapper works
Sure it does

Plain Text
def agent(input_str: str) -> str:
  """Useful for asking information about X."""
   response = agent.chat(input_str)
  return str(response)
Actually I think there's a few examples of hierarchical agents in the docs
Since the agent also extends the query engine class, you can also wrap it with the QueryEngineTool class
Add a reply
Sign up and join the conversation on Discord