Lim0011 commited on
Commit
252ce01
·
verified ·
1 Parent(s): 512321c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -30,15 +30,17 @@ def load_example_data():
30
 
31
  for idx in example_data.keys():
32
  try:
33
- with open(os.path.join("example", example_data[idx]["code_init"]), "r") as f:
 
34
  example_data[idx]["code_init"] = f.read()
35
  except FileNotFoundError:
36
- print(f"File not found: {example_data[idx]["code_init"]}. Skipping key: {idx}")
37
  try:
38
- with open(os.path.join("example", example_data[idx]["code_final"]), "r") as f:
 
39
  example_data[idx]["code_final"] = f.read()
40
  except FileNotFoundError:
41
- print(f"File not found: {example_data[idx]["code_final"]}. Skipping key: {idx}")
42
  return example_data
43
 
44
  example_data = load_example_data()
@@ -95,7 +97,7 @@ def start_experiment_agent(hypothesis, plan):
95
  step_index = 0
96
  state_complete = False
97
  # predefined_message = f"Implement the following hypothesis and experiment plan:\n\nHypothesis:\n{hypothesis}\n\nExperiment Plan:\n{plan}"
98
- return example_data[index_ex]['code_init'], predefined_action_log, ""
99
 
100
  def submit_feedback(user_feedback, history, previous_response):
101
  if (not state_extract or not state_generate or not state_agent):
@@ -114,8 +116,7 @@ def submit_feedback(user_feedback, history, previous_response):
114
  state_complete = True
115
  response = "Agent Finished."
116
 
117
-
118
- return msg, response, example_data[index_ex]['code_init'] if state_complete else example_data[index_ex]['code_final']
119
 
120
  def load_phase_2_inputs(hypothesis, plan):
121
  return hypothesis, plan, "# Code implementation will be displayed here after Start ExperimentAgent."
@@ -298,13 +299,13 @@ with gr.Blocks(theme=gr.themes.Default()) as app:
298
  start_exp_agnet.click(
299
  fn=start_experiment_agent,
300
  inputs=[hypothesis_state, experiment_plan_state],
301
- outputs=[code_display, log, response]
302
  )
303
 
304
  submit_button.click(
305
  fn=submit_feedback,
306
  inputs=[feedback, log, response],
307
- outputs=[log, response, code_display]
308
  )
309
 
310
  if __name__ == "__main__":
 
30
 
31
  for idx in example_data.keys():
32
  try:
33
+ file = example_data[idx]["code_init"]
34
+ with open(os.path.join("example", file), "r") as f:
35
  example_data[idx]["code_init"] = f.read()
36
  except FileNotFoundError:
37
+ print(f"File not found: {file}. Skipping key: {idx}")
38
  try:
39
+ file = example_data[idx]["code_final"]
40
+ with open(os.path.join("example", file), "r") as f:
41
  example_data[idx]["code_final"] = f.read()
42
  except FileNotFoundError:
43
+ print(f"File not found: {file}. Skipping key: {idx}")
44
  return example_data
45
 
46
  example_data = load_example_data()
 
97
  step_index = 0
98
  state_complete = False
99
  # predefined_message = f"Implement the following hypothesis and experiment plan:\n\nHypothesis:\n{hypothesis}\n\nExperiment Plan:\n{plan}"
100
+ return example_data[index_ex]['code_init'], predefined_action_log, "", ""
101
 
102
  def submit_feedback(user_feedback, history, previous_response):
103
  if (not state_extract or not state_generate or not state_agent):
 
116
  state_complete = True
117
  response = "Agent Finished."
118
 
119
+ return msg, response, example_data[index_ex]['code_init'] if state_complete else example_data[index_ex]['code_final'], ""
 
120
 
121
  def load_phase_2_inputs(hypothesis, plan):
122
  return hypothesis, plan, "# Code implementation will be displayed here after Start ExperimentAgent."
 
299
  start_exp_agnet.click(
300
  fn=start_experiment_agent,
301
  inputs=[hypothesis_state, experiment_plan_state],
302
+ outputs=[code_display, log, response, feedback]
303
  )
304
 
305
  submit_button.click(
306
  fn=submit_feedback,
307
  inputs=[feedback, log, response],
308
+ outputs=[log, response, code_display, feedback]
309
  )
310
 
311
  if __name__ == "__main__":