|
import gradio as gr |
|
|
|
def run_text(text, state, lang): |
|
res = "hello" |
|
state = state + [(text, res)] |
|
return state,state |
|
|
|
|
|
|
|
with gr.Blocks(css="#chatbot {overflow:auto; height:500px;}") as demo: |
|
with gr.Row(): |
|
lang = gr.Radio(choices=['ma', 'mb'], value='ma', label='zxc') |
|
openai_api_key_textbox = gr.Textbox( |
|
placeholder="Paste your OpenAI API key here to start Visual ChatGPT(sk-...) and press Enter ↵️", |
|
show_label=False, |
|
lines=1, |
|
type="password", |
|
) |
|
chatbot = gr.Chatbot(elem_id="chatbot",show_label=False) |
|
state = gr.State([]) |
|
with gr.Row() as input_raws: |
|
with gr.Column(scale=0.6): |
|
txt = gr.Textbox(show_label=False).style(container=False) |
|
with gr.Column(scale=0.20, min_width=0): |
|
run = gr.Button("🏃♂️Run") |
|
with gr.Column(scale=0.20, min_width=0): |
|
clear = gr.Button("🔄Clear️") |
|
|
|
txt.submit(run_text, [txt, state,lang], [chatbot,state]) |
|
txt.submit(lambda: "", None, txt) |
|
run.click(run_text, [txt, state], [chatbot,state]) |
|
|
|
demo.queue(concurrency_count=10).launch(server_name="0.0.0.0", server_port=7860) |