Yuchan5386 commited on
Commit
22f49f5
ยท
verified ยท
1 Parent(s): da6a9ae

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -28
app.py CHANGED
@@ -186,33 +186,16 @@ import gradio as gr
186
 
187
  nickname = "์‚ฌ์šฉ์ž"
188
 
189
- def respond_stream(message, chat_history):
190
  message = message.replace("@์‚ฌ์šฉ์ž1@", nickname)
191
- history = chat_history or []
192
- bot_response = ""
193
  for partial in generate_text_better_sampling(model, message):
194
- bot_response = partial
195
- # ๋งˆ์ง€๋ง‰ ๋Œ€ํ™”๋งŒ ์ŠคํŠธ๋ฆฌ๋ฐ ์ค‘์ด๋ผ ์—…๋ฐ์ดํŠธ
196
- if history and len(history) > 0:
197
- history[-1] = (history[-1][0], bot_response)
198
- else:
199
- history.append((message, bot_response))
200
- yield history
201
-
202
- with gr.Blocks() as demo:
203
- chat_history = gr.State([])
204
-
205
- txt_input = gr.TextArea(placeholder="๋ฉ”์‹œ์ง€๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”...", lines=2)
206
- chat_display = gr.Markdown()
207
-
208
- def update_display(history):
209
- formatted = ""
210
- for user_msg, bot_msg in history:
211
- formatted += f"**์‚ฌ์šฉ์ž:** {user_msg}\n\n"
212
- formatted += f"**๋ด‡:** {bot_msg}\n\n"
213
- return formatted
214
-
215
- txt_input.submit(respond_stream, inputs=[txt_input, chat_history], outputs=[chat_history], queue=True)\
216
- .then(update_display, inputs=chat_history, outputs=chat_display)
217
-
218
- demo.launch()
 
186
 
187
  nickname = "์‚ฌ์šฉ์ž"
188
 
189
+ def respond(message, chat_history):
190
  message = message.replace("@์‚ฌ์šฉ์ž1@", nickname)
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()