ll7098ll commited on
Commit
33caf8e
·
verified ·
1 Parent(s): e5fc402

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -31,7 +31,9 @@ chat_session = model.start_chat(history=[])
31
  def respond(user_input, history):
32
  response = chat_session.send_message(user_input)
33
  history.append((user_input, response.text))
34
- return "", history
 
 
35
 
36
  with gr.Blocks() as demo:
37
  gr.Markdown("<div style='font-size: 30px; font-weight: bold;'>AI 선생님</div>")
@@ -39,7 +41,7 @@ with gr.Blocks() as demo:
39
  msg = gr.Textbox(label="입력")
40
  clear = gr.Button("초기화")
41
 
42
- msg.submit(respond, [msg, chatbot], [msg, chatbot])
43
  clear.click(lambda: [], None, chatbot, queue=False)
44
 
45
  demo.launch()
 
31
  def respond(user_input, history):
32
  response = chat_session.send_message(user_input)
33
  history.append((user_input, response.text))
34
+ # 답변 내용을 문자열로 받아서 한 글자씩 출력
35
+ for char in response.text:
36
+ yield "", history + [(user_input, response.text[:len(history[-1][1]) + 1])]
37
 
38
  with gr.Blocks() as demo:
39
  gr.Markdown("<div style='font-size: 30px; font-weight: bold;'>AI 선생님</div>")
 
41
  msg = gr.Textbox(label="입력")
42
  clear = gr.Button("초기화")
43
 
44
+ msg.submit(respond, [msg, chatbot], [msg, chatbot], queue=False)
45
  clear.click(lambda: [], None, chatbot, queue=False)
46
 
47
  demo.launch()