Spaces:
Runtime error
Runtime error
File size: 555 Bytes
feac790 1139a18 feac790 1139a18 feac790 8485ef2 e2701b8 8485ef2 |
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 |
"""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, # seems to cause errors
# live=True, # api if set to True
)
iface.launch()
|