Wanswan commited on
Commit
40f79af
·
verified ·
1 Parent(s): 5eb46af

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -25
app.py CHANGED
@@ -206,20 +206,24 @@ with gr.Blocks(css="""
206
  background-color: #25D366 !important;
207
  color: white !important;
208
  border: none;
209
- border-radius: 10px;
210
- font-size: 20px;
 
211
  height: 42px;
212
- width: 100%;
213
- padding: 0;
214
- margin: 0;
215
  cursor: pointer;
216
  }
 
 
 
 
217
  #chatbox .avatar-container {
218
  width: 48px !important;
219
  height: 48px !important;
220
  min-width: 48px !important;
221
  min-height: 48px !important;
222
- margin-right: 8px !important;
223
  background-size: 100% 100% !important;
224
  background-position: center center !important;
225
  border-radius: 50% !important;
@@ -229,17 +233,16 @@ with gr.Blocks(css="""
229
  background-color: transparent !important;
230
  }
231
  #chatbox .message {
232
- line-height: 1.6em !important;
233
  padding: 10px 14px !important;
234
  border-radius: 12px !important;
235
  font-size: 16px !important;
236
- max-width: 85% !important;
237
  word-wrap: break-word !important;
238
  word-break: break-word !important;
239
  white-space: normal !important;
240
  overflow-wrap: break-word !important;
241
  }
242
-
243
  #chatbox .message.user { background-color: #DCF8C6 !important; }
244
  #chatbox .message.assistant { background-color: #ffffff !important; }
245
  footer { display: none !important; }
@@ -247,8 +250,6 @@ footer { display: none !important; }
247
  .icon-button-wrapper { display: none !important; }
248
  label.svelte-1to105q { display: none !important; }
249
  """) as demo:
250
-
251
- # 自动滚动到底部的脚本
252
  gr.HTML("""
253
  <script>
254
  const waitForChatbox = () => {
@@ -266,36 +267,31 @@ label.svelte-1to105q { display: none !important; }
266
  </script>
267
  """)
268
 
269
- # 聊天框
270
  chatbot = gr.Chatbot(
271
  elem_id="chatbox",
272
  label="",
273
  avatar_images=["user_avatar.jpg", "humanlike_avatar.png"],
274
  bubble_full_width=False,
275
- height="80vh",
276
  show_copy_button=False,
277
  type="messages"
278
  )
279
 
280
- # 输入 + 发送按钮布局(两列)
281
- with gr.Row(equal_height=True):
282
- with gr.Column(scale=11):
283
- user_input = gr.Textbox(
284
- show_label=False,
285
- placeholder="Type your message here and press send...",
286
- container=True
287
- )
288
- with gr.Column(scale=1, min_width=48):
289
- send_btn = gr.Button(value="➤", elem_classes="send-btn")
290
 
291
- # 状态变量
292
  state = gr.State([])
293
  step = gr.State(0)
294
  language = gr.State("")
295
  questions = gr.State([])
296
  followup_mode = gr.State(False)
297
 
298
- # 加载和按钮触发
299
  demo.load(fn=init, outputs=[chatbot, step, language, questions, followup_mode])
300
  user_input.submit(respond, [user_input, state, step, language, questions, followup_mode],
301
  [chatbot, user_input, step, language, questions, followup_mode])
 
206
  background-color: #25D366 !important;
207
  color: white !important;
208
  border: none;
209
+ border-radius: 20px;
210
+ font-size: 18px;
211
+ padding: 6px 12px;
212
  height: 42px;
213
+ width: 52px;
214
+ margin-left: 6px;
 
215
  cursor: pointer;
216
  }
217
+ #chatbox {
218
+ max-width: 100% !important;
219
+ padding: 0 8px !important;
220
+ }
221
  #chatbox .avatar-container {
222
  width: 48px !important;
223
  height: 48px !important;
224
  min-width: 48px !important;
225
  min-height: 48px !important;
226
+ margin-right: 6px !important;
227
  background-size: 100% 100% !important;
228
  background-position: center center !important;
229
  border-radius: 50% !important;
 
233
  background-color: transparent !important;
234
  }
235
  #chatbox .message {
236
+ line-height: 1.5em !important;
237
  padding: 10px 14px !important;
238
  border-radius: 12px !important;
239
  font-size: 16px !important;
240
+ max-width: 90% !important;
241
  word-wrap: break-word !important;
242
  word-break: break-word !important;
243
  white-space: normal !important;
244
  overflow-wrap: break-word !important;
245
  }
 
246
  #chatbox .message.user { background-color: #DCF8C6 !important; }
247
  #chatbox .message.assistant { background-color: #ffffff !important; }
248
  footer { display: none !important; }
 
250
  .icon-button-wrapper { display: none !important; }
251
  label.svelte-1to105q { display: none !important; }
252
  """) as demo:
 
 
253
  gr.HTML("""
254
  <script>
255
  const waitForChatbox = () => {
 
267
  </script>
268
  """)
269
 
 
270
  chatbot = gr.Chatbot(
271
  elem_id="chatbox",
272
  label="",
273
  avatar_images=["user_avatar.jpg", "humanlike_avatar.png"],
274
  bubble_full_width=False,
275
+ height=500,
276
  show_copy_button=False,
277
  type="messages"
278
  )
279
 
280
+ with gr.Row():
281
+ user_input = gr.Textbox(
282
+ show_label=False,
283
+ placeholder="Type your message here and press send...",
284
+ container=True,
285
+ scale=10
286
+ )
287
+ send_btn = gr.Button(value="➤", elem_classes="send-btn")
 
 
288
 
 
289
  state = gr.State([])
290
  step = gr.State(0)
291
  language = gr.State("")
292
  questions = gr.State([])
293
  followup_mode = gr.State(False)
294
 
 
295
  demo.load(fn=init, outputs=[chatbot, step, language, questions, followup_mode])
296
  user_input.submit(respond, [user_input, state, step, language, questions, followup_mode],
297
  [chatbot, user_input, step, language, questions, followup_mode])