import gradio as gr from Sample import * display_dict, info_dict = sample_random_entry(n=1) # Extract the question text question_text = display_dict['qa'] def markdown_to_html(markdown_text): # You would use a Markdown library to convert markdown to HTML here # Since this code runs in an environment without extra libraries, this is a placeholder html = markdown_text.replace("\n", "
") # Simple replacement, not a real markdown conversion return html completion_text = '' def evaluate_guess(reasoning, correctness, confidence): # Placeholder for comparison logic # You'll need to access the correct answer from `info_dict` or a similar structure correct_answer = "Correctly" # Placeholder for the actual logic to determine this evaluation_response = "Correct" if correctness == correct_answer else "Incorrect" actual_model = info_dict['model'] actual_completion = info_dict['completion'] # Update the completion text completion_text = f"Completion: {actual_completion}\n\nChoice: {chr(info_dict['verdict'] + 65)}" model = actual_model # Return the evaluation response and the completion text to update the interface return evaluation_response, model, completion_text print(display_dict['card']) with gr.Blocks() as app: with gr.Row(): with gr.Column(scale=2): # This column is wider # Use a Textbox to display the evaluation card content evaluation_card = gr.Textbox(value=display_dict['card'], label="Evaluation Card", interactive=False) model = gr.Textbox(value="", label="Model", placeholder='An anonymous Model', interactive=False) completion = gr.Textbox(value="", label="Model's Completion", interactive=False) with gr.Column(scale=1): # Display the sampled question in a Textbox question = gr.Textbox(value=question_text, label="Question", interactive=False) reasoning = gr.Textbox(lines=5, placeholder="Your reasoning (optional)") correctness = gr.Radio(choices=["Correct", "Incorrect"], label="I believe the model will answer this question") confidence = gr.Slider(minimum=0, maximum=10, step=1, label="Confidence") output_text = gr.Text(label="Evaluation Output") # Create an output text component submit_button = gr.Button("Submit") # This textbox will be used to display the model's completion # When the button is clicked, it will update the content of the completion textbox submit_button.click(fn=evaluate_guess, inputs=[reasoning, correctness, confidence], outputs=[output_text, model, completion]) app.launch()