yym68686 commited on
Commit
e974b81
·
1 Parent(s): 7ee251f

Fixed the issue with search suggestions, fixed the issue of text area being obscured.

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -14,7 +14,7 @@ chatgptbot = chatgpt(api_key=f"{API}", engine=GPT_ENGINE, system_prompt=systempr
14
 
15
  with gr.Blocks(fill_height=True) as demo:
16
  with gr.Column():
17
- chatbot = gr.Chatbot(show_label=False, elem_id="chatbox", scale=2) # 设置聊天框高度
18
  with gr.Row():
19
  msg = gr.Textbox(placeholder="输入你的问题...", elem_id="inputbox", scale=10)
20
  clear = gr.Button("清除", elem_id="clearbutton")
@@ -28,9 +28,14 @@ with gr.Blocks(fill_height=True) as demo:
28
  print(history)
29
  user_message = history[-1][0]
30
  history[-1][1] = ""
 
31
  for text in chatgptbot.ask_stream(user_message):
32
  print(text, end="")
33
- history[-1][1] += text
 
 
 
 
34
  yield history
35
 
36
  # 提交用户消息和处理回答
 
14
 
15
  with gr.Blocks(fill_height=True) as demo:
16
  with gr.Column():
17
+ chatbot = gr.Chatbot(show_label=False, elem_id="chatbox", scale=10, height=900) # 设置聊天框高度
18
  with gr.Row():
19
  msg = gr.Textbox(placeholder="输入你的问题...", elem_id="inputbox", scale=10)
20
  clear = gr.Button("清除", elem_id="clearbutton")
 
28
  print(history)
29
  user_message = history[-1][0]
30
  history[-1][1] = ""
31
+ answer = ""
32
  for text in chatgptbot.ask_stream(user_message):
33
  print(text, end="")
34
+ if "🌐" in text:
35
+ history[-1][1] = text
36
+ else:
37
+ answer += text
38
+ history[-1][1] = answer
39
  yield history
40
 
41
  # 提交用户消息和处理回答