Liu Yiwen commited on
Commit
a4c0034
·
1 Parent(s): 7722177

修改了页面布局

Browse files
Files changed (3) hide show
  1. __pycache__/utils.cpython-311.pyc +0 -0
  2. app.py +15 -8
  3. utils.py +4 -2
__pycache__/utils.cpython-311.pyc CHANGED
Binary files a/__pycache__/utils.cpython-311.pyc and b/__pycache__/utils.cpython-311.pyc differ
 
app.py CHANGED
@@ -266,9 +266,12 @@ with gr.Blocks() as demo:
266
  with gr.Row():
267
  with gr.Column(scale=2):
268
  statistics_textbox = gr.DataFrame()
 
 
 
269
  with gr.Column(scale=3):
270
  plot = gr.Plot()
271
- question_info_textbox = gr.DataFrame()
272
  with gr.Row():
273
  user_input_box = gr.Textbox(label="question", interactive=False)
274
  user_output_box = gr.Textbox(label="answer", interactive=False)
@@ -276,16 +279,17 @@ with gr.Blocks() as demo:
276
  # "statistics_textbox": statistics_textbox,
277
  # "user_input_box": user_input_box,
278
  # "plot": plot})
 
279
  with gr.Row():
280
  with gr.Column(scale=1):
281
  choose_retain = gr.Dropdown(["delete", "retain", "modify"], label="Choose to retain or delete or modify", interactive=True)
282
  with gr.Column(scale=2):
283
  choose_retain_reason_box = gr.Textbox(label="Reason", placeholder="Enter your reason", interactive=True)
284
- score_slider = gr.Slider(1, 5, 1, step=0.5, label="Score for answer", interactive=True)
285
  with gr.Row():
286
  with gr.Column(scale=2):
287
- user_submit_button = gr.Button("submit", interactive=True)
288
  user_name_box = gr.Textbox(label="user_name", placeholder="Enter your name firstly", interactive=True)
 
289
  with gr.Column(scale=1):
290
  submit_info_box = gr.Textbox(label="submit_info", interactive=False)
291
  with gr.Row():
@@ -311,7 +315,8 @@ with gr.Blocks() as demo:
311
  ret[plot] = gr.update(value=create_plot(df_list, id_list))
312
  elif dataset == BENCHMARK_DATASET:
313
  df, max_page, info = get_page(dataset, config, split, page)
314
- question_info = get_question_info(df)
 
315
  ret[qusetion_id_box] = gr.update(value = df[COLUMN_ID][0])
316
 
317
  lotsa_config, lotsa_page = str(df[COLUMN_SOURCE][0]).split('/')[-1], eval(df[COLUMN_TS_ID][0])
@@ -322,7 +327,8 @@ with gr.Blocks() as demo:
322
  lotsa_subtargets = eval(df[COLUMN_TARGET_ID][0])
323
  df_list, id_list = process_salesforce_data(TARGET_DATASET, lotsa_config, lotsa_split, lotsa_page, lotsa_subtargets)
324
 
325
- ret[question_info_textbox] = gr.update(value=question_info)
 
326
  ret[statistics_textbox] = gr.update(value=create_statistic(df_list, id_list, interval=interval))
327
  ret[plot] = gr.update(value=create_plot(df_list, id_list, interval=interval))
328
  ret[user_input_box] = gr.update(value=df[COLUMN_QUESTION][0])
@@ -399,7 +405,7 @@ with gr.Blocks() as demo:
399
  qusetion_id_box,
400
  user_input_box, user_output_box,
401
  submit_info_box,
402
- question_info_textbox]
403
 
404
  cp_go.click(show_dataset, inputs=[cp_dataset], outputs=all_outputs)
405
  cp_config.change(show_dataset_at_config, inputs=[cp_dataset, cp_config], outputs=all_outputs)
@@ -413,10 +419,11 @@ with gr.Blocks() as demo:
413
  if __name__ == "__main__":
414
 
415
  app = gr.mount_gradio_app(app, demo, path="/")
416
- host = "127.0.0.1" if os.getenv("DEV") else "0.0.0.0"
 
417
  # import subprocess
418
  # subprocess.Popen(["python", "test_server.py"])
419
- uvicorn.run(app, host=host, port=7860)
420
 
421
  #// 对一下数据 --
422
  #// 部署到服务器上
 
266
  with gr.Row():
267
  with gr.Column(scale=2):
268
  statistics_textbox = gr.DataFrame()
269
+ hr_line = gr.HTML('<hr style="border: 1px solid black;">')
270
+ question_info_textbox_p1 = gr.DataFrame()
271
+ question_info_textbox_p2 = gr.DataFrame()
272
  with gr.Column(scale=3):
273
  plot = gr.Plot()
274
+
275
  with gr.Row():
276
  user_input_box = gr.Textbox(label="question", interactive=False)
