bupa1018 commited on
Commit
1c0dbcc
·
1 Parent(s): 9f52dc4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -433,7 +433,10 @@ def initialize():
433
  doc1 = loader1.load()
434
 
435
  with tempfile.TemporaryDirectory() as tmp_dir_path:
436
-
 
 
 
437
  print("Temporary directory path:", tmp_dir_path)
438
 
439
  # Define a new sub-path to append
@@ -442,11 +445,11 @@ def initialize():
442
  # Append the new sub-path to the temporary directory path
443
  home = os.path.join(tmp_dir_path, new_sub_path)
444
 
 
 
 
445
  print("Appended path stored in 'home':", home)
446
- chroma_db = Chroma(embedding_function=EMBEDDING_MODEL_NAME, persist_directory=home)
447
- chorma_db.add_docuemnts(doc1)
448
- chroma_db.persist()
449
-
450
  api.upload_folder(
451
  folder_path=home,
452
  repo_id="bupa1018/KadiAPY_Coding_Assistant", # Replace with your Space ID
 
433
  doc1 = loader1.load()
434
 
435
  with tempfile.TemporaryDirectory() as tmp_dir_path:
436
+
437
+
438
+ def setup_chroma(chunks, model_name="sentence-transformers/all-mpnet-base-v2", persist_directory=r"C:\Users\Anwender\Downloads\chroma_test3"):
439
+
440
  print("Temporary directory path:", tmp_dir_path)
441
 
442
  # Define a new sub-path to append
 
445
  # Append the new sub-path to the temporary directory path
446
  home = os.path.join(tmp_dir_path, new_sub_path)
447
 
448
+ embedding_model = HuggingFaceEmbeddings(model_name=EMBEDDING_MODEL_NAME)
449
+ vectorstore = Chroma.from_texts(texts=chunks, embedding=embedding_model, persist_directory=home)
450
+
451
  print("Appended path stored in 'home':", home)
452
+
 
 
 
453
  api.upload_folder(
454
  folder_path=home,
455
  repo_id="bupa1018/KadiAPY_Coding_Assistant", # Replace with your Space ID