ArturG9 commited on
Commit
05127d7
·
verified ·
1 Parent(s): 3fbaf5c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -15
app.py CHANGED
@@ -118,22 +118,18 @@ def main():
118
 
119
  script_dir = os.path.dirname(os.path.abspath(__file__))
120
  data_path = os.path.join(script_dir, "data/")
121
- if not os.path.exists(data_path):
122
- st.error(f"Data path does not exist: {data_path}")
123
- return
 
 
 
 
 
 
 
124
 
125
- try:
126
- # Load documents from the data path
127
- documents = load_txt_documents(data_path)
128
- if not documents:
129
- st.warning("No documents found in the data path.")
130
- else:
131
- # Split the documents into chunks
132
- docs = split_docs(documents, 350, 40)
133
- # Add your logic here to use `docs`
134
- st.success("Documents loaded and processed successfully.")
135
- except Exception as e:
136
- st.error(f"An error occurred while loading documents: {e}")
137
 
138
 
139
 
 
118
 
119
  script_dir = os.path.dirname(os.path.abspath(__file__))
120
  data_path = os.path.join(script_dir, "data/")
121
+ for filename in os.listdir(data_path):
122
+
123
+ if filename.endswith('.txt'):
124
+
125
+ file_path = os.path.join(data_path, filename)
126
+
127
+ documents = TextLoader(file_path).load()
128
+
129
+ documents.extend(documents)
130
+
131
 
132
+ docs = split_docs(documents, 350, 40)
 
 
 
 
 
 
 
 
 
 
 
133
 
134
 
135