import json import gradio as gr with open('problems.json') as f: problems = json.load(f) problem_choices = [q['question_title'] for q in problems] with open('all_outputs.json') as f: all_outputs = json.load(f) model_choices = list(all_outputs.keys()) def update_view(problem_index, model_name): code = all_outputs[model_name][problem_index]['code_list'][0] code_viewer = gr.Code( label=f"Code for Model {model_name} on {problems[problem_index]['question_title']}", language="python", lines=10, value=code, interactive=False, ) return code_viewer with gr.Blocks() as demo: ## dropdown problem_dropdown = gr.Dropdown( label="Selected Problem", choices=problem_choices, value=problem_choices[0], type="index" ) model_dropdown = gr.Dropdown( label="Selected Model", choices=model_choices, value=model_choices[0], type="value" ) code_viewer = (update_view(0, model_choices[0])) problem_dropdown.change( update_view, inputs=[problem_dropdown, model_dropdown], outputs=[code_viewer] ) ## code viewer if __name__ == "__main__": demo.launch()