Update app.py
Browse files
app.py
CHANGED
@@ -360,6 +360,7 @@ def generate_auswahl(prompt_in, file, file_history, chatbot, history, anzahl_doc
|
|
360 |
########################################
|
361 |
# Hochladen von Dateien und Vektorstore neu erstellen
|
362 |
# Beispiel-Upload-PDF-Funktion
|
|
|
363 |
def upload_pdf(files):
|
364 |
if not files:
|
365 |
logging.warning("No files uploaded.")
|
@@ -415,15 +416,13 @@ def upload_pdf(files):
|
|
415 |
status_message += " - Fehler beim Erneuern des Vektorstores."
|
416 |
|
417 |
return status_message, display_files()
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
"""
|
|
|
424 |
def upload_pdf(files):
|
425 |
if not files:
|
426 |
-
|
|
|
|
|
427 |
|
428 |
for file in files:
|
429 |
try:
|
@@ -439,18 +438,32 @@ def upload_pdf(files):
|
|
439 |
upload_path = f"chroma/kkg/word/{filename}"
|
440 |
else:
|
441 |
upload_path = f"chroma/kkg/{filename}"
|
|
|
|
|
|
|
|
|
|
|
442 |
|
443 |
# Datei zum Hugging Face Space hochladen
|
444 |
upload_file_to_huggingface(file.name, upload_path)
|
445 |
|
446 |
except Exception as e:
|
447 |
logging.error(f"Error uploading file {file.name}: {e}")
|
448 |
-
|
449 |
-
#Vektorstore neu
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
454 |
|
455 |
|
456 |
|
|
|
360 |
########################################
|
361 |
# Hochladen von Dateien und Vektorstore neu erstellen
|
362 |
# Beispiel-Upload-PDF-Funktion
|
363 |
+
"""
|
364 |
def upload_pdf(files):
|
365 |
if not files:
|
366 |
logging.warning("No files uploaded.")
|
|
|
416 |
status_message += " - Fehler beim Erneuern des Vektorstores."
|
417 |
|
418 |
return status_message, display_files()
|
|
|
|
|
|
|
|
|
|
|
419 |
"""
|
420 |
+
|
421 |
def upload_pdf(files):
|
422 |
if not files:
|
423 |
+
logging.warning("No files uploaded.")
|
424 |
+
status_message = " Keine Dateien zum Hochladen"
|
425 |
+
else:
|
426 |
|
427 |
for file in files:
|
428 |
try:
|
|
|
438 |
upload_path = f"chroma/kkg/word/{filename}"
|
439 |
else:
|
440 |
upload_path = f"chroma/kkg/{filename}"
|
441 |
+
|
442 |
+
# Entfernen der vorhandenen Datei, falls sie existiert
|
443 |
+
if os.path.exists(upload_path):
|
444 |
+
os.remove(upload_path)
|
445 |
+
logging.info(f"Existing file {upload_path} removed.")
|
446 |
|
447 |
# Datei zum Hugging Face Space hochladen
|
448 |
upload_file_to_huggingface(file.name, upload_path)
|
449 |
|
450 |
except Exception as e:
|
451 |
logging.error(f"Error uploading file {file.name}: {e}")
|
452 |
+
|
453 |
+
# Nachdem alle Dateien hochgeladen wurden, den Vektorstore neu laden
|
454 |
+
try:
|
455 |
+
############################################
|
456 |
+
#Vektorstore neu....
|
457 |
+
############################################
|
458 |
+
create_vectorstore()
|
459 |
+
logging.info("Vektorstore successfully renewed.")
|
460 |
+
status_message += " - Vektorstore wurde erneuert."
|
461 |
+
except Exception as e:
|
462 |
+
logging.error(f"Error renewing Vektorstore: {e}")
|
463 |
+
status_message += " - Fehler beim Erneuern des Vektorstores."
|
464 |
+
|
465 |
+
return status_message, display_files()
|
466 |
+
|
467 |
|
468 |
|
469 |
|