Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -88,9 +88,9 @@ with gr.Blocks() as demo:
|
|
88 |
with gr.Column(scale=1):
|
89 |
with gr.Accordion("모델 설정", open=True):
|
90 |
model = gr.Radio(list(models.keys()), value=list(models.keys())[0], label="언어 모델 선택", info="사용할 언어 모델을 선택하세요")
|
91 |
-
max_tokens = gr.Slider(minimum=
|
92 |
-
temperature = gr.Slider(minimum=0
|
93 |
-
top_p = gr.Slider(minimum=0
|
94 |
|
95 |
system_message = gr.Textbox(
|
96 |
value="너는 나의 최고의 비서이다.\n내가 요구하는것들을 최대한 자세하고 정확하게 답변하라.\n반드시 한글로 답변할것.",
|
@@ -100,7 +100,11 @@ with gr.Blocks() as demo:
|
|
100 |
|
101 |
with gr.Column(scale=2):
|
102 |
chatbot = gr.Chatbot(height=400, label="대화 결과")
|
103 |
-
prompt = gr.Textbox(
|
|
|
|
|
|
|
|
|
104 |
|
105 |
with gr.Row():
|
106 |
send = gr.Button("전송")
|
@@ -108,6 +112,23 @@ with gr.Blocks() as demo:
|
|
108 |
stop = gr.Button("🛑 생성 중단")
|
109 |
clear = gr.Button("🗑️ 대화 내역 지우기")
|
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])
|
|
|
88 |
with gr.Column(scale=1):
|
89 |
with gr.Accordion("모델 설정", open=True):
|
90 |
model = gr.Radio(list(models.keys()), value=list(models.keys())[0], label="언어 모델 선택", info="사용할 언어 모델을 선택하세요")
|
91 |
+
max_tokens = gr.Slider(minimum=0, maximum=2000, value=500, step=100, label="최대토큰")
|
92 |
+
temperature = gr.Slider(minimum=0, maximum=1.0, value=0.7, step=0.05, label="온도")
|
93 |
+
top_p = gr.Slider(minimum=0, maximum=1.0, value=0.90, step=0.05, label="Top-p")
|
94 |
|
95 |
system_message = gr.Textbox(
|
96 |
value="너는 나의 최고의 비서이다.\n내가 요구하는것들을 최대한 자세하고 정확하게 답변하라.\n반드시 한글로 답변할것.",
|
|
|
100 |
|
101 |
with gr.Column(scale=2):
|
102 |
chatbot = gr.Chatbot(height=400, label="대화 결과")
|
103 |
+
prompt = gr.Textbox(
|
104 |
+
label="내용 입력",
|
105 |
+
lines=3,
|
106 |
+
placeholder="Shift+Enter로 제출, Enter로 줄바꿈"
|
107 |
+
)
|
108 |
|
109 |
with gr.Row():
|
110 |
send = gr.Button("전송")
|
|
|
112 |
stop = gr.Button("🛑 생성 중단")
|
113 |
clear = gr.Button("🗑️ 대화 내역 지우기")
|
114 |
|
115 |
+
# JavaScript to handle key events
|
116 |
+
prompt.javascript = """
|
117 |
+
function(textbox) {
|
118 |
+
textbox.addEventListener("keydown", function(e) {
|
119 |
+
if (e.key === "Enter" && !e.shiftKey) {
|
120 |
+
e.preventDefault(); // Prevent default Enter behavior
|
121 |
+
return;
|
122 |
+
}
|
123 |
+
if (e.key === "Enter" && e.shiftKey) {
|
124 |
+
e.preventDefault(); // Prevent new line
|
125 |
+
document.querySelector("button.primary").click(); // Click the send button
|
126 |
+
}
|
127 |
+
});
|
128 |
+
return textbox;
|
129 |
+
}
|
130 |
+
"""
|
131 |
+
|
132 |
# Event handlers
|
133 |
send.click(respond, inputs=[prompt, system_message, max_tokens, temperature, top_p, model], outputs=[chatbot])
|
134 |
prompt.submit(respond, inputs=[prompt, system_message, max_tokens, temperature, top_p, model], outputs=[chatbot])
|