ysharma HF Staff commited on
Commit
83c0738
·
verified ·
1 Parent(s): b262d53

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -7
app.py CHANGED
@@ -4,23 +4,30 @@ import time
4
  import itertools
5
 
6
  def textbox_dynamic_ui(example: str):
7
- # Creating an infinite cycle of placeholder messages
8
  placeholders = itertools.cycle([
9
  "Ask something like, What is 2+2?",
10
  "Ask something like, What is the meaning of Life?",
11
  "Ask something like, What is Gradio?"
12
  ])
13
-
14
  while True:
15
  yield gr.Textbox(placeholder=next(placeholders))
16
  time.sleep(2)
17
-
18
- with gr.Blocks(theme="ocean") as demo:
 
 
 
 
 
 
 
 
 
 
19
  chatbot = gr.Chatbot(type="messages")
20
  with gr.Row(equal_height=True):
21
  msg = gr.Textbox(scale=9)
22
- btn=gr.Button(variant='primary', scale=1, min_width=100)
23
- #clear = gr.ClearButton([msg, chatbot])
24
 
25
  def respond(message, chat_history):
26
  bot_message = random.choice(["How are you?", "Today is a great day", "I'm very hungry"])
@@ -32,5 +39,5 @@ with gr.Blocks(theme="ocean") as demo:
32
  msg.submit(respond, [msg, chatbot], [msg, chatbot])
33
  msg.blur(textbox_dynamic_ui, inputs=[msg], outputs=[msg], show_progress='hidden', js=True, preprocess=False, postprocess=False)
34
  btn.click(respond, [msg, chatbot], [msg, chatbot])
35
-
36
  demo.launch()
 
4
  import itertools
5
 
6
  def textbox_dynamic_ui(example: str):
 
7
  placeholders = itertools.cycle([
8
  "Ask something like, What is 2+2?",
9
  "Ask something like, What is the meaning of Life?",
10
  "Ask something like, What is Gradio?"
11
  ])
 
12
  while True:
13
  yield gr.Textbox(placeholder=next(placeholders))
14
  time.sleep(2)
15
+
16
+ # Custom CSS to style the placeholder text with gradient color
17
+ custom_css = """
18
+ .gradio-container input[type='text']::placeholder {
19
+ background: linear-gradient(90deg, #45B6FE, #38EF7D);
20
+ -webkit-background-clip: text;
21
+ -webkit-text-fill-color: transparent;
22
+ opacity: 1 !important;
23
+ }
24
+ """
25
+
26
+ with gr.Blocks(theme="ocean", css=custom_css) as demo:
27
  chatbot = gr.Chatbot(type="messages")
28
  with gr.Row(equal_height=True):
29
  msg = gr.Textbox(scale=9)
30
+ btn = gr.Button(variant='primary', scale=1, min_width=100)
 
31
 
32
  def respond(message, chat_history):
33
  bot_message = random.choice(["How are you?", "Today is a great day", "I'm very hungry"])
 
39
  msg.submit(respond, [msg, chatbot], [msg, chatbot])
40
  msg.blur(textbox_dynamic_ui, inputs=[msg], outputs=[msg], show_progress='hidden', js=True, preprocess=False, postprocess=False)
41
  btn.click(respond, [msg, chatbot], [msg, chatbot])
42
+
43
  demo.launch()