ginipick commited on
Commit
c3dadf6
Β·
verified Β·
1 Parent(s): 282bf91

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +76 -26
app.py CHANGED
@@ -188,11 +188,7 @@ PLACEHOLDER = """
188
  </div>
189
  """
190
 
191
- demo = gr.ChatInterface(
192
- fn=respond,
193
- title="Ginigen Private AI",
194
- description="6BIT μ–‘μžν™”λ‘œ λͺ¨λΈ ν¬κΈ°λŠ” 쀄이고 μ„±λŠ₯은 μœ μ§€ν•˜λŠ” ν”„λΌμ΄λ²„μ‹œ 쀑심 AI μ†”λ£¨μ…˜.",
195
- theme=gr.themes.Soft(primary_hue="violet", secondary_hue="violet", neutral_hue="gray",font=[gr.themes.GoogleFont("Exo"), "ui-sans-serif", "system-ui", "sans-serif"]).set(
196
  body_background_fill_dark="#16141c",
197
  block_background_fill_dark="#16141c",
198
  block_border_width="1px",
@@ -204,27 +200,81 @@ demo = gr.ChatInterface(
204
  background_fill_secondary_dark="#16141c",
205
  color_accent_soft_dark="transparent",
206
  code_background_fill_dark="#292733",
207
- ),
208
- css=css,
209
- examples=[
210
- ["μ•ˆλ…•ν•˜μ„Έμš”, μ €λŠ” AI에 관심이 λ§ŽμŠ΅λ‹ˆλ‹€. μ–‘μžν™”λž€ λ¬΄μ—‡μΈκ°€μš”?"],
211
- ["λ―ΈμŠ€νŠΈλž„ λͺ¨λΈμ˜ νŠΉμ§•μ€ λ¬΄μ—‡μΈκ°€μš”?"],
212
- ["κΈ΄ μ»¨ν…μŠ€νŠΈ(context)λ₯Ό μ²˜λ¦¬ν•˜λŠ” 방법을 μ„€λͺ…ν•΄ μ£Όμ„Έμš”."]
213
- ],
214
- additional_inputs=[
215
- gr.Textbox(
216
- value="You are a deep thinking AI, you may use extremely long chains of thought to deeply consider the problem and deliberate with yourself via systematic reasoning processes to help come to a correct solution prior to answering. You should enclose your thoughts and internal monologue inside tags, and then provide your solution or response to the problem.",
217
- label="μ‹œμŠ€ν…œ λ©”μ‹œμ§€",
218
- lines=5
219
- ),
220
- gr.Slider(minimum=1, maximum=4096, value=2048, step=1, label="μ΅œλŒ€ 토큰 수"),
221
- gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
222
- gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p"),
223
- gr.Slider(minimum=0, maximum=100, value=40, step=1, label="Top-k"),
224
- gr.Slider(minimum=0.0, maximum=2.0, value=1.1, step=0.1, label="Repetition penalty"),
225
- ],
226
- chatbot=gr.Chatbot(placeholder=PLACEHOLDER, type="messages")
227
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
 
229
  if __name__ == "__main__":
230
  demo.launch()
 
188
  </div>
189
  """
190
 
191
+ with gr.Blocks(theme=gr.themes.Soft(primary_hue="violet", secondary_hue="violet", neutral_hue="gray",font=[gr.themes.GoogleFont("Exo"), "ui-sans-serif", "system-ui", "sans-serif"]).set(
 
 
 
 
192
  body_background_fill_dark="#16141c",
193
  block_background_fill_dark="#16141c",
194
  block_border_width="1px",
 
200
  background_fill_secondary_dark="#16141c",
201
  color_accent_soft_dark="transparent",
202
  code_background_fill_dark="#292733",
203
+ ), css=css) as demo:
204
+
205
+ gr.Markdown("# Ginigen Private AI")
206
+ gr.Markdown("6BIT μ–‘μžν™”λ‘œ λͺ¨λΈ ν¬κΈ°λŠ” 쀄이고 μ„±λŠ₯은 μœ μ§€ν•˜λŠ” ν”„λΌμ΄λ²„μ‹œ 쀑심 AI μ†”λ£¨μ…˜.")
207
+
208
+ chatbot = gr.Chatbot(
209
+ value=[[None, PLACEHOLDER]],
210
+ height=600,
211
+ avatar_images=(None, "https://huggingface.co/spaces/ginigen/Private-BitSix-Mistral-Small-3.1-24B-Instruct-2503/resolve/main/llama.jpg"),
212
+ show_copy_button=True,
213
+ show_label=False,
214
+ elem_id="chatbot"
215
+ )
216
+
217
+ with gr.Row():
218
+ with gr.Column(scale=4):
219
+ with gr.Row():
220
+ msg = gr.Textbox(
221
+ show_label=False,
222
+ placeholder="λ©”μ‹œμ§€λ₯Ό μž…λ ₯ν•˜μ„Έμš”...",
223
+ container=False,
224
+ scale=8
225
+ )
226
+ submit_btn = gr.Button("전솑", variant="primary", scale=1)
227
+
228
+ with gr.Column(scale=1):
229
+ system_message = gr.Textbox(
230
+ value="You are a deep thinking AI, you may use extremely long chains of thought to deeply consider the problem and deliberate with yourself via systematic reasoning processes to help come to a correct solution prior to answering. You should enclose your thoughts and internal monologue inside tags, and then provide your solution or response to the problem.",
231
+ label="μ‹œμŠ€ν…œ λ©”μ‹œμ§€",
232
+ lines=5
233
+ )
234
+
235
+ with gr.Accordion("κ³ κΈ‰ μ„€μ •", open=False):
236
+ max_tokens = gr.Slider(minimum=1, maximum=4096, value=2048, step=1, label="μ΅œλŒ€ 토큰 수")
237
+ temperature = gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature")
238
+ top_p = gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p")
239
+ top_k = gr.Slider(minimum=0, maximum=100, value=40, step=1, label="Top-k")
240
+ repeat_penalty = gr.Slider(minimum=0.0, maximum=2.0, value=1.1, step=0.1, label="Repetition penalty")
241
+
242
+ clear_btn = gr.Button("λŒ€ν™” μ΄ˆκΈ°ν™”")
243
+
244
+ # Event handlers
245
+ submit_btn.click(
246
+ fn=lambda chatbot: chatbot[1:] if chatbot and len(chatbot) > 0 and chatbot[0][0] is None else chatbot,
247
+ inputs=chatbot,
248
+ outputs=chatbot,
249
+ queue=False
250
+ ).then(
251
+ fn=respond,
252
+ inputs=[msg, chatbot, system_message, max_tokens, temperature, top_p, top_k, repeat_penalty],
253
+ outputs=chatbot,
254
+ queue=True
255
+ ).then(
256
+ fn=lambda: "",
257
+ inputs=None,
258
+ outputs=msg
259
+ )
260
+
261
+ msg.submit(
262
+ fn=lambda chatbot: chatbot[1:] if chatbot and len(chatbot) > 0 and chatbot[0][0] is None else chatbot,
263
+ inputs=chatbot,
264
+ outputs=chatbot,
265
+ queue=False
266
+ ).then(
267
+ fn=respond,
268
+ inputs=[msg, chatbot, system_message, max_tokens, temperature, top_p, top_k, repeat_penalty],
269
+ outputs=chatbot,
270
+ queue=True
271
+ ).then(
272
+ fn=lambda: "",
273
+ inputs=None,
274
+ outputs=msg
275
+ )
276
+
277
+ clear_btn.click(lambda: [[None, PLACEHOLDER]], None, chatbot, queue=False)
278
 
279
  if __name__ == "__main__":
280
  demo.launch()