ArturG9 commited on
Commit
c923605
·
verified ·
1 Parent(s): 2c3a2a1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py CHANGED
@@ -114,8 +114,27 @@ def create_conversational_rag_chain(vectorstore):
114
  def main():
115
  """Main function for the Streamlit app."""
116
  # Initialize chat history if not already present in session state
 
 
 
117
  script_dir = os.path.dirname(os.path.abspath(__file__))
118
  data_path = os.path.join(script_dir, "data/")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
 
120
 
121
 
 
114
  def main():
115
  """Main function for the Streamlit app."""
116
  # Initialize chat history if not already present in session state
117
+
118
+ documents = []
119
+
120
  script_dir = os.path.dirname(os.path.abspath(__file__))
121
  data_path = os.path.join(script_dir, "data/")
122
+ if not os.path.exists(data_path):
123
+ st.error(f"Data path does not exist: {data_path}")
124
+ return
125
+
126
+ try:
127
+ # Load documents from the data path
128
+ documents = load_txt_documents(data_path)
129
+ if not documents:
130
+ st.warning("No documents found in the data path.")
131
+ else:
132
+ # Split the documents into chunks
133
+ docs = split_docs(documents, 350, 40)
134
+ # Add your logic here to use `docs`
135
+ st.success("Documents loaded and processed successfully.")
136
+ except Exception as e:
137
+ st.error(f"An error occurred while loading documents: {e}")
138
 
139
 
140