File size: 1,298 Bytes
281af70
 
 
 
 
 
f9db121
281af70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f9db121
281af70
 
 
 
 
 
 
f9db121
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import gradio as gr

demo = gr.Blocks()

name_list = ['huggingface/microsoft/biogpt', 'huggingface/stanford-crfm/BioMedLM']

examples = [['COVID-19 is'],['A 65-year-old female patient with a past medical history of']] 

def generate_biomedical(text):
    interfaces = [gr.Interface.load(name) for name in name_list]
    return [interface(text) for interface in interfaces]

def set_example(example: list) -> dict:
    return gr.Textbox.update(value=example[0]) 
    
with gr.Blocks() as demo:
    gr.Markdown("# Compare generative biomedical LLMs")
    with gr.Box():
        with gr.Row():
            with gr.Column():
                input_text = gr.Textbox(label = "Write your text here", lines=4)
                with gr.Row():
                    btn = gr.Button("Generate")
                
                example_text = gr.Dataset(components=[input_text], samples=examples)
                example_text.click(fn=set_example,
                                inputs = example_text,
                                outputs= example_text.components)    
            with gr.Column():   
                gr.Markdown("Let’s compare!")      
                btn.click(generate_biomedical, inputs = input_text, outputs = [gr.Textbox(label=name_list[_], lines=4) for _ in range(len(name_list))])