yizhangliu commited on
Commit
cd1df3c
·
1 Parent(s): 5f83b94

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -5
app.py CHANGED
@@ -26,13 +26,22 @@ def get_response_from_chatbot(text):
26
  # return history, history
27
 
28
  def chat(message, chat_history):
29
- split_mark = 'CHCHCHCHCHCH'
30
- chat_history = chat_history.split(split_mark)
 
 
 
 
 
 
31
  print(f'liuyz_1_{chat_history}')
32
  response = get_response_from_chatbot(message)
33
- chat_history.append((message, response))
 
 
 
34
  print(f'liuyz_2_{chat_history}')
35
- return chat_history, split_mark.join(chat_history)
36
 
37
  start_work = """async() => {
38
  function isMobile() {
@@ -139,7 +148,7 @@ with gr.Blocks(title='Text to Image') as demo:
139
  chatbot = gr.Chatbot(elem_id="chat_bot").style(color_map=("green", "gray"))
140
  with gr.Row():
141
  prompt_input0 = gr.Textbox(lines=2, label="prompt")
142
- chat_history = gr.Textbox(lines=2, label="prompt", visible=False)
143
  submit_btn = gr.Button(value = "submit",elem_id="erase-btn").style(
144
  margin=True,
145
  rounded=(True, True, True, True),
 
26
  # return history, history
27
 
28
  def chat(message, chat_history):
29
+ split_mark_1 = ',,,,,,,,,,;'
30
+ split_mark_2 = ';;;;;;;;;;;'
31
+ out_chat = []
32
+ if chat_history != '':
33
+ ss0 = chat_history.split(split_mark_1)
34
+ for ss1 in ss0:
35
+ ss2 = ss1.split(split_mark_2)
36
+ out_chat.append((ss2[0], ss2[1]))
37
  print(f'liuyz_1_{chat_history}')
38
  response = get_response_from_chatbot(message)
39
+ out_chat.append((message, response))
40
+ if chat_history != '':
41
+ chat_history += split_mark_1
42
+ chat_history += f'{message}{split_mark_2}{response}'
43
  print(f'liuyz_2_{chat_history}')
44
+ return out_chat, chat_history
45
 
46
  start_work = """async() => {
47
  function isMobile() {
 
148
  chatbot = gr.Chatbot(elem_id="chat_bot").style(color_map=("green", "gray"))
149
  with gr.Row():
150
  prompt_input0 = gr.Textbox(lines=2, label="prompt")
151
+ chat_history = gr.Textbox(lines=4, label="prompt", visible=True)
152
  submit_btn = gr.Button(value = "submit",elem_id="erase-btn").style(
153
  margin=True,
154
  rounded=(True, True, True, True),