openfree commited on
Commit
dc16673
ยท
verified ยท
1 Parent(s): 7826ad4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -29
app.py CHANGED
@@ -142,7 +142,6 @@ def pdf_to_markdown(pdf_path: str) -> str:
142
  page_text = page.extract_text() or ""
143
  page_text = page_text.strip()
144
  if page_text:
145
- # ํŽ˜์ด์ง€๋ณ„ ์ตœ๋Œ€์น˜ ์ž˜๋ผ์„œ ์‚ฌ์šฉ
146
  if len(page_text) > MAX_CONTENT_CHARS // max_pages:
147
  page_text = page_text[:MAX_CONTENT_CHARS // max_pages] + "...(truncated)"
148
  text_chunks.append(f"## Page {page_num+1}\n\n{page_text}\n")
@@ -278,7 +277,6 @@ def process_interleaved_images(message: dict) -> list[dict]:
278
  elif part.strip():
279
  content.append({"type": "text", "text": part.strip()})
280
  else:
281
- # ๋นˆ ๋ฌธ์ž์—ด๋„ content์— ์ถ”๊ฐ€๋  ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ ํ•„์š”ํ•œ ๊ฒฝ์šฐ ์กฐ์ •
282
  if isinstance(part, str) and part != "<image>":
283
  content.append({"type": "text", "text": part})
284
  return content
@@ -331,7 +329,6 @@ def process_new_user_message(message: dict) -> list[dict]:
331
 
332
  if "<image>" in message["text"] and image_files:
333
  interleaved_content = process_interleaved_images({"text": message["text"], "files": image_files})
334
- # ์ด๋ฏธ text ๋ณธ๋ฌธ์— <image>๊ฐ€ ํฌํ•จ๋œ ๊ฒฝ์šฐ, ์ค‘๋ณต ์ฒ˜๋ฆฌ๋ฅผ ํ”ผํ•˜๊ธฐ ์œ„ํ•ด ํ•„์š” ์‹œ ์กฐ์ •
335
  if content_list and content_list[0]["type"] == "text":
336
  content_list = content_list[1:]
337
  return interleaved_content + content_list
@@ -570,40 +567,44 @@ examples = [
570
  # Gradio UI (Blocks) ๊ตฌ์„ฑ (์ขŒ์ธก ์‚ฌ์ด๋“œ ๋ฉ”๋‰ด ์—†์ด ์ „์ฒดํ™”๋ฉด ์ฑ„ํŒ…)
571
  ##############################################################################
572
  css = """
573
- body {
574
- background: linear-gradient(135deg, #667eea, #764ba2);
575
- font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
576
- color: #333;
577
- margin: 0;
578
- padding: 0;
579
- }
580
  .gradio-container {
581
  background: rgba(255, 255, 255, 0.95);
582
  border-radius: 15px;
583
  padding: 30px 40px;
584
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
585
- margin: 40px auto;
586
- max-width: 1200px;
587
- }
588
- .gradio-container h1 {
589
- color: #333;
590
- text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
591
  }
 
592
  .fillable {
593
- width: 95% !important;
594
- max-width: unset !important;
595
- }
596
- #examples_container {
597
- margin: auto;
598
- width: 90%;
599
  }
600
- #examples_row {
601
- justify-content: center;
 
 
 
 
 
 
 
 
 
 
602
  }
 
 
603
  button, .btn {
604
- background: linear-gradient(90deg, #ff8a00, #e52e71);
 
 
 
 
605
  border: none;
606
- color: #fff;
607
  padding: 12px 24px;
608
  text-transform: uppercase;
609
  font-weight: bold;
@@ -612,8 +613,18 @@ button, .btn {
612
  cursor: pointer;
613
  transition: transform 0.2s ease-in-out;
614
  }
 
615
  button:hover, .btn:hover {
616
- transform: scale(1.05);
 
 
 
 
 
 
 
 
 
617
  }
618
  """
619
 
@@ -638,7 +649,7 @@ with gr.Blocks(css=css, title="Gemma3-R1945-27B") as demo:
638
  # ๋‚ด๋ถ€์ ์œผ๋กœ ์“ฐ์ด์ง€๋งŒ ํ™”๋ฉด์—๋Š” ๋…ธ์ถœ๋˜์ง€ ์•Š๋„๋ก ์„ค์ •
639
  system_prompt_box = gr.Textbox(
640
  lines=3,
641
- 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. Please answer in Korean.You have the ability to read English sources, but you **must always speak in Korean**.Even if the search results are in English, answer in Korean.",
642
  visible=False # ํ™”๋ฉด์—์„œ ๊ฐ์ถค
643
  )
644
 
@@ -695,4 +706,4 @@ with gr.Blocks(css=css, title="Gemma3-R1945-27B") as demo:
695
 
696
  if __name__ == "__main__":
697
  # ๋กœ์ปฌ์—์„œ๋งŒ ์‹คํ–‰ ์‹œ
698
- demo.launch()
 
142
  page_text = page.extract_text() or ""
143
  page_text = page_text.strip()
144
  if page_text:
 
145
  if len(page_text) > MAX_CONTENT_CHARS // max_pages:
146
  page_text = page_text[:MAX_CONTENT_CHARS // max_pages] + "...(truncated)"
147
  text_chunks.append(f"## Page {page_num+1}\n\n{page_text}\n")
 
277
  elif part.strip():
278
  content.append({"type": "text", "text": part.strip()})
279
  else:
 
280
  if isinstance(part, str) and part != "<image>":
281
  content.append({"type": "text", "text": part})
282
  return content
 
329
 
330
  if "<image>" in message["text"] and image_files:
331
  interleaved_content = process_interleaved_images({"text": message["text"], "files": image_files})
 
332
  if content_list and content_list[0]["type"] == "text":
333
  content_list = content_list[1:]
334
  return interleaved_content + content_list
 
567
  # Gradio UI (Blocks) ๊ตฌ์„ฑ (์ขŒ์ธก ์‚ฌ์ด๋“œ ๋ฉ”๋‰ด ์—†์ด ์ „์ฒดํ™”๋ฉด ์ฑ„ํŒ…)
568
  ##############################################################################
569
  css = """
570
+ /* 1) UI๋ฅผ ์ฒ˜์Œ๋ถ€ํ„ฐ ๊ฐ€์žฅ ๋„“๊ฒŒ (width 100%) ๊ณ ์ •ํ•˜์—ฌ ํ‘œ์‹œ */
 
 
 
 
 
 
571
  .gradio-container {
572
  background: rgba(255, 255, 255, 0.95);
573
  border-radius: 15px;
574
  padding: 30px 40px;
575
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
576
+ margin: 20px auto; /* ์œ„์•„๋ž˜ ์—ฌ๋ฐฑ๋งŒ ์œ ์ง€ */
577
+ width: 100% !important;
578
+ max-width: none !important; /* 1200px ์ œํ•œ ์ œ๊ฑฐ */
 
 
 
579
  }
580
+
581
  .fillable {
582
+ width: 100% !important;
583
+ max-width: 100% !important;
 
 
 
 
584
  }
585
+
586
+ /* 2) ๋ฐฐ๊ฒฝ์„ ์—ฐํ•˜๊ณ  ํˆฌ๋ช…ํ•œ ํŒŒ์Šคํ…” ํ†ค ๊ทธ๋ผ๋””์–ธํŠธ๋กœ ๋ณ€๊ฒฝ */
587
+ body {
588
+ background: linear-gradient(
589
+ 135deg,
590
+ rgba(255, 229, 210, 0.6),
591
+ rgba(255, 240, 245, 0.6)
592
+ );
593
+ margin: 0;
594
+ padding: 0;
595
+ font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
596
+ color: #333;
597
  }
598
+
599
+ /* ๋ฒ„ํŠผ ์ƒ‰์ƒ๋„ ๊ธฐ์กด์˜ ์ง™์€ ๋ถ‰์€-์ฃผํ™ฉ โ†’ ํŒŒ์Šคํ…” ๊ณ„์—ด๋กœ ์—ฐํ•˜๊ฒŒ */
600
  button, .btn {
601
+ background: linear-gradient(
602
+ 90deg,
603
+ rgba(255, 210, 220, 0.7),
604
+ rgba(255, 190, 200, 0.7)
605
+ ) !important;
606
  border: none;
607
+ color: #333; /* ๊ธ€์ž ์ž˜ ๋ณด์ด๋„๋ก ์•ฝ๊ฐ„ ์ง„ํ•œ ๊ธ€์”จ */
608
  padding: 12px 24px;
609
  text-transform: uppercase;
610
  font-weight: bold;
 
613
  cursor: pointer;
614
  transition: transform 0.2s ease-in-out;
615
  }
616
+
617
  button:hover, .btn:hover {
618
+ transform: scale(1.03);
619
+ }
620
+
621
+ #examples_container {
622
+ margin: auto;
623
+ width: 90%;
624
+ }
625
+
626
+ #examples_row {
627
+ justify-content: center;
628
  }
629
  """
630
 
 
649
  # ๋‚ด๋ถ€์ ์œผ๋กœ ์“ฐ์ด์ง€๋งŒ ํ™”๋ฉด์—๋Š” ๋…ธ์ถœ๋˜์ง€ ์•Š๋„๋ก ์„ค์ •
650
  system_prompt_box = gr.Textbox(
651
  lines=3,
652
+ 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. Please answer in Korean.You have the ability to read English sources, but you **must always speak in Korean**.Even if the search results are in English, answer in Korean.",
653
  visible=False # ํ™”๋ฉด์—์„œ ๊ฐ์ถค
654
  )
655
 
 
706
 
707
  if __name__ == "__main__":
708
  # ๋กœ์ปฌ์—์„œ๋งŒ ์‹คํ–‰ ์‹œ
709
+ demo.launch()