Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
| 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 |
-
#examples_container {
|
| 597 |
-
margin: auto;
|
| 598 |
-
width: 90%;
|
| 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,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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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.
|
| 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()
|