Spaces:
Running
on
Zero
Running
on
Zero
Update app-backup.py
Browse files- 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 |
-
|
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:
|
586 |
-
|
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:
|
594 |
-
max-width:
|
595 |
}
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
602 |
}
|
|
|
|
|
603 |
button, .btn {
|
604 |
-
background: linear-gradient(
|
|
|
|
|
|
|
|
|
605 |
border: none;
|
606 |
-
color: #
|
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
617 |
}
|
618 |
"""
|
619 |
|
620 |
title_html = """
|
621 |
-
<h1 align="center" style="margin-bottom: 0.2em; font-size: 1.6em;"> ๐ค Gemma3-
|
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-
|
630 |
gr.Markdown(title_html)
|
631 |
|
632 |
# ์น์์น ์ต์
์ ํ๋ฉด์ ํ์ (ํ์ง๋ง ์์คํ
ํ๋กฌํํธ, ํ ํฐ ์ฌ๋ผ์ด๋ ๋ฑ์ ๊ฐ์ถค)
|
633 |
web_search_checkbox = gr.Checkbox(
|
634 |
-
label="
|
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.
|
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 |
+
|