import gradio as gr from app_utils import evaluate_prompt, get_split import logging logging.basicConfig(level=logging.INFO) with gr.Blocks(title=f"Prompting Challenge ({get_split()}") as demo: gr.Markdown( f""" # Prompting Challenge ### ({get_split()}) """ + """ The goal of this challenge is to prompt GPT-4 to "unscramble" a sentence. The input is a sentence with scrambled word order, e.g.: *"are How ? you"* GPT-4 should identify the original sentence, e.g.: *"How are you?"* Enter your prompt template here. Use `{% shuffled_sentence %}` at the place where you want the shuffled sentence to be inserted. """ ) input_text = gr.Textbox( lines=10, label="Prompt Template", value="Unscramble the following sentence: {% shuffled_sentence %}" ) submit_button = gr.Button("Submit") results_output = gr.HTML(label="Results") def update_results(prompt): result_tuples = list(evaluate_prompt(prompt)) if result_tuples: total_score = sum(item_score for _, _, _, item_score in result_tuples) score = total_score / len(result_tuples) else: score = 0 html_output = "