Siyuan0730 commited on
Commit
98e9f16
·
1 Parent(s): 70cafa7

修改代码,让btn的点击之后的加载,从col1中解放出来

Browse files
Files changed (1) hide show
  1. app.py +29 -28
app.py CHANGED
@@ -215,41 +215,42 @@ def app():
215
  Chinese = st.checkbox('Output in Chinese')
216
  if Chinese:
217
  language = 'Chinese'
218
- btn_outline = st.button('submit')
219
 
220
 
221
  col1, col2 = st.columns([0.6,0.4], gap='large')
222
-
223
- with col1:
224
 
225
- if btn_outline:
226
- temp_file_paths = []
227
- file_proc_state = st.text("Processing file...")
228
- for added_file in added_files:
229
- with tempfile.NamedTemporaryFile(delete=False, suffix=".md") as tmp:
230
- tmp.write(added_file.getvalue())
231
- tmp_path = tmp.name
232
- temp_file_paths.append(tmp_path)
233
- file_proc_state.text("Processing file...Done")
234
-
235
- outline_generating_state = st.text("Generating Course Oueline...")
236
- course_outline_list = courseOutlineGenerating(temp_file_paths, num_lessons, language)
237
- outline_generating_state.text("Generating Course Oueline...Done")
238
-
239
- course_outline_string = ''
240
- lessons_count = 0
241
- for outline in course_outline_list:
242
- lessons_count += 1
243
- course_outline_string += f"{lessons_count}." + outline[0] + '\n'
244
- course_outline_string += outline[1] + '\n\n'
245
- #time.sleep(1)
 
 
246
  with st.expander("Check the course outline", expanded=False):
247
  st.write(course_outline_string)
248
 
249
- vdb_state = st.text("Constructing vector database from provided materials...")
250
- embeddings_df, faiss_index = constructVDB(temp_file_paths)
251
- vdb_state.text("Constructing vector database from provided materials...Done")
252
-
 
253
  count_generating_content = 0
254
  for lesson in course_outline_list:
255
  count_generating_content += 1
 
215
  Chinese = st.checkbox('Output in Chinese')
216
  if Chinese:
217
  language = 'Chinese'
218
+ btn = st.button('submit')
219
 
220
 
221
  col1, col2 = st.columns([0.6,0.4], gap='large')
 
 
222
 
223
+ if btn:
224
+ temp_file_paths = []
225
+ col1.file_proc_state = st.text("Processing file...")
226
+ for added_file in added_files:
227
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".md") as tmp:
228
+ tmp.write(added_file.getvalue())
229
+ tmp_path = tmp.name
230
+ temp_file_paths.append(tmp_path)
231
+ col1.file_proc_state.text("Processing file...Done")
232
+
233
+ col1.outline_generating_state = st.text("Generating Course Oueline...")
234
+ course_outline_list = courseOutlineGenerating(temp_file_paths, num_lessons, language)
235
+ col1.outline_generating_state.text("Generating Course Oueline...Done")
236
+
237
+ #把课程大纲打印出来
238
+ course_outline_string = ''
239
+ lessons_count = 0
240
+ for outline in course_outline_list:
241
+ lessons_count += 1
242
+ course_outline_string += f"{lessons_count}." + outline[0] + '\n'
243
+ course_outline_string += '\n' + outline[1] + '\n\n'
244
+ #time.sleep(1)
245
+ with col1:
246
  with st.expander("Check the course outline", expanded=False):
247
  st.write(course_outline_string)
248
 
249
+ col1.vdb_state = st.text("Constructing vector database from provided materials...")
250
+ embeddings_df, faiss_index = constructVDB(temp_file_paths)
251
+ col1.vdb_state.text("Constructing vector database from provided materials...Done")
252
+
253
+ with col1:
254
  count_generating_content = 0
255
  for lesson in course_outline_list:
256
  count_generating_content += 1