youngtsai commited on
Commit
30e87ad
1 Parent(s): 915c63d

df_string = df.to_string()

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -14,11 +14,17 @@ def process_file(file):
14
  df = pd.read_csv(file)
15
  else:
16
  df = pd.read_excel(file)
17
-
18
- # 将 DataFrame 转换为字符串
19
  df_string = df.to_string()
20
 
21
- return update_buttons(df_string), df_string
 
 
 
 
 
 
 
22
 
23
  def update_buttons(df_string):
24
  # 根据上传的文件内容生成问题
@@ -104,7 +110,7 @@ with gr.Blocks() as demo:
104
  )
105
 
106
  # file_upload.change(process_file, inputs=file_upload, outputs=df_string_output)
107
- file_upload.change(process_file, inputs=file_upload, outputs=[(btn_1, "text"), (btn_2, "text"), (btn_3, "text"), df_string_output])
108
 
109
 
110
  # 连接按钮点击事件
 
14
  df = pd.read_csv(file)
15
  else:
16
  df = pd.read_excel(file)
17
+
 
18
  df_string = df.to_string()
19
 
20
+ # 根据上传的文件内容生成问题
21
+ questions = generate_questions(df_string)
22
+
23
+ # 返回按钮文本和 DataFrame 字符串
24
+ return questions[0] if len(questions) > 0 else "", \
25
+ questions[1] if len(questions) > 1 else "", \
26
+ questions[2] if len(questions) > 2 else "", \
27
+ df_string
28
 
29
  def update_buttons(df_string):
30
  # 根据上传的文件内容生成问题
 
110
  )
111
 
112
  # file_upload.change(process_file, inputs=file_upload, outputs=df_string_output)
113
+ file_upload.change(process_file, inputs=file_upload, outputs=[btn_1, btn_2, btn_3, df_string_output])
114
 
115
 
116
  # 连接按钮点击事件