File size: 576 Bytes
5c0667a
d5f1b3e
5c0667a
 
d5f1b3e
29608dd
 
 
 
5c0667a
 
d5f1b3e
29608dd
 
d5f1b3e
 
 
38b2348
 
 
d5f1b3e
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import gradio as gr
from handler import handler


def predict(action, query):
    try:
        return handler(action, query)
    except Exception as e:
        return {"error": e}


with gr.Blocks() as app:
    action_type = gr.Dropdown(label="Type", value="Search", choices=[
                              "Search", "AutoSuggest"])
    query = gr.Textbox(label="Query")
    output = gr.Textbox(label="Output Box")
    greet_btn = gr.Button("Action!")
    greet_btn.click(
        fn=predict,
        inputs=[action_type, query], outputs=output, api_name="api")

app.launch()