Spaces:
Sleeping
Sleeping
File size: 1,557 Bytes
cafb253 431e389 cafb253 2a44cb7 cafb253 4fdd436 94cbf22 4fdd436 83c0738 94cbf22 83c0738 94cbf22 83c0738 431e389 b262d53 94cbf22 83c0738 431e389 9284166 ab6a641 83c0738 431e389 |
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
import gradio as gr
import random
import time
import itertools
def textbox_dynamic_ui(example: str):
placeholders = itertools.cycle([
"Ask something like, What is 2+2?",
"Ask something like, What is the meaning of Life?",
"Ask something like, What is Gradio?"
])
while True:
yield gr.Textbox(placeholder=next(placeholders))
time.sleep(2)
# Starting with the CSS that worked for color, and adding gradient
custom_css = """
.gradio-container input::placeholder,
.gradio-container textarea::placeholder {
color: #45B6FE;
background: linear-gradient(to right, #45B6FE 0%, #38EF7D 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
"""
with gr.Blocks(theme="ocean", css=custom_css) as demo:
chatbot = gr.Chatbot(type="messages")
with gr.Row(equal_height=True):
msg = gr.Textbox(scale=9)
btn = gr.Button(variant='primary', scale=1, min_width=100)
def respond(message, chat_history):
bot_message = random.choice(["How are you?", "Today is a great day", "I'm very hungry"])
chat_history.append({"role": "user", "content": message})
chat_history.append({"role": "assistant", "content": bot_message})
time.sleep(2)
return "", chat_history
msg.submit(respond, [msg, chatbot], [msg, chatbot])
msg.blur(textbox_dynamic_ui, inputs=[msg], outputs=[msg], show_progress='hidden', ) #js=True, preprocess=False, postprocess=False)
btn.click(respond, [msg, chatbot], [msg, chatbot])
demo.launch() |