Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -12,6 +12,7 @@ import json
|
|
12 |
# Global variables to store session state
|
13 |
env = None
|
14 |
agent = None
|
|
|
15 |
state_extract = False
|
16 |
state_generate = False
|
17 |
state_agent = False
|
@@ -57,7 +58,8 @@ example_text = [load_example(1), load_example(2)]
|
|
57 |
|
58 |
# Function to handle example clicks
|
59 |
def load_example_and_set_index(paper_text_input):
|
60 |
-
global index_ex
|
|
|
61 |
index_ex = str(example_text.index(paper_text_input) + 1)
|
62 |
paper_text = load_example(index_ex)
|
63 |
|
@@ -68,7 +70,9 @@ def load_example_and_set_index(paper_text_input):
|
|
68 |
########## Phase 1 ##############
|
69 |
|
70 |
def extract_research_elements(paper_text):
|
71 |
-
global state_extract, index_ex
|
|
|
|
|
72 |
state_extract = True
|
73 |
example = example_data[index_ex]
|
74 |
tasks = example['research_tasks']
|
@@ -80,7 +84,7 @@ def extract_research_elements(paper_text):
|
|
80 |
|
81 |
# Step 2: Generate Research Hypothesis and Experiment Plan
|
82 |
def generate_and_store(tasks, gaps, keywords, recent_works):
|
83 |
-
if (not state_extract):
|
84 |
return "", "", "", ""
|
85 |
global state_generate, index_ex
|
86 |
state_generate = True
|
@@ -90,7 +94,7 @@ def generate_and_store(tasks, gaps, keywords, recent_works):
|
|
90 |
|
91 |
########## Phase 2 & 3 ##############
|
92 |
def start_experiment_agent(hypothesis, plan):
|
93 |
-
if (not state_extract or not
|
94 |
return "", "", ""
|
95 |
global state_agent, step_index, state_complete
|
96 |
state_agent = True
|
@@ -100,7 +104,7 @@ def start_experiment_agent(hypothesis, 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):
|
104 |
return "", "", ""
|
105 |
global step_index, state_complete
|
106 |
step_index += 1
|
|
|
12 |
# Global variables to store session state
|
13 |
env = None
|
14 |
agent = None
|
15 |
+
state_example = False
|
16 |
state_extract = False
|
17 |
state_generate = False
|
18 |
state_agent = False
|
|
|
58 |
|
59 |
# Function to handle example clicks
|
60 |
def load_example_and_set_index(paper_text_input):
|
61 |
+
global index_ex, state_example
|
62 |
+
state_example = True
|
63 |
index_ex = str(example_text.index(paper_text_input) + 1)
|
64 |
paper_text = load_example(index_ex)
|
65 |
|
|
|
70 |
########## Phase 1 ##############
|
71 |
|
72 |
def extract_research_elements(paper_text):
|
73 |
+
global state_extract, index_ex, state_example
|
74 |
+
if not state_example:
|
75 |
+
return "", "", "", ""
|
76 |
state_extract = True
|
77 |
example = example_data[index_ex]
|
78 |
tasks = example['research_tasks']
|
|
|
84 |
|
85 |
# Step 2: Generate Research Hypothesis and Experiment Plan
|
86 |
def generate_and_store(tasks, gaps, keywords, recent_works):
|
87 |
+
if (not state_extract or not state_example):
|
88 |
return "", "", "", ""
|
89 |
global state_generate, index_ex
|
90 |
state_generate = True
|
|
|
94 |
|
95 |
########## Phase 2 & 3 ##############
|
96 |
def start_experiment_agent(hypothesis, plan):
|
97 |
+
if (not state_extract or not state_generate or not state_example):
|
98 |
return "", "", ""
|
99 |
global state_agent, step_index, state_complete
|
100 |
state_agent = True
|
|
|
104 |
return example_data[index_ex]['code_init'], predefined_action_log, "", ""
|
105 |
|
106 |
def submit_feedback(user_feedback, history, previous_response):
|
107 |
+
if (not state_extract or not state_generate or not state_agent or not state_example):
|
108 |
return "", "", ""
|
109 |
global step_index, state_complete
|
110 |
step_index += 1
|