StevenChen16 commited on
Commit
a2fadca
1 Parent(s): 04e878e

change FAISS datasets download method

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -5,6 +5,7 @@ from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStream
5
  from threading import Thread
6
  from langchain_community.vectorstores.faiss import FAISS
7
  from langchain_huggingface import HuggingFaceEmbeddings
 
8
 
9
  class RAGChatbot:
10
  def __init__(self):
@@ -91,9 +92,16 @@ class RAGChatbot:
91
  def init_vector_store(self):
92
  """Load vector store from HuggingFace Hub"""
93
  try:
94
- self.vector_store = FAISS.from_huggingface_hub(
 
95
  repo_id="StevenChen16/laws.faiss",
96
- embeddings=self.embeddings,
 
 
 
 
 
 
97
  allow_dangerous_deserialization=True
98
  )
99
  except Exception as e:
 
5
  from threading import Thread
6
  from langchain_community.vectorstores.faiss import FAISS
7
  from langchain_huggingface import HuggingFaceEmbeddings
8
+ from huggingface_hub import snapshot_download
9
 
10
  class RAGChatbot:
11
  def __init__(self):
 
92
  def init_vector_store(self):
93
  """Load vector store from HuggingFace Hub"""
94
  try:
95
+ # Download FAISS files from HuggingFace Hub
96
+ repo_path = snapshot_download(
97
  repo_id="StevenChen16/laws.faiss",
98
+ repo_type="model"
99
+ )
100
+
101
+ # Load the vector store from downloaded files
102
+ self.vector_store = FAISS.load_local(
103
+ repo_path,
104
+ self.embeddings,
105
  allow_dangerous_deserialization=True
106
  )
107
  except Exception as e: