test / app.py
amanda
Create app.py
1e25ffc verified
Raw History Blame Contribute Delete
1.36 kB
import gradio as gr
CSS = """
.gradio-container { background: #ffe9f3 !important; }
h2 { color: #37324a !important; }
"""
with gr.Blocks(title="smoke test", css=CSS) as demo:
gr.Markdown(
"## smoke test\n"
"If you can read this and the background is **pink**, the UI loaded.\n"
"Type something and hit send. If you get an echo, it works."
)
chat = gr.Chatbot(type="messages", height=300, show_label=False, elem_id="smoke-chat")
tray = gr.MultimodalTextbox(
file_types=["image"],
placeholder="say hi",
show_label=False,
submit_btn="send",
)
def respond(value, history):
history = list(history or [])
text = ""
files = []
if isinstance(value, dict):
text = (value.get("text") or "").strip()
files = value.get("files") or []
else:
text = str(value or "").strip()
if not text and not files:
return history, None
shown = text if text else "(no text)"
if files:
shown += f" [+{len(files)} file(s)]"
history.append({"role": "user", "content": shown})
history.append({"role": "assistant", "content": f"echo: {shown}"})
return history, None
tray.submit(respond, [tray, chat], [chat, tray])
demo.queue().launch(ssr_mode=False)