gradio-ttw-api / app.py
freemt
Update interface live=True results in no api
8485ef2
raw
history blame
528 Bytes
"""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",
examples=["test", "测试"],
cache_examples=True,
# live=True, # api if set to True
)
iface.launch()