openfree commited on
Commit
14a6ee9
ยท
verified ยท
1 Parent(s): bece420

Update app-backup.py

Browse files
Files changed (1) hide show
  1. app-backup.py +67 -44
app-backup.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
@@ -527,24 +524,13 @@ examples = [
527
  ],
528
  }
529
  ],
530
- [
531
- {
532
- "text": "์ด๋ฏธ์ง€์˜ ์‹œ๊ฐ์  ์š”์†Œ์—์„œ ์˜๊ฐ์„ ๋ฐ›์•„ ์‹œ๋ฅผ ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”.",
533
- "files": ["assets/sample-images/06-1.png", "assets/sample-images/06-2.png"],
534
- }
535
- ],
536
  [
537
  {
538
  "text": "๋™์ผํ•œ ๋ง‰๋Œ€ ๊ทธ๋ž˜ํ”„๋ฅผ ๊ทธ๋ฆฌ๋Š” matplotlib ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”.",
539
  "files": ["assets/additional-examples/barchart.png"],
540
  }
541
  ],
542
- [
543
- {
544
- "text": "์ด ์„ธ๊ณ„์—์„œ ์‚ด๊ณ  ์žˆ์„ ์ƒ๋ฌผ๋“ค์„ ์ƒ์ƒํ•ด์„œ ๋ฌ˜์‚ฌํ•ด์ฃผ์„ธ์š”.",
545
- "files": ["assets/sample-images/08.png"],
546
- }
547
- ],
548
  [
549
  {
550
  "text": "์ด๋ฏธ์ง€์— ์žˆ๋Š” ํ…์ŠคํŠธ๋ฅผ ๊ทธ๋Œ€๋กœ ์ฝ์–ด์„œ ๋งˆํฌ๋‹ค์šด ํ˜•ํƒœ๋กœ ์ ์–ด์ฃผ์„ธ์š”.",
@@ -563,6 +549,28 @@ examples = [
563
  "files": ["assets/sample-images/03.png"],
564
  }
565
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
566
  ]
567
 
568
 
@@ -570,40 +578,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,13 +624,23 @@ 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
 
620
  title_html = """
621
- <h1 align="center" style="margin-bottom: 0.2em; font-size: 1.6em;"> ๐Ÿค— Gemma3-R1945-27B </h1>
622
  <p align="center" style="font-size:1.1em; color:#555;">
623
  โœ…Agentic AI Platform โœ…Reasoning & Uncensored โœ…Multimodal & VLM โœ…Deep-Research & RAG <br>
624
  Operates on an โœ…'NVIDIA A100 GPU' as an independent local server, enhancing security and preventing information leakage.<br>
@@ -626,19 +648,19 @@ title_html = """
626
  </p>
627
  """
628
 
629
- with gr.Blocks(css=css, title="Gemma3-R1945-27B") as demo:
630
  gr.Markdown(title_html)
631
 
632
  # ์›น์„œ์น˜ ์˜ต์…˜์€ ํ™”๋ฉด์— ํ‘œ์‹œ (ํ•˜์ง€๋งŒ ์‹œ์Šคํ…œ ํ”„๋กฌํ”„ํŠธ, ํ† ํฐ ์Šฌ๋ผ์ด๋” ๋“ฑ์€ ๊ฐ์ถค)
633
  web_search_checkbox = gr.Checkbox(
634
- label="Use Web Search (์ž๋™ ํ‚ค์›Œ๋“œ ์ถ”์ถœ)",
635
  value=False
636
  )
637
 
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 +717,5 @@ 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
 
524
  ],
525
  }
526
  ],
527
+
 
 
 
 
 
528
  [
529
  {
530
  "text": "๋™์ผํ•œ ๋ง‰๋Œ€ ๊ทธ๋ž˜ํ”„๋ฅผ ๊ทธ๋ฆฌ๋Š” matplotlib ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”.",
531
  "files": ["assets/additional-examples/barchart.png"],
532
  }
533
  ],
 
 
 
 
 
 
534
  [
535
  {
536
  "text": "์ด๋ฏธ์ง€์— ์žˆ๋Š” ํ…์ŠคํŠธ๋ฅผ ๊ทธ๋Œ€๋กœ ์ฝ์–ด์„œ ๋งˆํฌ๋‹ค์šด ํ˜•ํƒœ๋กœ ์ ์–ด์ฃผ์„ธ์š”.",
 
549
  "files": ["assets/sample-images/03.png"],
550
  }
551
  ],
552
+ [
553
+ {
554
+ "text": "๋„ˆ๋Š” ์นœ๊ทผํ•˜๊ณ  ๋‹ค์ •ํ•œ ์ดํ•ด์‹ฌ ๋งŽ์€ ์—ฌ์ž์นœ๊ตฌ ์—ญํ• ์ด๋‹ค.",
555
+ }
556
+ ],
557
+ [
558
+ {
559
+ "text": """์ธ๋ฅ˜์˜ ๋งˆ์ง€๋ง‰ ์‹œํ—˜(Humanity's Last Exam) ๋ฌธ์ œ๋ฅผ ํ’€์ดํ•˜๋ผ('Deep Research' ๋ฒ„ํŠผ ํด๋ฆญํ• ๊ฒƒ) Which was the first statute in the modern State of Israel to explicitly introduce the concept of "good faith"? (Do not append "the" or the statute's year to the answer.)""",
560
+ }
561
+ ],
562
+ [
563
+ {
564
+ "text": """์ธ๋ฅ˜์˜ ๋งˆ์ง€๋ง‰ ์‹œํ—˜(Humanity's Last Exam) ๋ฌธ์ œ๋ฅผ ํ’€์ดํ•˜๋ผ. How does Guarani's nominal tense/aspect system interact with effected objects in sentences?
565
+
566
+ Answer Choices:
567
+ A. Effected objects cannot take nominal tense/aspect markers
568
+ B. Effected objects require the post-stative -kue
569
+ C. Effected objects must be marked with the destinative -rรฃ
570
+ D. Nominal tense/aspect is optional for effected objects
571
+ E. Effected objects use a special set of tense/aspect markers""",
572
+ }
573
+ ],
574
  ]
575
 
576
 
 
578
  # Gradio UI (Blocks) ๊ตฌ์„ฑ (์ขŒ์ธก ์‚ฌ์ด๋“œ ๋ฉ”๋‰ด ์—†์ด ์ „์ฒดํ™”๋ฉด ์ฑ„ํŒ…)
579
  ##############################################################################
580
  css = """
581
+ /* 1) UI๋ฅผ ์ฒ˜์Œ๋ถ€ํ„ฐ ๊ฐ€์žฅ ๋„“๊ฒŒ (width 100%) ๊ณ ์ •ํ•˜์—ฌ ํ‘œ์‹œ */
 
 
 
 
 
 
582
  .gradio-container {
583
  background: rgba(255, 255, 255, 0.95);
584
  border-radius: 15px;
585
  padding: 30px 40px;
586
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
587
+ margin: 20px auto; /* ์œ„์•„๋ž˜ ์—ฌ๋ฐฑ๋งŒ ์œ ์ง€ */
588
+ width: 100% !important;
589
+ max-width: none !important; /* 1200px ์ œํ•œ ์ œ๊ฑฐ */
 
 
 
590
  }
591
+
592
  .fillable {
593
+ width: 100% !important;
594
+ max-width: 100% !important;
595
  }
596
+
597
+ /* 2) ๋ฐฐ๊ฒฝ์„ ์—ฐํ•˜๊ณ  ํˆฌ๋ช…ํ•œ ํŒŒ์Šคํ…” ํ†ค ๊ทธ๋ผ๋””์–ธํŠธ๋กœ ๋ณ€๊ฒฝ */
598
+ body {
599
+ background: linear-gradient(
600
+ 135deg,
601
+ rgba(255, 229, 210, 0.6),
602
+ rgba(255, 240, 245, 0.6)
603
+ );
604
+ margin: 0;
605
+ padding: 0;
606
+ font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
607
+ color: #333;
608
  }
609
+
610
+ /* ๋ฒ„ํŠผ ์ƒ‰์ƒ๋„ ๊ธฐ์กด์˜ ์ง™์€ ๋ถ‰์€-์ฃผํ™ฉ โ†’ ํŒŒ์Šคํ…” ๊ณ„์—ด๋กœ ์—ฐํ•˜๊ฒŒ */
611
  button, .btn {
612
+ background: linear-gradient(
613
+ 90deg,
614
+ rgba(255, 210, 220, 0.7),
615
+ rgba(255, 190, 200, 0.7)
616
+ ) !important;
617
  border: none;
618
+ color: #333; /* ๊ธ€์ž ์ž˜ ๋ณด์ด๋„๋ก ์•ฝ๊ฐ„ ์ง„ํ•œ ๊ธ€์”จ */
619
  padding: 12px 24px;
620
  text-transform: uppercase;
621
  font-weight: bold;
 
624
  cursor: pointer;
625
  transition: transform 0.2s ease-in-out;
626
  }
627
+
628
  button:hover, .btn:hover {
629
+ transform: scale(1.03);
630
+ }
631
+
632
+ #examples_container {
633
+ margin: auto;
634
+ width: 90%;
635
+ }
636
+
637
+ #examples_row {
638
+ justify-content: center;
639
  }
