eli02 commited on
Commit
d4bf6ac
·
1 Parent(s): abefdb6

update: Change database loading method to use a predefined path and add error handling

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -21,10 +21,10 @@ def main():
21
  # Load embedding model
22
  embedding_model = SentenceTransformer(model_name_or_path="all-mpnet-base-v2", device=device)
23
 
24
- # File upload for the database
25
- database_file = st.file_uploader("Upload the Parquet database file", type=["parquet"])
26
 
27
- if database_file is not None:
28
  df, chunk_embeddings = load_data(database_file)
29
  st.success("Database loaded successfully!")
30
 
@@ -52,6 +52,8 @@ def main():
52
  st.write(f"**Text:** {df.iloc[int(idx)]['ext']}")
53
  st.write(f"**Number of tokens:** {df.iloc[int(idx)]['tokens']}")
54
  st.write("---")
 
 
55
 
56
  if __name__ == "__main__":
57
  main()
 
21
  # Load embedding model
22
  embedding_model = SentenceTransformer(model_name_or_path="all-mpnet-base-v2", device=device)
23
 
24
+ # Load database from predefined path
25
+ database_file = '[Embedded Chunks] The Alchemy of Happiness (Ghazzālī, Claud Field) (Z-Library).parquet'
26
 
27
+ try:
28
  df, chunk_embeddings = load_data(database_file)
29
  st.success("Database loaded successfully!")
30
 
 
52
  st.write(f"**Text:** {df.iloc[int(idx)]['ext']}")
53
  st.write(f"**Number of tokens:** {df.iloc[int(idx)]['tokens']}")
54
  st.write("---")
55
+ except Exception as e:
56
+ st.error(f"Failed to load database: {str(e)}")
57
 
58
  if __name__ == "__main__":
59
  main()