Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -82,33 +82,39 @@ def stop_generation():
|
|
82 |
return "생성이 중단되었습니다."
|
83 |
|
84 |
with gr.Blocks() as demo:
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
with gr.Row():
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
|
105 |
# Event handlers
|
106 |
-
send.click(respond, inputs=[
|
107 |
-
|
108 |
continue_btn.click(continue_writing,
|
109 |
inputs=[chatbot, system_message, max_tokens, temperature, top_p, model],
|
110 |
outputs=[chatbot])
|
111 |
-
stop.click(stop_generation, outputs=[
|
112 |
clear.click(lambda: None, outputs=[chatbot])
|
113 |
|
114 |
if __name__ == "__main__":
|
|
|
82 |
return "생성이 중단되었습니다."
|
83 |
|
84 |
with gr.Blocks() as demo:
|
85 |
+
gr.Markdown("# 프롬프트 최적화 Playground")
|
86 |
+
|
|
|
87 |
with gr.Row():
|
88 |
+
with gr.Column(scale=1):
|
89 |
+
system_message = gr.Textbox(
|
90 |
+
value="너는 나의 최고의 비서이다.\n내가 요구하는것들을 최대한 자세하고 정확하게 답변하라.\n반드시 한글로 답변할것.",
|
91 |
+
label="시스템 메시지",
|
92 |
+
lines=5
|
93 |
+
)
|
94 |
+
prompt = gr.Textbox(label="프롬프트 입력", lines=3)
|
95 |
+
|
96 |
+
with gr.Row():
|
97 |
+
send = gr.Button("전송")
|
98 |
+
continue_btn = gr.Button("계속 작성")
|
99 |
+
stop = gr.Button("🛑 생성 중단")
|
100 |
+
clear = gr.Button("🗑️ 대화 내역 지우기")
|
101 |
+
|
102 |
+
with gr.Accordion("모델 설정", open=True):
|
103 |
+
model = gr.Radio(list(models.keys()), value=list(models.keys())[0], label="언어 모델 선택", info="사용할 언어 모델을 선택하세요")
|
104 |
+
max_tokens = gr.Slider(minimum=1, maximum=2000, value=500, step=100, label="최대 새 토큰 수")
|
105 |
+
temperature = gr.Slider(minimum=0.1, maximum=2.0, value=0.7, step=0.05, label="온도")
|
106 |
+
top_p = gr.Slider(minimum=0.1, maximum=1.0, value=0.90, step=0.05, label="Top-p (핵 샘플링)")
|
107 |
+
|
108 |
+
with gr.Column(scale=2):
|
109 |
+
chatbot = gr.Chatbot(height=700, label="대화 결과")
|
110 |
|
111 |
# Event handlers
|
112 |
+
send.click(respond, inputs=[prompt, system_message, max_tokens, temperature, top_p, model], outputs=[chatbot])
|
113 |
+
prompt.submit(respond, inputs=[prompt, system_message, max_tokens, temperature, top_p, model], outputs=[chatbot])
|
114 |
continue_btn.click(continue_writing,
|
115 |
inputs=[chatbot, system_message, max_tokens, temperature, top_p, model],
|
116 |
outputs=[chatbot])
|
117 |
+
stop.click(stop_generation, outputs=[prompt])
|
118 |
clear.click(lambda: None, outputs=[chatbot])
|
119 |
|
120 |
if __name__ == "__main__":
|