Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -17,6 +17,10 @@ state_agent = False
|
|
17 |
state_complete = False
|
18 |
index_ex = "1"
|
19 |
|
|
|
|
|
|
|
|
|
20 |
|
21 |
# Load example JSON file
|
22 |
def load_example_data():
|
@@ -39,6 +43,18 @@ def load_example(example_id):
|
|
39 |
paper_text = 'Title:\t' + example['title'] + '\nAbstract:\t' + example['abstract']
|
40 |
return paper_text
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
########## Phase 1 ##############
|
43 |
|
44 |
def extract_research_elements(paper_text):
|
@@ -176,11 +192,15 @@ def info_to_message(info):
|
|
176 |
return msg
|
177 |
|
178 |
|
|
|
|
|
|
|
|
|
179 |
|
180 |
# Gradio Interface
|
181 |
with gr.Blocks() as app:
|
182 |
-
gr.Markdown("# MLR- Copilot:
|
183 |
-
gr.Markdown("MLR-Copilot is a framework where LLMs mimic researchers’ thought processes, designed to enhance the productivity of machine learning research by automating the generation and implementation of research ideas.It begins with a research paper, autonomously generating and validating these ideas, while incorporating human feedback to help reach executable research outcomes.")
|
184 |
|
185 |
|
186 |
# Use state variables to store generated hypothesis and experiment plan
|
@@ -190,9 +210,6 @@ with gr.Blocks() as app:
|
|
190 |
########## Phase 1: Research Idea Generation Tab ##############
|
191 |
with gr.Tab("Phase 1: Research Idea Generation"):
|
192 |
gr.Markdown("### Extract Research Elements and Generate Research Ideas")
|
193 |
-
with gr.Row():
|
194 |
-
example_1_button = gr.Button("Load Example 1: " + example_data["1"]["title"])
|
195 |
-
example_2_button = gr.Button("Load Example 2: " + example_data["2"]["title"])
|
196 |
|
197 |
with gr.Row():
|
198 |
with gr.Column():
|
@@ -212,17 +229,30 @@ with gr.Blocks() as app:
|
|
212 |
hypothesis_output = gr.Textbox(label="Generated Hypothesis", lines=20, interactive=False)
|
213 |
experiment_plan_output = gr.Textbox(label="Generated Experiment Plan", lines=20, interactive=False)
|
214 |
|
215 |
-
|
216 |
-
#
|
217 |
-
|
218 |
-
|
219 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
220 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
221 |
|
222 |
-
example_2_button.click(
|
223 |
-
|
224 |
-
|
225 |
-
)
|
226 |
|
227 |
# Step 1: Extract Research Elements
|
228 |
extract_button.click(
|
@@ -281,4 +311,4 @@ with gr.Blocks() as app:
|
|
281 |
|
282 |
if __name__ == "__main__":
|
283 |
step_index = 0
|
284 |
-
app.launch()
|
|
|
17 |
state_complete = False
|
18 |
index_ex = "1"
|
19 |
|
20 |
+
example_text = [
|
21 |
+
"Research Paper 1: Dataset and Baseline for Automatic Student Feedback Analysis",
|
22 |
+
"Research Paper 2: An Empirical Study on the Impact of Code Review on Software Quality"
|
23 |
+
]
|
24 |
|
25 |
# Load example JSON file
|
26 |
def load_example_data():
|
|
|
43 |
paper_text = 'Title:\t' + example['title'] + '\nAbstract:\t' + example['abstract']
|
44 |
return paper_text
|
45 |
|
46 |
+
example_text = [load_example(1), load_example(2)]
|
47 |
+
|
48 |
+
# Function to handle example clicks
|
49 |
+
def load_example_and_set_index(paper_text_input):
|
50 |
+
global index_ex
|
51 |
+
index_ex = str(example_text.index(paper_text_input) + 1)
|
52 |
+
paper_text = load_example(index_ex)
|
53 |
+
|
54 |
+
return paper_text, "", "", "", "", "", ""
|
55 |
+
|
56 |
+
|
57 |
+
|
58 |
########## Phase 1 ##############
|
59 |
|
60 |
def extract_research_elements(paper_text):
|
|
|
192 |
return msg
|
193 |
|
194 |
|
195 |
+
def handle_example_click(example_index):
|
196 |
+
global index_ex
|
197 |
+
index_ex = example_index
|
198 |
+
return load_example(index_ex) # Simply return the text to display it in the textbox
|
199 |
|
200 |
# Gradio Interface
|
201 |
with gr.Blocks() as app:
|
202 |
+
gr.Markdown("# MLR- Copilot: AI Research Assistant with Research Agent")
|
203 |
+
gr.Markdown("### MLR-Copilot is a framework where LLMs mimic researchers’ thought processes, designed to enhance the productivity of machine learning research by automating the generation and implementation of research ideas.It begins with a research paper, autonomously generating and validating these ideas, while incorporating human feedback to help reach executable research outcomes.")
|
204 |
|
205 |
|
206 |
# Use state variables to store generated hypothesis and experiment plan
|
|
|
210 |
########## Phase 1: Research Idea Generation Tab ##############
|
211 |
with gr.Tab("Phase 1: Research Idea Generation"):
|
212 |
gr.Markdown("### Extract Research Elements and Generate Research Ideas")
|
|
|
|
|
|
|
213 |
|
214 |
with gr.Row():
|
215 |
with gr.Column():
|
|
|
229 |
hypothesis_output = gr.Textbox(label="Generated Hypothesis", lines=20, interactive=False)
|
230 |
experiment_plan_output = gr.Textbox(label="Generated Experiment Plan", lines=20, interactive=False)
|
231 |
|
232 |
+
# with gr.Row():
|
233 |
+
# example_1_button = gr.Button("Load Example 1: " + example_data["1"]["title"])
|
234 |
+
# example_2_button = gr.Button("Load Example 2: " + example_data["2"]["title"])
|
235 |
+
# Example buttons
|
236 |
+
gr.Examples(
|
237 |
+
examples=example_text,
|
238 |
+
inputs=[paper_text_input],
|
239 |
+
outputs=[paper_text_input, tasks_output, gaps_output, keywords_output, recent_works_output, hypothesis_output, experiment_plan_output],
|
240 |
+
fn=load_example_and_set_index,
|
241 |
+
run_on_click = True,
|
242 |
+
label="Click an example to load"
|
243 |
)
|
244 |
+
|
245 |
+
|
246 |
+
# # Pre-step: load example
|
247 |
+
# example_1_button.click(
|
248 |
+
# fn=lambda: load_example(1), x
|
249 |
+
# outputs=[paper_text_input]
|
250 |
+
# )
|
251 |
|
252 |
+
# example_2_button.click(
|
253 |
+
# fn=lambda: load_example(2),
|
254 |
+
# outputs=[paper_text_input]
|
255 |
+
# )
|
256 |
|
257 |
# Step 1: Extract Research Elements
|
258 |
extract_button.click(
|
|
|
311 |
|
312 |
if __name__ == "__main__":
|
313 |
step_index = 0
|
314 |
+
app.launch(share=True)
|