Spaces:
Runtime error
Runtime error
sharjeel1477
commited on
Commit
•
2ce8bfd
1
Parent(s):
05f16d4
Update build.py
Browse files
build.py
CHANGED
@@ -16,7 +16,7 @@ logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))
|
|
16 |
pinecone_key = os.environ['PINECONE_KEY']
|
17 |
mongo_key=os.environ["MONGO_KEY"]
|
18 |
|
19 |
-
def add_file(username, filename):
|
20 |
document = {
|
21 |
"brain": username,
|
22 |
"filename": filename,
|
@@ -25,7 +25,7 @@ def add_file(username, filename):
|
|
25 |
collection.insert_one(document)
|
26 |
|
27 |
|
28 |
-
def delete_file(username, filename):
|
29 |
query = {
|
30 |
"brain": username,
|
31 |
"filename": filename
|
@@ -81,7 +81,7 @@ def updateBrain(brainName, files):
|
|
81 |
|
82 |
for prevfile in newfiles:
|
83 |
index.delete_ref_doc(prevfile, delete_from_docstore=True)
|
84 |
-
delete_file(brainName,prevfile)
|
85 |
|
86 |
uploadedFiles=[]
|
87 |
j = 1
|
@@ -90,7 +90,7 @@ def updateBrain(brainName, files):
|
|
90 |
try:
|
91 |
index.insert(doc)
|
92 |
if doc.doc_id not in uploadedFiles:
|
93 |
-
add_file(brainName,doc.doc_id)
|
94 |
uploadedFiles.append(doc.doc_id)
|
95 |
except Exception as e:
|
96 |
if doc.doc_id not in corrupt:
|
|
|
16 |
pinecone_key = os.environ['PINECONE_KEY']
|
17 |
mongo_key=os.environ["MONGO_KEY"]
|
18 |
|
19 |
+
def add_file(collection,username, filename):
|
20 |
document = {
|
21 |
"brain": username,
|
22 |
"filename": filename,
|
|
|
25 |
collection.insert_one(document)
|
26 |
|
27 |
|
28 |
+
def delete_file(collection,username, filename):
|
29 |
query = {
|
30 |
"brain": username,
|
31 |
"filename": filename
|
|
|
81 |
|
82 |
for prevfile in newfiles:
|
83 |
index.delete_ref_doc(prevfile, delete_from_docstore=True)
|
84 |
+
delete_file(collection,brainName,prevfile)
|
85 |
|
86 |
uploadedFiles=[]
|
87 |
j = 1
|
|
|
90 |
try:
|
91 |
index.insert(doc)
|
92 |
if doc.doc_id not in uploadedFiles:
|
93 |
+
add_file(collection,brainName,doc.doc_id)
|
94 |
uploadedFiles.append(doc.doc_id)
|
95 |
except Exception as e:
|
96 |
if doc.doc_id not in corrupt:
|