640
  """
641
 
642
  title_html = """
643
+ <h1 align="center" style="margin-bottom: 0.2em; font-size: 1.6em;"> ๐Ÿค— Gemma3-uncensored-R27B </h1>
644
  <p align="center" style="font-size:1.1em; color:#555;">
645
  โœ…Agentic AI Platform โœ…Reasoning & Uncensored โœ…Multimodal & VLM โœ…Deep-Research & RAG <br>
646
  Operates on an โœ…'NVIDIA A100 GPU' as an independent local server, enhancing security and preventing information leakage.<br>
 
648
  </p>
649
  """
650
 
651
+ with gr.Blocks(css=css, title="Gemma3-uncensored-R27B") as demo:
652
  gr.Markdown(title_html)
653
 
654
  # ์›น์„œ์น˜ ์˜ต์…˜์€ ํ™”๋ฉด์— ํ‘œ์‹œ (ํ•˜์ง€๋งŒ ์‹œ์Šคํ…œ ํ”„๋กฌํ”„ํŠธ, ํ† ํฐ ์Šฌ๋ผ์ด๋” ๋“ฑ์€ ๊ฐ์ถค)
655
  web_search_checkbox = gr.Checkbox(
656
+ label="Deep Research",
657
  value=False
658
  )
659
 
660
  # ๋‚ด๋ถ€์ ์œผ๋กœ ์“ฐ์ด์ง€๋งŒ ํ™”๋ฉด์—๋Š” ๋…ธ์ถœ๋˜์ง€ ์•Š๋„๋ก ์„ค์ •
661
  system_prompt_box = gr.Textbox(
662
  lines=3,
663
+ 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.",
664
  visible=False # ํ™”๋ฉด์—์„œ ๊ฐ์ถค
665
  )
666
 
 
717
 
718
  if __name__ == "__main__":
719
  # ๋กœ์ปฌ์—์„œ๋งŒ ์‹คํ–‰ ์‹œ
720
+ demo.launch()
721
+