Spaces:
Sleeping
Sleeping
File size: 759 Bytes
171f2ef 9602bb7 171f2ef 9602bb7 21916d9 9602bb7 171f2ef 9602bb7 171f2ef 9602bb7 171f2ef 9602bb7 171f2ef 551e9e2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import gradio as gr
from comp import generate_response
# --- Gradio UI ---
with gr.Blocks() as demo:
gr.Markdown("# Ling Playground")
chatbot = gr.Chatbot()
msg = gr.Textbox()
clear = gr.ClearButton([msg, chatbot])
def user(user_message, history):
return "", history + [[user_message, None]]
def bot(history):
user_message = history[-1][0]
history[-1][1] = ""
for response in generate_response(user_message, history[:-1]):
history[-1][1] = response
yield history
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
bot, chatbot, chatbot
)
clear.click(lambda: None, None, chatbot, queue=False)
if __name__ == "__main__":
demo.launch() |