import gradio as gr from inductor import BartInductor inductor = BartInductor() def bart(prompt, num, return_score): results = inductor.generate(prompt, k=num, topk=num, return_scores=return_score) if return_score: results = [(result[0], float(result[1]) * 100) for result in results] else: results = [(result, 0) for result in results] results_dict = {result[0]: float(result[1]) for result in results} return results_dict demo = gr.Interface(fn=bart, inputs=[gr.inputs.Textbox(default=' is the capital of .'), gr.Slider(0, 10, value=5, step=1), gr.Checkbox(label="Hell Yes", info="Return Scores?")], outputs=gr.Label(), title="ORION: Open Rule InductiON", examples=[[' is the capital of .', 5, True], [' is founder and CEO of .', 5, False], ["'s mother was a -based actress, .", 5, False]], description="Enter a text prompt to generate text. Make sure using to replace entities.") if __name__ == "__main__": demo.launch()