Anne31415 commited on
Commit
e67aebd
·
1 Parent(s): 93039f8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -45,6 +45,8 @@ api_key = os.getenv("OPENAI_API_KEY")
45
 
46
  # Updated caching mechanism using st.cache_data
47
  @st.cache_data(persist="disk")
 
 
48
  def load_vector_store(file_path, store_name, force_reload=False):
49
  try:
50
  if force_reload or not os.path.exists(f"{store_name}.pkl"):
@@ -59,17 +61,27 @@ def load_vector_store(file_path, store_name, force_reload=False):
59
 
60
  embeddings = OpenAIEmbeddings()
61
  VectorStore = FAISS.from_texts(chunks, embedding=embeddings)
 
 
 
 
 
 
 
 
 
 
62
  with open(f"{store_name}.pkl", "wb") as f:
63
  pickle.dump(VectorStore, f)
64
  else:
65
  with open(f"{store_name}.pkl", "rb") as f:
66
  VectorStore = pickle.load(f)
67
-
68
  return VectorStore
69
 
70
  except Exception as e:
71
  st.error(f"An error occurred: {e}")
72
- traceback.print_exc() # This will print the full traceback to the console
73
  return None
74
 
75
 
 
45
 
46
  # Updated caching mechanism using st.cache_data
47
  @st.cache_data(persist="disk")
48
+ import traceback
49
+
50
  def load_vector_store(file_path, store_name, force_reload=False):
51
  try:
52
  if force_reload or not os.path.exists(f"{store_name}.pkl"):
 
61
 
62
  embeddings = OpenAIEmbeddings()
63
  VectorStore = FAISS.from_texts(chunks, embedding=embeddings)
64
+
65
+ # Inspect the VectorStore object
66
+ print("Inspecting VectorStore object...")
67
+ print("Type of VectorStore:", type(VectorStore))
68
+ print("Attributes of VectorStore:", dir(VectorStore))
69
+
70
+ # Additional specific inspections if necessary
71
+ # for example, if VectorStore has an attribute 'some_attribute':
72
+ # print("VectorStore.some_attribute:", VectorStore.some_attribute)
73
+
74
  with open(f"{store_name}.pkl", "wb") as f:
75
  pickle.dump(VectorStore, f)
76
  else:
77
  with open(f"{store_name}.pkl", "rb") as f:
78
  VectorStore = pickle.load(f)
79
+
80
  return VectorStore
81
 
82
  except Exception as e:
83
  st.error(f"An error occurred: {e}")
84
+ traceback.print_exc()
85
  return None
86
 
87