Spaces:
Sleeping
Sleeping
sujeongim commited on
Commit ยท
6d7b8f9
1
Parent(s): a91cc9f
edit : gr
Browse files
app.py
CHANGED
|
@@ -289,17 +289,56 @@ chatbot = gr.ChatInterface(
|
|
| 289 |
],
|
| 290 |
)
|
| 291 |
|
|
|
|
|
|
|
| 292 |
with gr.Blocks() as demo:
|
| 293 |
with gr.Sidebar():
|
| 294 |
-
#
|
| 295 |
-
gr.LoginButton()
|
|
|
|
| 296 |
gr.Markdown(
|
| 297 |
"### ์งํ ์์\n"
|
| 298 |
"1) ๊ณ ์ 10๋ฌธํญ์ ๋จผ์ ๋ตํ๊ธฐ\n"
|
| 299 |
"2) LLM์ด ์์ฑํ 20๋ฌธํญ ๊ผฌ๋ฆฌ์ง๋ฌธ์ ๋ตํ๊ธฐ\n"
|
| 300 |
"3) ๊ณ ์ 10๋ฌธํญ์ ๋ค์ ํ ๋ฒ ๋ตํ๊ธฐ"
|
| 301 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 302 |
chatbot.render()
|
| 303 |
|
| 304 |
if __name__ == "__main__":
|
| 305 |
demo.launch()
|
|
|
|
|
|
| 289 |
],
|
| 290 |
)
|
| 291 |
|
| 292 |
+
# --- (์๋ต: ์์ ๋ชจ๋ import/ํจ์ ์ ์/์๋ต ๋ก์ง ๋์ผ) ---
|
| 293 |
+
|
| 294 |
with gr.Blocks() as demo:
|
| 295 |
with gr.Sidebar():
|
| 296 |
+
# โ
์ด ๋ฒํผ์ด hf_token์ ๊ณต๊ธํ๋๋ก ์ปดํฌ๋ํธ๋ฅผ ๋จผ์ ๋ง๋ค์ด ๋ก๋๋ค.
|
| 297 |
+
oauth = gr.LoginButton() # gr.OAuthButton(...)์ ์ฐ๋ ๊ฒฝ์ฐ๋ ๋์ผ ํฌ์ง์
|
| 298 |
+
|
| 299 |
gr.Markdown(
|
| 300 |
"### ์งํ ์์\n"
|
| 301 |
"1) ๊ณ ์ 10๋ฌธํญ์ ๋จผ์ ๋ตํ๊ธฐ\n"
|
| 302 |
"2) LLM์ด ์์ฑํ 20๋ฌธํญ ๊ผฌ๋ฆฌ์ง๋ฌธ์ ๋ตํ๊ธฐ\n"
|
| 303 |
"3) ๊ณ ์ 10๋ฌธํญ์ ๋ค์ ํ ๋ฒ ๋ตํ๊ธฐ"
|
| 304 |
)
|
| 305 |
+
|
| 306 |
+
# โ
์ํ ์ปดํฌ๋ํธ๋ฅผ 'ํ๋๋ง' ์์ฑํด ์
๋ ฅ/์ถ๋ ฅ์ ์ฌ์ฌ์ฉ
|
| 307 |
+
phase = gr.State(1)
|
| 308 |
+
asked = gr.State(False)
|
| 309 |
+
i1 = gr.State(0)
|
| 310 |
+
i2 = gr.State(0)
|
| 311 |
+
i3 = gr.State(0)
|
| 312 |
+
gen_questions= gr.State([])
|
| 313 |
+
fixed_answers= gr.State([])
|
| 314 |
+
gen_answers = gr.State([])
|
| 315 |
+
rep_answers = gr.State([])
|
| 316 |
+
|
| 317 |
+
# system/max_tokens/temperature/top_p ์
๋ ฅ ์ปดํฌ๋ํธ๋ ๋ธ๋ก ์์์ ๋ง๋ค๊ณ ๋๊น๋๋ค
|
| 318 |
+
sys_msg = gr.Textbox(value="You are a friendly Chatbot.", label="System message")
|
| 319 |
+
max_toks = gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens")
|
| 320 |
+
temp = gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature")
|
| 321 |
+
top_p = gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)")
|
| 322 |
+
|
| 323 |
+
chatbot = gr.ChatInterface(
|
| 324 |
+
respond,
|
| 325 |
+
type="messages",
|
| 326 |
+
# โ
ํ๋ผ๋ฏธํฐ ์์: system_message, max_tokens, temperature, top_p, hf_token, (statesโฆ)
|
| 327 |
+
additional_inputs=[
|
| 328 |
+
sys_msg, max_toks, temp, top_p,
|
| 329 |
+
oauth, # <-- โ
hf_token ์๋ฆฌ์ ๋๊ธฐ!
|
| 330 |
+
phase, asked, i1, i2, i3,
|
| 331 |
+
gen_questions, fixed_answers, gen_answers, rep_answers,
|
| 332 |
+
],
|
| 333 |
+
# โ
์ถ๋ ฅ์๋ ๋์ผํ State ์ธ์คํด์ค ์ฌ์ฌ์ฉ
|
| 334 |
+
additional_outputs=[
|
| 335 |
+
phase, asked, i1, i2, i3,
|
| 336 |
+
gen_questions, fixed_answers, gen_answers, rep_answers,
|
| 337 |
+
],
|
| 338 |
+
)
|
| 339 |
+
|
| 340 |
chatbot.render()
|
| 341 |
|
| 342 |
if __name__ == "__main__":
|
| 343 |
demo.launch()
|
| 344 |
+
|