"""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()