----------------------
I see, you want to update the documents used by a tool in your LlamaIndex setup. Unfortunately, based on the provided knowledge sources, there isn't a direct method to add documents to an existing
VectorStoreIndex
that's already been used to create a
QueryEngineTool
.
However, you can create a new
VectorStoreIndex
with the additional documents and then create a new
QueryEngineTool
with the updated index. Here's how you can do it:
from llama_index.core import VectorStoreIndex, ToolMetadata
from llama_index.agent import QueryEngineTool
# Add the new document to your existing documents
some_docs.append(new_doc)
# Create a new VectorStoreIndex with the updated documents
new_vector_index = VectorStoreIndex.from_documents(some_docs)
# Create a new QueryEngineTool with the updated index
new_query_engine_tool = QueryEngineTool(
query_engine=new_vector_index.as_query_engine(),
metadata=ToolMetadata(
name="new_tool_name",
description="New tool description"
)
)
In this code,
new_doc
is your additional document, and
new_tool_name
and
New tool description
should be replaced with the name and description of your new tool.
Please note that this will create a new tool and won't update the existing one. If you want to replace the existing tool with the new one, you would need to remove the old tool from your toolset and add the new one.
For more information on creating tools, you can refer to the
LlamaIndex documentation ().
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------