File size: 425 Bytes
feac790
 
1139a18
feac790
1139a18
 
feac790
 
 
 
 
 
 
 
 
 
 
 
 
 
 
202c5e7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""Run api."""
from typing import Dict
import gradio as gr
from gradio_ttw_api.hit import hit


def ttw_api(query: str) -> Dict:
    "Prep api."""
    try:
        hit_ = hit(query)
    except Exception as exc:
        hit_ = str(exc)

    return {
        "xyz": f"Hello {query} !!",
        "abc": "dummy",
        "hit": hit_,
   }


iface = gr.Interface(fn=ttw_api, inputs="text", outputs="json")
iface.launch(live=True)