Yuchan5386 commited on
Commit
eaff888
·
verified ·
1 Parent(s): 40ae10a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -23
app.py CHANGED
@@ -191,28 +191,11 @@ def respond(message, chat_history):
191
  response = ""
192
  for partial in generate_text_better_sampling(model, message):
193
  response = partial
194
- chat_history = chat_history + [(message, response)]
195
- yield chat_history, ""
196
 
197
- with gr.Blocks() as demo:
198
- chat_history = gr.State([])
 
 
199
 
200
- with gr.Column():
201
- chat_display = gr.Markdown(value="", elem_id="chat_display", label="대화창")
202
- msg = gr.Textbox(placeholder="말 걸어봐!", label="입력")
203
- clear = gr.Button("초기화")
204
-
205
- def update_chat_display(history):
206
- formatted = ""
207
- for user_msg, bot_msg in history:
208
- formatted += f"**사용자:** {user_msg}\n\n"
209
- formatted += f"**InteractGPT:** {bot_msg}\n\n---\n\n"
210
- return formatted
211
-
212
- msg.submit(respond, inputs=[msg, chat_history], outputs=[chat_history, msg]).then(
213
- update_chat_display, inputs=chat_history, outputs=chat_display
214
- )
215
-
216
- clear.click(lambda: ([], ""), None, [chat_history, chat_display])
217
-
218
- demo.launch()
 
191
  response = ""
192
  for partial in generate_text_better_sampling(model, message):
193
  response = partial
194
+ yield response
 
195
 
196
+ chat = gr.ChatInterface(
197
+ fn=respond,
198
+ title="InteractGPT",
199
+ )
200
 
201
+ chat.launch()