Spaces:
Paused
Paused
import gradio as gr | |
import json | |
import logging | |
from fastapi import FastAPI | |
from utils import session_logger | |
session_logger.change_logging(logging.DEBUG) | |
CUSTOM_GRADIO_PATH = "/" | |
app = FastAPI(title="lisa_app", version="1.0") | |
def health() -> str: | |
try: | |
logging.info("health check") | |
return json.dumps({"msg": "ok"}) | |
except Exception as e: | |
logging.error(f"exception:{e}.") | |
return json.dumps({"msg": "request failed"}) | |
def request_formatter(text: str) -> str: | |
logging.info("start request formatting...") | |
formatted_text = f"transformed {text}." | |
logging.info(f"formatted request as {formatted_text}.") | |
return formatted_text | |
io = gr.Interface( | |
request_formatter, | |
inputs=[ | |
gr.Textbox(lines=1, placeholder=None, label="Text input"), | |
], | |
outputs=[ | |
gr.Textbox(lines=1, placeholder=None, label="Text Output"), | |
], | |
) | |
app = gr.mount_gradio_app(app, io, path=CUSTOM_GRADIO_PATH) | |