ysharma HF staff commited on
Commit
d4ede8f
1 Parent(s): e523671

added a placeholder to the chatbot

Browse files

Gradio now supports the use of `Placeholder`. This is a small Quality of Life improvement that enhances the user experience by displaying a placeholder in the chatbot. With this new feature, you can add any information or logo to be displayed when the chat is blank or cleared.

I have attached an image of how it will look on your chatbot demo so that you can see for yourself. The best part is that you can easily modify the image or messaging to meet your needs, just like you would when using markdown.

![image.png](https://cdn-uploads.huggingface.co/production/uploads/60d2dc1007da9c17c72708f8/jzXMed1dTjp4bip31DVMG.png)

Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -74,6 +74,14 @@ custom_css = """
74
  }
75
  """
76
 
 
 
 
 
 
 
 
 
77
  with gr.Blocks(analytics_enabled=False, css=custom_css) as demo:
78
  cid = gr.State("")
79
 
@@ -93,7 +101,7 @@ with gr.Blocks(analytics_enabled=False, css=custom_css) as demo:
93
 
94
  with gr.Column():
95
  with gr.Row():
96
- chatbot = gr.Chatbot(show_label=False, show_share_button=False, show_copy_button=True)
97
 
98
  with gr.Row():
99
  user_message = gr.Textbox(lines=1, placeholder="Ask anything ...", label="Input", show_label=False)
 
74
  }
75
  """
76
 
77
+ PLACEHOLDER = """
78
+ <div style="padding: 30px; text-align: center; display: flex; flex-direction: column; align-items: center;">
79
+ <img src="https://txt.cohere.com/content/images/size/w2000/2024/04/r--Blog-Header.png" style="width: 80%; max-width: 450px; height: auto; opacity: 0.55; margin-bottom: 10px; border-radius: 10px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);">
80
+ <h1 style="font-size: 28px; margin-bottom: 2px; color: #000; opacity: 0.55;">Command R+ Chatbot</h1>
81
+ <p style="font-size: 18px; margin-bottom: 2px; color: #000; opacity: 0.65;">Ask me anything...</p>
82
+ </div>
83
+ """
84
+
85
  with gr.Blocks(analytics_enabled=False, css=custom_css) as demo:
86
  cid = gr.State("")
87
 
 
101
 
102
  with gr.Column():
103
  with gr.Row():
104
+ chatbot = gr.Chatbot(show_label=False, show_share_button=False, show_copy_button=True, placeholder=PLACEHOLDER)
105
 
106
  with gr.Row():
107
  user_message = gr.Textbox(lines=1, placeholder="Ask anything ...", label="Input", show_label=False)