277
  user_output_box = gr.Textbox(label="answer", interactive=False)
 
279
  # "statistics_textbox": statistics_textbox,
280
  # "user_input_box": user_input_box,
281
  # "plot": plot})
282
+ hr_line_ = gr.HTML('<hr style="border: 2px dashed black;">')
283
  with gr.Row():
284
  with gr.Column(scale=1):
285
  choose_retain = gr.Dropdown(["delete", "retain", "modify"], label="Choose to retain or delete or modify", interactive=True)
286
  with gr.Column(scale=2):
287
  choose_retain_reason_box = gr.Textbox(label="Reason", placeholder="Enter your reason", interactive=True)
288
+ score_slider = gr.Slider(1, 5, 1, step=1, label="Score for answer", interactive=True)
289
  with gr.Row():
290
  with gr.Column(scale=2):
 
291
  user_name_box = gr.Textbox(label="user_name", placeholder="Enter your name firstly", interactive=True)
292
+ user_submit_button = gr.Button("submit", interactive=True)
293
  with gr.Column(scale=1):
294
  submit_info_box = gr.Textbox(label="submit_info", interactive=False)
295
  with gr.Row():
 
315
  ret[plot] = gr.update(value=create_plot(df_list, id_list))
316
  elif dataset == BENCHMARK_DATASET:
317
  df, max_page, info = get_page(dataset, config, split, page)
318
+ question_info_p1 = get_question_info(df, [COLUMN_DOMAIN, COLUMN_SOURCE])
319
+ question_info_p2 = get_question_info(df, [COLUMN_QA_TYPE, COLUMN_TASK_TYPE])
320
  ret[qusetion_id_box] = gr.update(value = df[COLUMN_ID][0])
321
 
322
  lotsa_config, lotsa_page = str(df[COLUMN_SOURCE][0]).split('/')[-1], eval(df[COLUMN_TS_ID][0])
 
327
  lotsa_subtargets = eval(df[COLUMN_TARGET_ID][0])
328
  df_list, id_list = process_salesforce_data(TARGET_DATASET, lotsa_config, lotsa_split, lotsa_page, lotsa_subtargets)
329
 
330
+ ret[question_info_textbox_p1] = gr.update(value=question_info_p1)
331
+ ret[question_info_textbox_p2] = gr.update(value=question_info_p2)
332
  ret[statistics_textbox] = gr.update(value=create_statistic(df_list, id_list, interval=interval))
333
  ret[plot] = gr.update(value=create_plot(df_list, id_list, interval=interval))
334
  ret[user_input_box] = gr.update(value=df[COLUMN_QUESTION][0])
 
405
  qusetion_id_box,
406
  user_input_box, user_output_box,
407
  submit_info_box,
408
+ question_info_textbox_p1, question_info_textbox_p2]
409
 
410
  cp_go.click(show_dataset, inputs=[cp_dataset], outputs=all_outputs)
411
  cp_config.change(show_dataset_at_config, inputs=[cp_dataset, cp_config], outputs=all_outputs)
 
419
  if __name__ == "__main__":
420
 
421
  app = gr.mount_gradio_app(app, demo, path="/")
422
+ # host = "127.0.0.1" if os.getenv("DEV") else "0.0.0.0"
423
+ host = "0.0.0.0"
424
  # import subprocess
425
  # subprocess.Popen(["python", "test_server.py"])
426
+ uvicorn.run(app, host=host, port=5001)
427
 
428
  #// 对一下数据 --
429
  #// 部署到服务器上
utils.py CHANGED
@@ -141,11 +141,13 @@ def clean_up_df(df: pd.DataFrame, rows_to_include: list[int], name_mapping_map:d
141
  df.drop(columns=['past_feat_dynamic_real'], inplace=True)
142
  return df
143
 
144
- def get_question_info(df: pd.DataFrame) -> pd.DataFrame:
145
  """
146
  从数据集中提取问题信息。
147
  """
148
- question_info = df[[COLUMN_DOMAIN, COLUMN_SOURCE, COLUMN_QA_TYPE, COLUMN_TASK_TYPE]]
 
 
149
  question_info = question_info.drop_duplicates()
150
  return question_info
151
 
 
141
  df.drop(columns=['past_feat_dynamic_real'], inplace=True)
142
  return df
143
 
144
+ def get_question_info(df: pd.DataFrame, info_columns:list|None=None) -> pd.DataFrame:
145
  """
146
  从数据集中提取问题信息。
147
  """
148
+ if info_columns is None:
149
+ info_columns = [COLUMN_DOMAIN, COLUMN_SOURCE, COLUMN_QA_TYPE, COLUMN_TASK_TYPE]
150
+ question_info = df[info_columns]
151
  question_info = question_info.drop_duplicates()
152
  return question_info
153