HenryY2023 commited on
Commit
999a470
·
verified ·
1 Parent(s): 946901c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -37,7 +37,7 @@ class ZhipuAILLM(LLM):
37
  )
38
  return response.choices[0].message.content
39
 
40
- # Database setup - use current directory
41
  DB_PATH = "chat_history.db"
42
 
43
  def init_db():
@@ -93,7 +93,14 @@ def initialize_system(pdf_path):
93
  chunks = text_splitter.split_text(text)
94
 
95
  # Create embeddings
96
- embeddings = HuggingFaceEmbeddings(model_name="all-MiniLM-L6-v2")
 
 
 
 
 
 
 
97
 
98
  # Create vector store
99
  vector_store = FAISS.from_texts(chunks, embeddings)
 
37
  )
38
  return response.choices[0].message.content
39
 
40
+ # Database setup
41
  DB_PATH = "chat_history.db"
42
 
43
  def init_db():
 
93
  chunks = text_splitter.split_text(text)
94
 
95
  # Create embeddings
96
+ try:
97
+ embeddings = HuggingFaceEmbeddings(model_name="all-MiniLM-L6-v2")
98
+ except Exception as e:
99
+ print(f"Error with HuggingFaceEmbeddings: {e}")
100
+ # Fallback to a different embedding method
101
+ from langchain.embeddings import FakeEmbeddings
102
+ embeddings = FakeEmbeddings(size=384)
103
+ print("Using FakeEmbeddings as fallback")
104
 
105
  # Create vector store
106
  vector_store = FAISS.from_texts(chunks, embeddings)