yaleh commited on
Commit
e446177
·
1 Parent(s): 8274eff

Convert all example outputs to str in process_json_data().

Browse files
Files changed (1) hide show
  1. app/gradio_meta_prompt_utils.py +8 -8
app/gradio_meta_prompt_utils.py CHANGED
@@ -559,17 +559,17 @@ def process_json_data(
559
 
560
  description = result["description"]
561
  examples_directly = [
562
- [example["input"], example["output"]]
563
  for example in result["examples_directly"]["examples"]
564
  ]
565
  input_analysis = result["examples_from_briefs"]["input_analysis"]
566
  new_example_briefs = result["examples_from_briefs"]["new_example_briefs"]
567
  examples_from_briefs = [
568
- [example["input"], example["output"]]
569
  for example in result["examples_from_briefs"]["examples"]
570
  ]
571
  examples = [
572
- [example["input"], example["output"]]
573
  for example in result["additional_examples"]
574
  ]
575
  suggestions = result.get("suggestions", [])
@@ -704,11 +704,11 @@ def append_example_to_input_dataframe(
704
  new_example_input, new_example_output, input_dataframe
705
  ):
706
  try:
707
- new_row = pd.DataFrame(
708
- [[new_example_input, new_example_output]], columns=["Input", "Output"]
709
- )
710
- updated_df = pd.concat([input_dataframe, new_row], ignore_index=True)
711
- return updated_df, None, None, None, None
712
  except KeyError:
713
  raise gr.Error("Invalid input or output")
714
 
 
559
 
560
  description = result["description"]
561
  examples_directly = [
562
+ [str(example["input"]), str(example["output"])]
563
  for example in result["examples_directly"]["examples"]
564
  ]
565
  input_analysis = result["examples_from_briefs"]["input_analysis"]
566
  new_example_briefs = result["examples_from_briefs"]["new_example_briefs"]
567
  examples_from_briefs = [
568
+ [str(example["input"]), str(example["output"])]
569
  for example in result["examples_from_briefs"]["examples"]
570
  ]
571
  examples = [
572
+ [str(example["input"]), str(example["output"])]
573
  for example in result["additional_examples"]
574
  ]
575
  suggestions = result.get("suggestions", [])
 
704
  new_example_input, new_example_output, input_dataframe
705
  ):
706
  try:
707
+ if input_dataframe.empty or (input_dataframe.iloc[-1] == ['', '']).all():
708
+ input_dataframe.iloc[-1] = [new_example_input, new_example_output]
709
+ else:
710
+ input_dataframe = pd.concat([input_dataframe, pd.DataFrame([[new_example_input, new_example_output]], columns=["Input", "Output"])], ignore_index=True)
711
+ return input_dataframe, None, None, None, None
712
  except KeyError:
713
  raise gr.Error("Invalid input or output")
714