alexkueck commited on
Commit
f86fc4a
1 Parent(s): 623a275

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +18 -5
utils.py CHANGED
@@ -138,6 +138,7 @@ YOUTUBE_DIR = "/youtube"
138
  HISTORY_PFAD = "/data/history"
139
  DOCS_DIR_PDF = "chroma/kkg/pdf"
140
  DOCS_DIR_WORD = "chroma/kkg/word"
 
141
 
142
  ###############################################
143
  #URLs zu Dokumenten oder andere Inhalte, die einbezogen werden sollen
@@ -396,13 +397,25 @@ def document_storage_chroma(splits):
396
 
397
  ########################################################
398
  #Vektorstore speichern - bzw. laden
399
- def save_splits_and_metadata(splits, filename="splits_and_metadata.pkl"):
400
- with open(filename, "wb") as f:
 
 
 
 
 
 
 
 
401
  pickle.dump(splits, f)
402
 
403
- def load_splits_and_metadata(filename="splits_and_metadata.pkl"):
404
- if os.path.exists(filename):
405
- with open(filename, "rb") as f:
 
 
 
 
406
  return pickle.load(f)
407
  return None
408
 
 
138
  HISTORY_PFAD = "/data/history"
139
  DOCS_DIR_PDF = "chroma/kkg/pdf"
140
  DOCS_DIR_WORD = "chroma/kkg/word"
141
+ VECTORSTORE_DIR="chroma/kkg"
142
 
143
  ###############################################
144
  #URLs zu Dokumenten oder andere Inhalte, die einbezogen werden sollen
 
397
 
398
  ########################################################
399
  #Vektorstore speichern - bzw. laden
400
+ def save_splits_and_metadata(splits, directory="chroma/kkg", filename="splits_and_metadata.pkl"):
401
+ # Erstellen des Verzeichnisses, falls es nicht existiert
402
+ if not os.path.exists(directory):
403
+ os.makedirs(directory)
404
+
405
+ # Vollständigen Pfad zur Datei erstellen
406
+ filepath = os.path.join(directory, filename)
407
+
408
+ # Speichern der Splits und Metadaten in der Datei
409
+ with open(filepath, "wb") as f:
410
  pickle.dump(splits, f)
411
 
412
+ def load_splits_and_metadata(directory="chroma/kkg", filename="splits_and_metadata.pkl"):
413
+ # Vollständigen Pfad zur Datei erstellen
414
+ filepath = os.path.join(directory, filename)
415
+
416
+ # Laden der Splits und Metadaten aus der Datei
417
+ if os.path.exists(filepath):
418
+ with open(filepath, "rb") as f:
419
  return pickle.load(f)
420
  return None
421