tarekfer8 commited on
Commit
db8ea96
·
verified ·
1 Parent(s): 025c907

Update djezzy.py

Browse files
Files changed (1) hide show
  1. djezzy.py +15 -2
djezzy.py CHANGED
@@ -16,12 +16,25 @@ from sklearn.metrics.pairwise import cosine_similarity
16
  import json
17
  import pickle
18
  import numpy as np
19
-
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  model_name = "sentence-transformers/all-MiniLM-L6-v2"
22
 
23
  embedding_llm = SentenceTransformerEmbeddings(model_name=model_name)
24
- loaded_vector_db = FAISS.load_local('index.faiss', embedding_llm, allow_dangerous_deserialization=True)
25
  def load_data(text_filename='docs_text.json', embeddings_filename='docs_embeddings.json'):
26
 
27
 
 
16
  import json
17
  import pickle
18
  import numpy as np
19
+ import shutil
20
+ import tempfile
21
+
22
+ with tempfile.TemporaryDirectory() as temp_dir:
23
+ # Chemins des fichiers cibles dans le répertoire temporaire
24
+ index_target = os.path.join(temp_dir, 'index.txt')
25
+ hh_target = os.path.join(temp_dir, 'hh.txt')
26
+
27
+ # Copier les fichiers dans le répertoire temporaire
28
+ shutil.copy(index_source, index_target)
29
+ shutil.copy(hh_source, hh_target)
30
+
31
+ # Charger la base de données FAISS à partir du répertoire temporaire
32
+ vector_db = FAISS.load_local(temp_dir, embedding_llm, allow_dangerous_deserialization=True)
33
 
34
  model_name = "sentence-transformers/all-MiniLM-L6-v2"
35
 
36
  embedding_llm = SentenceTransformerEmbeddings(model_name=model_name)
37
+
38
  def load_data(text_filename='docs_text.json', embeddings_filename='docs_embeddings.json'):
39
 
40