Yuchan5386 commited on
Commit
75a0ea0
ยท
verified ยท
1 Parent(s): 3c64a9f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -30
app.py CHANGED
@@ -200,35 +200,22 @@ def generate_text_topkp_stream(model, prompt, max_len=100, max_gen=98, p=0.9, k=
200
 
201
  yield decoded_text
202
 
203
- def chat(user_input, history):
204
- if history is None:
205
- history = []
206
-
207
- for partial_response in generate_text_topkp_stream(model, user_input, p=0.9):
208
- yield history + [(user_input, partial_response)], history + [(user_input, partial_response)]
209
-
210
- with gr.Blocks() as demo: # title ์ œ๊ฑฐ๋จ
211
- gr.Markdown(
212
- """
213
- # ๐Ÿ’ก KeraLux์™€ ๋Œ€ํ™”ํ•ด๋ณด์„ธ์š”!
214
- ๋Œ€ํ™”๋ฅผ ์ž…๋ ฅํ•˜๋ฉด KeraLux๊ฐ€ ๋˜‘๋˜‘ํ•˜๊ฒŒ ๋Œ€๋‹ตํ•ด์ค„ ๊ฑฐ์˜ˆ์š”.
215
- """,
216
- elem_id="title",
217
- )
218
- gr.Markdown("---")
219
-
220
- with gr.Row():
221
- with gr.Column(scale=1):
222
- chatbot = gr.Chatbot(label="KeraLux", type="messages") # ์ด๊ฑฐ ๊ผญ ๋ช…์‹œ
223
- with gr.Column(scale=0):
224
- msg = gr.Textbox(
225
- label="๋‹น์‹ ์˜ ์งˆ๋ฌธ์„ ์ž…๋ ฅํ•˜์„ธ์š”!",
226
- placeholder="ex) ๋‚˜ ์ข€ ๋„์™€์ค„ ์ˆ˜ ์žˆ๋‹ˆ?",
227
- lines=1,
228
- )
229
- state = gr.State([])
230
-
231
- msg.submit(chat, inputs=[msg, state], outputs=[chatbot, state])
232
- msg.submit(lambda: "", None, msg) # ์ž…๋ ฅ์ฐฝ ์ดˆ๊ธฐํ™”
233
 
234
  demo.launch(share=True)
 
200
 
201
  yield decoded_text
202
 
203
+
204
+ history = ""
205
+
206
+ def chat(user_input):
207
+ global history
208
+ response = generate_text(user_input) # ๋„ค ๋ชจ๋ธ ์ƒ์„ฑ ํ•จ์ˆ˜
209
+ history += f"์‚ฌ์šฉ์ž: {user_input}\nKeraLux: {response}\n\n"
210
+ return history
211
+
212
+ with gr.Blocks() as demo:
213
+ gr.Markdown("### ๐Ÿ“Ÿ KeraLux Textbot\n๊ฐ„๋‹จํ•˜๊ณ  ๋น ๋ฅธ ๋Œ€ํ™”์šฉ ๋ด‡์ด์—์š”.\n")
214
+
215
+ textbox = gr.Textbox(placeholder="๋ฉ”์‹œ์ง€๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”", lines=1)
216
+ output_area = gr.Textbox(label="๋Œ€ํ™” ๊ธฐ๋ก", lines=20, interactive=False)
217
+
218
+ textbox.submit(chat, inputs=textbox, outputs=output_area)
219
+ textbox.submit(lambda: "", None, textbox) # ์ž…๋ ฅ์ฐฝ ์ดˆ๊ธฐํ™”
 
 
 
 
 
 
 
 
 
 
 
 
 
220
 
221
  demo.launch(share=True)