Update app.py
Browse files68 unmodified lines6970717273747534 unmodified lines11011111211311468 unmodified lines)def run_and_submit_one():# 1. Instantiate Agent ( modify this part to create your agent)try:#agent = BasicAgent()34 unmodified linesprint("Agent did not produce any answers to submit.")return "Agent did not produce any answers to submit.", pd.DataFrame(results_log)run_and_submit_one()68 unmodified lines6970717273747534 unmodified lines11011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514668 unmodified lines)#def run_and_submit_one():# 1. Instantiate Agent ( modify this part to create your agent)try:#agent = BasicAgent()34 unmodified linesprint("Agent did not produce any answers to submit.")return "Agent did not produce any answers to submit.", pd.DataFrame(results_log)#run_and_submit_one()# Gradio handler that runs the agentdef run_once(state):if state is not None:return "Already run once. Refresh to rerun.", statestatus_message, questions_data = load_questions_from_file()if questions_data is None or len(questions_data) == 0:return "No questions found or failed to load.", Nonequestion = questions_data[0]question_text = question["question"]task_id = question["task_id"]try:answer = agent_codeagent(question_text)output = f"Answer to task {task_id}:\n{answer}"return output, outputexcept Exception as e:return f"Error running agent: {e}", None# Create Gradio interfacewith gr.Blocks() as demo:gr.Markdown("## Run AI Agent Once")output_text = gr.Textbox(label="Agent Output", lines=10)run_button = gr.Button("Run Agent")state = gr.State() # cache variable to prevent re-runsrun_button.click(fn=run_once, inputs=state, outputs=[output_text, state])# Launch the interfacedemo.launch()
app.py+34-2