elinstallation commited on
Commit
b544281
·
verified ·
1 Parent(s): af325df

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -6
app.py CHANGED
@@ -141,26 +141,63 @@ custom_css = """
141
  #chatbox .message.user {background-color: #EDE7F6; color: #4A148C; border-radius: 20px; padding: 10px; margin: 5px; max-width: 75%;}
142
  #chatbox .message.bot {background-color: #F3E5F5; color: #4A148C; border-radius: 20px; padding: 10px; margin: 5px; max-width: 75%;}
143
  #header {background-color: #8E24AA; color: white; padding: 12px; border-radius: 12px 12px 0 0; font-weight: bold;}
144
- .choice-btn {background-color: #BA68C8; color: white; border-radius: 20px; padding: 5px 12px; margin: 5px; cursor: pointer;}
145
- .choice-btn:hover {background-color: #9C27B0;}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  """
147
 
 
 
 
 
 
148
  with gr.Blocks(css=custom_css) as demo:
149
  gr.HTML("<div id='header'>DivaBot</div>")
150
 
151
  chatbot = gr.Chatbot(elem_id="chatbox", height=400)
152
 
153
  with gr.Row():
154
- msg = gr.Textbox(placeholder="Type your message here...")
155
- send = gr.Button("Send")
 
 
 
 
 
 
 
 
 
156
 
157
- # Hook up to your existing respond() function
158
  msg.submit(respond, [msg, chatbot], [chatbot, msg])
159
- send.click(respond, [msg, chatbot], [chatbot, msg])
160
 
161
  demo.launch()
162
 
163
 
 
164
  #launching chatbot
165
  #chatbot.launch()
166
  #You may run into errors when you're trying different models. To see the error messages, set debug to True in launch()
 
141
  #chatbox .message.user {background-color: #EDE7F6; color: #4A148C; border-radius: 20px; padding: 10px; margin: 5px; max-width: 75%;}
142
  #chatbox .message.bot {background-color: #F3E5F5; color: #4A148C; border-radius: 20px; padding: 10px; margin: 5px; max-width: 75%;}
143
  #header {background-color: #8E24AA; color: white; padding: 12px; border-radius: 12px 12px 0 0; font-weight: bold;}
144
+
145
+ /* Input bar styling */
146
+ .input-container {
147
+ display: flex;
148
+ align-items: center;
149
+ background-color: white;
150
+ border: 1px solid #ccc;
151
+ border-radius: 25px;
152
+ padding: 5px 10px;
153
+ width: 100%;
154
+ }
155
+ .input-container input {
156
+ border: none;
157
+ outline: none;
158
+ flex: 1;
159
+ font-size: 14px;
160
+ }
161
+ .input-container button {
162
+ background-color: #8E24AA;
163
+ color: white;
164
+ border: none;
165
+ border-radius: 50%;
166
+ width: 35px;
167
+ height: 35px;
168
+ cursor: pointer;
169
+ }
170
  """
171
 
172
+ def respond(message, history):
173
+ history.append(("You", message))
174
+ history.append(("Bot", "Got it!"))
175
+ return history, ""
176
+
177
  with gr.Blocks(css=custom_css) as demo:
178
  gr.HTML("<div id='header'>DivaBot</div>")
179
 
180
  chatbot = gr.Chatbot(elem_id="chatbox", height=400)
181
 
182
  with gr.Row():
183
+ with gr.Column():
184
+ # HTML custom input bar
185
+ gr.HTML("""
186
+ <div class="input-container">
187
+ <input id="user-input" placeholder="Type your message..." />
188
+ <button id="send-btn">➤</button>
189
+ </div>
190
+ """)
191
+
192
+ # Normal Gradio textbox (hidden) to still connect logic
193
+ msg = gr.Textbox(visible=False)
194
 
 
195
  msg.submit(respond, [msg, chatbot], [chatbot, msg])
 
196
 
197
  demo.launch()
198
 
199
 
200
+
201
  #launching chatbot
202
  #chatbot.launch()
203
  #You may run into errors when you're trying different models. To see the error messages, set debug to True in launch()