import gradio as gr import os GRADIO_PORT = os.getenv("GRADIO_PORT") or 7860 GRADIO_SHARE = os.getenv("GRADIO_SHARE") or False GRADIO_DEBUG = os.getenv("GRADIO_DEBUG") or True SDT_PLACEHOLDER = os.getenv("SDT_PLACEHOLDER") or "Ctrl-Shift to get a response..." SDT_LABEL = os.getenv("SDT_LABEL") or "Dyanmic Text ( Shift-Enter to send )" SDT_LINES = os.getenv("SDT_LINES") or "\n"*16 INITIAL_STATE = { "html": f"""

Welcome

""" } def greeting(inpt): return "You Said,

" + inpt.strip() + "

!\n\n" with gr.Blocks() as dmo: with gr.Row(): output = gr.HTML(INITIAL_STATE['html']) with gr.Row(): inpt = gr.Textbox(SDT_LINES, placeholder=SDT_PLACEHOLDER, label=SDT_LABEL, lines=len(SDT_LINES)) inpt.submit(greeting, inputs=[inpt], outputs=[inpt]) dmo.launch(share=GRADIO_SHARE, debug=GRADIO_DEBUG, inline=True, server_port=GRADIO_PORT)