bupa1018 commited on
Commit
2c0ea57
·
1 Parent(s): e257401

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -4
app.py CHANGED
@@ -404,7 +404,7 @@ def initialize():
404
 
405
  download_gitlab_project_by_version()
406
 
407
- code_folder_paths = ['kadi_apy']
408
  doc_folder_paths = ['docs/source/']
409
 
410
 
@@ -425,10 +425,36 @@ def initialize():
425
  #codestore = embed_documents_into_vectorstore(kadiAPY_doc_chunks, EMBEDDING_MODEL_NAME, PERSIST_CODE_DIRECTORY)
426
  filename = "test"
427
  vector_store = embed_documents_into_vectorstore(doc_chunks + code_chunks, EMBEDDING_MODEL_NAME, f"{DATA_DIR}/{filename}")
428
- print("HELLLLLLLLLO:", os.getcwd()) # Check the current working directory
429
- print("BYYYYYYYYYYYYE:", os.listdir()) # List files and folders in the current
430
  llm = setup_llm(LLM_MODEL_NAME, LLM_TEMPERATURE, GROQ_API_KEY)
431
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
432
  initialize()
433
 
434
 
 
404
 
405
  download_gitlab_project_by_version()
406
 
407
+ code_folder_paths = []
408
  doc_folder_paths = ['docs/source/']
409
 
410
 
 
425
  #codestore = embed_documents_into_vectorstore(kadiAPY_doc_chunks, EMBEDDING_MODEL_NAME, PERSIST_CODE_DIRECTORY)
426
  filename = "test"
427
  vector_store = embed_documents_into_vectorstore(doc_chunks + code_chunks, EMBEDDING_MODEL_NAME, f"{DATA_DIR}/{filename}")
 
 
428
  llm = setup_llm(LLM_MODEL_NAME, LLM_TEMPERATURE, GROQ_API_KEY)
429
+
430
+ from langchain.document_loaders import TextLoader
431
+
432
+ loader1 = TextLoader("text1.txt")
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
440
+ new_sub_path = "new_folder"
441
+
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
453
+ repo_type="space" # Ensure repo type is 'space'
454
+ )
455
+ print(f"New folder created at: {home}"
456
+
457
+
458
  initialize()
459
 
460