chansung commited on
Commit
a9db698
1 Parent(s): 9b0bdb7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -14,6 +14,7 @@ local_rank, world_size = setup_model_parallel()
14
  generator = get_pretrained_models("7B", "tokenizer", local_rank, world_size)
15
 
16
  history = []
 
17
 
18
  def chat(user_input):
19
  bot_response = get_output(generator, user_input)[0]
@@ -26,16 +27,22 @@ def chat(user_input):
26
  "role": "system",
27
  "content": bot_response
28
  })
 
 
29
 
30
  response = ""
31
  for word in bot_response.split(" "):
 
32
  response += word + " "
33
- yield [(user_input, response)]
 
 
34
 
35
  with gr.Blocks(css = """#col_container {width: 700px; margin-left: auto; margin-right: auto;}
36
  #chatbot {height: 400px; overflow: auto;}""") as demo:
37
- gr.Markdown(f"## {TITLE}\n\n\n\n{ABSTRACT}")
38
  with gr.Column(elem_id='col_container'):
 
39
  chatbot = gr.Chatbot(elem_id='chatbot')
40
  textbox = gr.Textbox(placeholder="Enter a prompt")
41
 
 
14
  generator = get_pretrained_models("7B", "tokenizer", local_rank, world_size)
15
 
16
  history = []
17
+ simple_history = []
18
 
19
  def chat(user_input):
20
  bot_response = get_output(generator, user_input)[0]
 
27
  "role": "system",
28
  "content": bot_response
29
  })
30
+
31
+ simple_history.append((user_input, None))
32
 
33
  response = ""
34
  for word in bot_response.split(" "):
35
+ time.sleep(0.1)
36
  response += word + " "
37
+ current_pair = (user_input, response)
38
+ simple_history[-1] = current_pair
39
+ yield simple_history
40
 
41
  with gr.Blocks(css = """#col_container {width: 700px; margin-left: auto; margin-right: auto;}
42
  #chatbot {height: 400px; overflow: auto;}""") as demo:
43
+
44
  with gr.Column(elem_id='col_container'):
45
+ gr.Markdown(f"## {TITLE}\n\n\n\n{ABSTRACT}")
46
  chatbot = gr.Chatbot(elem_id='chatbot')
47
  textbox = gr.Textbox(placeholder="Enter a prompt")
48