Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import random | |
| def respond(message, chat_history): | |
| #No LLM here, just respond with a random pre-made message | |
| bot_message = random.choice(["Tell me more about it", | |
| "Cool, but I'm not interested", | |
| "Hmmmm, ok then"]) | |
| chat_history.append((message, bot_message)) | |
| return "", chat_history | |
| with gr.Blocks() as demo: | |
| chatbot = gr.Chatbot(height=240) #just to fit the notebook | |
| msg = gr.Textbox(label="Prompt") | |
| btn = gr.Button("Submit") | |
| clear = gr.ClearButton(components=[msg, chatbot], value="Clear console") | |
| btn.click(respond, inputs=[msg, chatbot], outputs=[msg, chatbot]) | |
| msg.submit(respond, inputs=[msg, chatbot], outputs=[msg, chatbot]) #Press enter to submit | |
| gr.close_all() | |
| demo.launch() |