Yuchan5386 commited on
Commit
f9d7b03
ยท
verified ยท
1 Parent(s): be7ab48

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -29
app.py CHANGED
@@ -181,37 +181,18 @@ def generate_text_better_sampling(model, prompt, max_len=100, max_gen=98, top_k=
181
 
182
  yield decoded_text
183
 
 
184
 
185
- import gradio as gr
186
-
187
- nickname = "์‚ฌ์šฉ์ž1"
188
-
189
- def respond(message, history):
190
  message = message.replace("@์‚ฌ์šฉ์ž1@", nickname)
191
- history = history or []
192
- bot_response = ""
193
-
194
  for partial in generate_text_better_sampling(model, message):
195
- bot_response = partial
196
- updated_history = history + [(nickname, message), ("๋ด‡", bot_response)]
197
- yield updated_history
198
-
199
- with gr.Blocks() as demo:
200
- state = gr.State([])
201
- chat_display = gr.Markdown()
202
- user_input = gr.Textbox(placeholder="๋ฉ”์‹œ์ง€๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”...", show_label=False)
203
-
204
- def format_history(history):
205
- return "\n\n".join([f"**{who}**: {what}" for who, what in history])
206
-
207
- def update(history):
208
- return format_history(history), history
209
-
210
- def stream_response(message, history):
211
- for updated_history in respond(message, history):
212
- yield format_history(updated_history), updated_history
213
 
214
- user_input.submit(stream_response, inputs=[user_input, state], outputs=[chat_display, state])
215
- user_input.submit(lambda: "", None, user_input) # ์ž…๋ ฅ์ฐฝ ์ดˆ๊ธฐํ™”
 
 
216
 
217
- demo.launch()
 
181
 
182
  yield decoded_text
183
 
184
+ nickname = "์‚ฌ์šฉ์ž"
185
 
186
+ def respond(message, chat_history):
 
 
 
 
187
  message = message.replace("@์‚ฌ์šฉ์ž1@", nickname)
188
+ response = ""
 
 
189
  for partial in generate_text_better_sampling(model, message):
190
+ response = partial
191
+ yield response
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
 
193
+ chat = gr.ChatInterface(
194
+ fn=respond,
195
+ title="InteractGPT",
196
+ )
197
 
198
+ chat.launch()