I was trying to build a RAG with the combination of both Llamaindex and Milvus, and I was referring to the code from this Llamaindex document: https://docs.llamaindex.ai/en/stable/examples/node_postprocessor/MetadataReplacementDemo/
Based on the code above, I modified it to use mainly Milvus with my own data inserted. However, when I attempted to make the index, some of the nodes were giving errors, saying how the length of dynamic field exceeds max length.
I thought this was due to the fact that the nodes were too big, thus I tried to decrease their sizes but still got the same error.
I was wondering if there is something I can do on the Milvus end, for example increasing the max limit.
The error suggests ‘Please reduce your prompt; or completion length.’, but I am not sure how to do that.
Here is my code for reference:
from llama_index.core import VectorStoreIndex
from llama_index.vector_store.milvus import MilvusVectorStore
from llama_index.core import StorageContext
from pymilvus import MilvusClient
client = MilvusClient(
uri = "http://localhost:19530"
)
if client.has_collection(collection_name = "SWR_collection_for_all_nodes")
client.drop_collection(collection_name = "SWR_collection_for_all_nodes")
count = 0
fails = 0
successes = 0
for x in nodes:
count += 1
try:
del vector_store, storage_context, sentence_index
except:
pass
vector_store = MiluvsVectorStore(uri = "http://localhost:19530", collection_name = "SWR_collection_for_all_nodes", dim = 1536, overwrite = False)
storage_context = StorageContext.from_defaults(vector_store = vector_store)
try:
sentence_index = VectorStoreIndex([x], storage_context = storage_context)
exception Exception as e:
print(f"failed to add node {count} to storage")
print(e)
fails += 1
continue
print(f"node {count} added to storage")
successes += 1
print(f"Added {success} nodes to storage, failed to add {fails} nodes")