File size: 1,493 Bytes
00a31fe
 
d0fad25
00a31fe
 
 
55ec42e
00a31fe
 
 
 
d0fad25
00a31fe
 
 
 
d0fad25
55ec42e
 
 
 
00a31fe
d0fad25
 
 
 
 
 
 
 
 
 
 
 
 
 
00a31fe
 
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
33
34
35
36
37
38
39
import gradio as gr

from models import DST_MODELS, NLG_MODELS, PIPELINES


def predict(text: str, model_name: str) -> str:
    return PIPELINES[model_name](text)


with gr.Blocks(title="CLARIN-PL Dialogue System Modules") as demo:
    gr.Markdown("Dialogue State Tracking Modules")
    for model_name in DST_MODELS:
        with gr.Row():
            gr.Markdown(f"## {model_name}")
            model_name_component = gr.Textbox(value=model_name, visible=False)
        with gr.Row():
            text_input = gr.Textbox(label="Input Text", value=DST_MODELS[model_name]["default_input"])
            output = gr.Textbox(label="Slot Value", value="")
        with gr.Row():
            predict_button = gr.Button("Predict")
            predict_button.click(fn=predict, inputs=[text_input, model_name_component], outputs=output)


    gr.Markdown("Natural Language Generation / Paraphrasing Modules")
    for model_name in NLG_MODELS:
        with gr.Row():
            gr.Markdown(f"## {model_name}")
            model_name_component = gr.Textbox(value=model_name, visible=False)
        with gr.Row():
            text_input = gr.Textbox(label="Input Text", value=NLG_MODELS[model_name]["default_input"])
            output = gr.Textbox(label="Slot Value", value="")
        with gr.Row():
            predict_button = gr.Button("Predict")
            predict_button.click(fn=predict, inputs=[text_input, model_name_component], outputs=output)


demo.queue(concurrency_count=3)
demo.launch()