----------------------
Based on the provided knowledge sources, there is no direct method to add more tools to an instance of
FunctionCallingAgentWorker
after it has been created. The
FunctionCallingAgentWorker
is initialized with a set of tools or a
tool_retriever
, and these are not designed to be modified after the instance has been created.
However, there is a way to work around this by using a
tool_retriever
. The
tool_retriever
is an instance of
ObjectRetriever
that can retrieve tools based on some criteria. If you initialize the
FunctionCallingAgentWorker
with a
tool_retriever
, you can potentially modify the underlying data of the
tool_retriever
to change the tools that are available.
Here is an example of creating a
FunctionCallingAgentWorker
with a
tool_retriever
:
from llama_index.core import VectorStoreIndex
from llama_index.core.objects import ObjectIndex
# define an "object" index and retriever over these tools
obj_index = ObjectIndex.from_objects(
all_tools,
index_cls=VectorStoreIndex,
)
obj_retriever = obj_index.as_retriever(similarity_top_k=3)
agent_worker = FunctionCallingAgentWorker.from_tools(
tool_retriever=obj_retriever,
llm=vertex_gemini,
system_prompt="""
You are an agent designed to answer queries over a set of given papers.
Please use the tools provided to answer a question as possible. Do not rely on prior knowledge. Summarize your answer\
""",
verbose=True,
)
agent = AgentRunner(agent_worker)
In this example,
all_tools
is a list of all the tools you want to use. If you want to add more tools, you can modify
all_tools
and recreate
obj_index
,
obj_retriever
, and
agent_worker
.
Please note that this is a workaround and may not be the best practice. It's always recommended to initialize the
FunctionCallingAgentWorker
with all the tools you plan to use.