lisa-on-cuda / app.py
alessandro trinca tornidor
[fix] fix missing imports, wrong path in entrypoint.sh
326115c
raw
history blame
1.05 kB
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")
@app.get("/health")
@session_logger.set_uuid_logging
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"})
@session_logger.set_uuid_logging
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)