Update utils.py
Browse files
utils.py
CHANGED
@@ -406,6 +406,31 @@ def load_vectorstore(filename="vectorstore.pkl"):
|
|
406 |
return pickle.load(f)
|
407 |
return None
|
408 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
409 |
|
410 |
|
411 |
###############################################
|
|
|
406 |
return pickle.load(f)
|
407 |
return None
|
408 |
|
409 |
+
# Beispiel-Funktion zum Erstellen des Vektorstores
|
410 |
+
def create_vectorstore():
|
411 |
+
# Splits zu allen Dokumenten in den Verzeichnissen erstellen
|
412 |
+
PREPROCESSED_SPLITS, SPLIT_TO_ORIGINAL_MAPPING = document_loading_splitting()
|
413 |
+
if PREPROCESSED_SPLITS:
|
414 |
+
# Vektordatenbank zu den Splits erstellen
|
415 |
+
vektordatenbank = document_storage_chroma(PREPROCESSED_SPLITS)
|
416 |
+
# Speichern des Vektorstores
|
417 |
+
save_vectorstore(vektordatenbank)
|
418 |
+
return vektordatenbank
|
419 |
+
else:
|
420 |
+
return None
|
421 |
+
|
422 |
+
# Beispiel-Upload-Funktion
|
423 |
+
def upload_file_to_huggingface(file_path, upload_path):
|
424 |
+
api.upload_file(
|
425 |
+
path_or_fileobj=file_path,
|
426 |
+
path_in_repo=upload_path,
|
427 |
+
repo_id=REPO_ID,
|
428 |
+
repo_type=REPO_TYPE,
|
429 |
+
token=HF_WRITE
|
430 |
+
)
|
431 |
+
|
432 |
+
|
433 |
+
|
434 |
|
435 |
|
436 |
###############################################
|