Wenye He commited on
Commit
9ccabc7
·
verified ·
1 Parent(s): 7788bc9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -56,9 +56,9 @@ class ChatModel:
56
  self.current_store = None
57
  self.current_vectorstore = None
58
  # Use the same embedding model as in vector store creation
59
- self.embeddings = HuggingFaceEmbeddings(
60
- model_name="sentence-transformers/all-MiniLM-L6-v2"
61
- )
62
 
63
  def load_model(self, model_name):
64
  """Load and cache the model and tokenizer"""
@@ -88,14 +88,17 @@ class ChatModel:
88
  if self.current_store != store_name:
89
  logger.info(f"Loading new vector store: {store_name}")
90
  vector_store_path = f"vector_stores_index/{store_name}"
91
-
92
  if not os.path.exists(vector_store_path):
93
  raise ValueError(f"Vector store not found at: {vector_store_path}")
94
-
 
 
 
95
  # Load new vector store
96
  self.current_vectorstore = FAISS.load_local(
97
  vector_store_path,
98
- self.embeddings,
99
  allow_dangerous_deserialization=True
100
  )
101
  self.current_store = store_name
 
56
  self.current_store = None
57
  self.current_vectorstore = None
58
  # Use the same embedding model as in vector store creation
59
+ # self.embeddings = HuggingFaceEmbeddings(
60
+ # model_name="sentence-transformers/all-MiniLM-L6-v2"
61
+ # )
62
 
63
  def load_model(self, model_name):
64
  """Load and cache the model and tokenizer"""
 
88
  if self.current_store != store_name:
89
  logger.info(f"Loading new vector store: {store_name}")
90
  vector_store_path = f"vector_stores_index/{store_name}"
91
+ logger.info(f"vector store path: {vector_store_path}")
92
  if not os.path.exists(vector_store_path):
93
  raise ValueError(f"Vector store not found at: {vector_store_path}")
94
+
95
+ embeddings = HuggingFaceEmbeddings(
96
+ model_name="sentence-transformers/all-MiniLM-L6-v2"
97
+ )
98
  # Load new vector store
99
  self.current_vectorstore = FAISS.load_local(
100
  vector_store_path,
101
+ embeddings,
102
  allow_dangerous_deserialization=True
103
  )
104
  self.current_store = store_name