Update app.py
Browse files
app.py
CHANGED
@@ -76,15 +76,15 @@ if uploaded_file is not None:
|
|
76 |
example_data_generator = map(lambda i: (f'id-{i}', pdf_vectors[i], {"text": texts[i]}), range(vector_count))
|
77 |
# Update the Pinecone index with new vectors
|
78 |
for ids_vectors_chunk in chunks(example_data_generator, batch_size=100): # Iterate through chunks of example data
|
79 |
-
|
80 |
-
|
81 |
|
82 |
-
ns_count = index.describe_index_stats()['namespaces']['ns1']['vector_count'] # Get current vector count in namespace 'ns1'
|
83 |
|
84 |
-
if vector_count < ns_count: # Check if the old vectors are still inside
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
|
89 |
# Input for the search query
|
90 |
with st.form(key='my_form'):
|
|
|
76 |
example_data_generator = map(lambda i: (f'id-{i}', pdf_vectors[i], {"text": texts[i]}), range(vector_count))
|
77 |
# Update the Pinecone index with new vectors
|
78 |
for ids_vectors_chunk in chunks(example_data_generator, batch_size=100): # Iterate through chunks of example data
|
79 |
+
index.upsert(vectors=ids_vectors_chunk, namespace='ns1') # Upsert (update or insert) vectors
|
80 |
+
time.sleep(0.05) # Pause to avoid overwhelming the server
|
81 |
|
82 |
+
ns_count = index.describe_index_stats()['namespaces']['ns1']['vector_count'] # Get current vector count in namespace 'ns1'
|
83 |
|
84 |
+
if vector_count < ns_count: # Check if the old vectors are still inside
|
85 |
+
ids_to_delete = [f'id-{i}' for i in range(vector_count, ns_count)] # Generate list of IDs to delete
|
86 |
+
index.delete(ids=ids_to_delete, namespace='ns1') # Delete old vectors
|
87 |
+
time.sleep(0.05) # Pause to avoid overwhelming the server
|
88 |
|
89 |
# Input for the search query
|
90 |
with st.form(key='my_form'):
|