Spaces:
Running
Running
Commit ยท
c318017
1
Parent(s): 7cd2a55
feat(title-proofread): address customer feedback round 1
Browse files- Add Chosun style-book thousands-comma rule (PRIORITY 0, MANDATORY).
Examples: 7870 -> 7,870; 1๋ง2000 -> 1๋ง2,000.
Year/code exceptions documented (2030, KF-21).
- Strip stray </think> tokens from model output.
Handles both paired <think>...</think> and orphan </think> patterns
occasionally emitted by solar-pro2.
- Lock model to solar-pro2 (production extension target) and drop the
pro3 comparison column. Single-column result UI only.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- title_proofread/prompts/prompt_dev_v1/system.txt +24 -1
- title_proofread/runner.py +36 -14
- title_proofread/ui.py +28 -68
title_proofread/prompts/prompt_dev_v1/system.txt
CHANGED
|
@@ -21,6 +21,28 @@
|
|
| 21 |
|
| 22 |
# CRITICAL ๋ณด์กด ๊ท์น (PRIORITY ์์)
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
## PRIORITY 1: ์๋ฏธยท๊ตฌ์กฐ ์ ๋ ๋ณด์กด (MANDATORY)
|
| 25 |
|
| 26 |
NEVER ๋ค์์ ์ํํ๋ค:
|
|
@@ -42,8 +64,9 @@ NEVER ๋ค์์ ์ํํ๋ค:
|
|
| 42 |
โ ํ์ด์ฐ์ง ์๋๋ค. NEVER `้ซ์์ต` โ `๊ณ ์์ต`
|
| 43 |
- **๋ง์ค์ํ `โฆ`**: ํฉํธ์ ์์ฌ์ ยท๊ฒฐ๋ก ์ ์ฐ๊ฒฐํ๋ ์๋๋ ๊ตฌ๋์
|
| 44 |
โ ์์นยท๊ฐ์ ๊ทธ๋๋ก ์ ์ง
|
| 45 |
-
- **์์น ํ๊ธฐ ์์**: `40์กฐ์`, `1๋ง
|
| 46 |
โ ๋งยท์ตยท์กฐ ํ๊ธ ๋ณ๊ธฐ ์์ ๋ณ๊ฒฝ ๊ธ์ง, ๋จ์ยท๊ธฐํธ (`%`ยท`๋ฐฐ`ยท`๋ช
`ยท`์`) ๋ณ๊ฒฝ ๊ธ์ง
|
|
|
|
| 47 |
- **๋ฐ์ดํ ์ข
๋ฅ ๋ณํ ์ ๋ ๊ธ์ง**: ํฐ๋ฐ์ดํ โ ์์๋ฐ์ดํ ๋ณํ์ ์๋ฏธ๋ฅผ ์์ ํ ๋ฐ๊พผ๋ค
|
| 48 |
|
| 49 |
## PRIORITY 3: ์ ๋ณด ์ถ๊ฐ/์ญ์ ๊ธ์ง (MANDATORY)
|
|
|
|
| 21 |
|
| 22 |
# CRITICAL ๋ณด์กด ๊ท์น (PRIORITY ์์)
|
| 23 |
|
| 24 |
+
## PRIORITY 0: ์กฐ์ ์คํ์ผ๋ถ ์๋ฌด ๊ต์ (MANDATORY โ ๋ณด์กด์ด ์๋๋ผ *์ ๊ทน ๊ต์ *)
|
| 25 |
+
|
| 26 |
+
๋ค์ ํจํด์ ์กฐ์ ์ผ๋ณด ์คํ์ผ๋ถ ์๋ฐ์ด๋ฏ๋ก **๋ฐ๋์ ๊ต์ **ํ๋ค. ๋ณด์กด ์์น๋ณด๋ค ์ฐ์ .
|
| 27 |
+
|
| 28 |
+
### ์ฒ๋จ์ ์ฝค๋ง (4์๋ฆฌ ์ด์ ์๋ผ๋น์ ์ซ์)
|
| 29 |
+
|
| 30 |
+
์๋ฌธ์ ์ฝค๋ง๊ฐ ๋น ์ง 4์๋ฆฌ ์ด์ ์ซ์๋ *๋ฐ๋์* ์ฒ๋จ์ ์ฝค๋ง๋ฅผ ๋ณด์ถฉํ๋ค:
|
| 31 |
+
- `7870` โ `7,870`
|
| 32 |
+
- `12345` โ `12,345`
|
| 33 |
+
- `1234567` โ `1,234,567`
|
| 34 |
+
|
| 35 |
+
ํ๊ธ ๋จ์(๋ง/์ต/์กฐ) ๋ค์ ๋ถ๋ ์ซ์์๋ ๋์ผ ์ ์ฉ:
|
| 36 |
+
- `1๋ง2000` โ `1๋ง2,000`
|
| 37 |
+
- `5์ต3000๋ง` โ `5์ต3,000๋ง`
|
| 38 |
+
- `2๋ง8000๋ช
` โ `2๋ง8,000๋ช
`
|
| 39 |
+
|
| 40 |
+
**์์ธ โ ์ฝค๋ง ์ถ๊ฐํ์ง ์์**:
|
| 41 |
+
- ์ฐ๋: `2030`, `1980`, `2024ํ๋ฒ`
|
| 42 |
+
- ์ฝ๋ยท๋ฒํธยท์๋ณ์ ์ฑ๊ฒฉ: `KF-21`, `B-1`, `5G`
|
| 43 |
+
|
| 44 |
+
`% / %p / ๋ฐฐ / ๋ช
/ ์ / ๊ฑด / km / kg` ๋ฑ ๋จ์ *์* ์ซ์ ๋ชจ๋์ ์ ์ฉ.
|
| 45 |
+
|
| 46 |
## PRIORITY 1: ์๋ฏธยท๊ตฌ์กฐ ์ ๋ ๋ณด์กด (MANDATORY)
|
| 47 |
|
| 48 |
NEVER ๋ค์์ ์ํํ๋ค:
|
|
|
|
| 64 |
โ ํ์ด์ฐ์ง ์๋๋ค. NEVER `้ซ์์ต` โ `๊ณ ์์ต`
|
| 65 |
- **๋ง์ค์ํ `โฆ`**: ํฉํธ์ ์์ฌ์ ยท๊ฒฐ๋ก ์ ์ฐ๊ฒฐํ๋ ์๋๋ ๊ตฌ๋์
|
| 66 |
โ ์์นยท๊ฐ์ ๊ทธ๋๋ก ์ ์ง
|
| 67 |
+
- **์์น ํ๊ธฐ ์์**: `40์กฐ์`, `1๋ง9,585๊ฑด`, `22๋ง8,000๋ช
`, `30%`, `2๋ฐฐ`
|
| 68 |
โ ๋งยท์ตยท์กฐ ํ๊ธ ๋ณ๊ธฐ ์์ ๋ณ๊ฒฝ ๊ธ์ง, ๋จ์ยท๊ธฐํธ (`%`ยท`๋ฐฐ`ยท`๋ช
`ยท`์`) ๋ณ๊ฒฝ ๊ธ์ง
|
| 69 |
+
โ ์ฒ๋จ์ ์ฝค๋ง ๊ท์น์ ์๋ *PRIORITY 0* ์ ์๋ฌด ๊ต์ ๋์์ด๋ฏ๋ก, *์๋ฌธ์ ์ฝค๋ง๊ฐ ๋น ์ ธ ์์ผ๋ฉด ๋ฐ๋์ ๋ณด์ถฉ* ํ๋ค
|
| 70 |
- **๋ฐ์ดํ ์ข
๋ฅ ๋ณํ ์ ๋ ๊ธ์ง**: ํฐ๋ฐ์ดํ โ ์์๋ฐ์ดํ ๋ณํ์ ์๋ฏธ๋ฅผ ์์ ํ ๋ฐ๊พผ๋ค
|
| 71 |
|
| 72 |
## PRIORITY 3: ์ ๋ณด ์ถ๊ฐ/์ญ์ ๊ธ์ง (MANDATORY)
|
title_proofread/runner.py
CHANGED
|
@@ -1,18 +1,40 @@
|
|
| 1 |
-
"""์ ๋ชฉ ๊ต์ด ๋จ์ผ ํธ์ถ ๋ฌ๋ โ solar-pro2
|
| 2 |
|
| 3 |
-
|
| 4 |
-
๋ชจ๋ธ์ ํธ์ถ ์ ์ธ์๋ก ์ง์ (UI ์์ ๋ ๋ชจ๋ธ์ ๋ณ๋ ฌ๋ก ํธ์ถ).
|
| 5 |
"""
|
| 6 |
|
| 7 |
from __future__ import annotations
|
| 8 |
|
|
|
|
| 9 |
import time
|
| 10 |
from pathlib import Path
|
| 11 |
from typing import Any
|
| 12 |
|
| 13 |
-
|
| 14 |
DEFAULT_PROMPT_DIR = Path(__file__).resolve().parent / "prompts" / "prompt_dev_v1"
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
def load_default_prompts() -> tuple[str, str]:
|
| 18 |
"""`prompt_dev_v1` ์ system.txt + user.txt ๋ฅผ ๊ทธ๋๋ก ๋ฐํ."""
|
|
@@ -33,28 +55,27 @@ def run_title_proofread(
|
|
| 33 |
category: str,
|
| 34 |
system_prompt: str,
|
| 35 |
user_template: str,
|
| 36 |
-
model: str,
|
| 37 |
temperature: float = 0.0,
|
| 38 |
reasoning_effort: str = "low",
|
| 39 |
max_tokens: int = 2000,
|
| 40 |
) -> dict[str, Any]:
|
| 41 |
-
"""๋จ์ผ LLM ํธ์ถ.
|
| 42 |
|
| 43 |
Returns:
|
| 44 |
{
|
| 45 |
-
"output": str, # ๋ชจ๋ธ ์๋ต (strip
|
| 46 |
-
"user_message": str, # placeholder ์นํ๋ ์ค user content
|
| 47 |
"model": str,
|
| 48 |
"latency_ms": int,
|
| 49 |
"usage": dict, # {prompt_tokens, completion_tokens, total_tokens}
|
| 50 |
-
"error": str | None,
|
| 51 |
}
|
| 52 |
"""
|
| 53 |
user_msg = render_user_message(user_template, original, category)
|
| 54 |
start = time.time()
|
| 55 |
try:
|
| 56 |
kwargs: dict[str, Any] = {
|
| 57 |
-
"model":
|
| 58 |
"messages": [
|
| 59 |
{"role": "system", "content": system_prompt},
|
| 60 |
{"role": "user", "content": user_msg},
|
|
@@ -69,14 +90,15 @@ def run_title_proofread(
|
|
| 69 |
return {
|
| 70 |
"output": "",
|
| 71 |
"user_message": user_msg,
|
| 72 |
-
"model":
|
| 73 |
"latency_ms": int((time.time() - start) * 1000),
|
| 74 |
"usage": {},
|
| 75 |
"error": f"{type(exc).__name__}: {exc}",
|
| 76 |
}
|
| 77 |
|
| 78 |
elapsed_ms = int((time.time() - start) * 1000)
|
| 79 |
-
raw =
|
|
|
|
| 80 |
usage = getattr(resp, "usage", None)
|
| 81 |
usage_dict: dict[str, int] = {}
|
| 82 |
if usage:
|
|
@@ -86,9 +108,9 @@ def run_title_proofread(
|
|
| 86 |
usage_dict[k] = v
|
| 87 |
|
| 88 |
return {
|
| 89 |
-
"output":
|
| 90 |
"user_message": user_msg,
|
| 91 |
-
"model":
|
| 92 |
"latency_ms": elapsed_ms,
|
| 93 |
"usage": usage_dict,
|
| 94 |
"error": None,
|
|
|
|
| 1 |
+
"""์ ๋ชฉ ๊ต์ด ๋จ์ผ ํธ์ถ ๋ฌ๋ โ solar-pro2 ๊ณ ์ .
|
| 2 |
|
| 3 |
+
production ํ๊ฒฝ(extension) ์ด solar-pro2 ๋ฅผ ์ฌ์ฉํ๋ฏ๋ก ๋ฐ๋ชจ๋ ๋์ผ ๋ชจ๋ธ๋ก ๊ณ ์ .
|
|
|
|
| 4 |
"""
|
| 5 |
|
| 6 |
from __future__ import annotations
|
| 7 |
|
| 8 |
+
import re
|
| 9 |
import time
|
| 10 |
from pathlib import Path
|
| 11 |
from typing import Any
|
| 12 |
|
| 13 |
+
MODEL = "solar-pro2"
|
| 14 |
DEFAULT_PROMPT_DIR = Path(__file__).resolve().parent / "prompts" / "prompt_dev_v1"
|
| 15 |
|
| 16 |
+
# solar-pro2 ๊ฐ ๊ฐ๋ ์๋ต ๋ณธ๋ฌธ ์์ reasoning trace ๋ฅผ emit ํ๊ณ `</think>` ๋ก ๋ซ๋
|
| 17 |
+
# ๊ฒฝ์ฐ๊ฐ ์์ (๋ณดํต์ paired `<think>...</think>` ์ธ๋ฐ unpaired ๊ฐ ๋ฐ์). upstage
|
| 18 |
+
# provider ์ paired-tag strip ๋ ์ฐํ๋๋ฏ๋ก, ๋ฐ๋ชจ ๋จ์์ ๊ฒฐ์ ์ ์ผ๋ก ์ ๊ฑฐํ๋ค.
|
| 19 |
+
_PAIRED_THINK = re.compile(r"<think>.*?</think>", re.DOTALL)
|
| 20 |
+
_ORPHAN_THINK_PREFIX = re.compile(r"^.*?</think>\s*", re.DOTALL)
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def _strip_think(raw: str) -> str:
|
| 24 |
+
"""`<think>...</think>` ๋ฐ unpaired `</think>` ์๋ถ๋ถ ๋ชจ๋ ์ ๊ฑฐ.
|
| 25 |
+
|
| 26 |
+
๊ฐ๋ ์์:
|
| 27 |
+
1. paired `<think>...</think>` ๋ธ๋ก ์ ๊ฑฐ
|
| 28 |
+
2. ๊ทธ๋๋ `</think>` ๊ฐ ๋จ์ ์์ผ๋ฉด โ ์ฒซ ๋ฑ์ฅ ์์น ์ด์ ์ ์ ๋ถ reasoning
|
| 29 |
+
trace ๋ก ๊ฐ์ฃผํ๊ณ ์๋ผ๋ (๊ฐ์ฅ ํํ ๋์ถ ํจํด)
|
| 30 |
+
3. ๋จ์ `<think>` / `</think>` ํ ํฐ ์์กด๋ ์ ๊ฑฐ
|
| 31 |
+
"""
|
| 32 |
+
s = _PAIRED_THINK.sub("", raw)
|
| 33 |
+
if "</think>" in s:
|
| 34 |
+
s = _ORPHAN_THINK_PREFIX.sub("", s, count=1)
|
| 35 |
+
s = s.replace("</think>", "").replace("<think>", "")
|
| 36 |
+
return s.strip()
|
| 37 |
+
|
| 38 |
|
| 39 |
def load_default_prompts() -> tuple[str, str]:
|
| 40 |
"""`prompt_dev_v1` ์ system.txt + user.txt ๋ฅผ ๊ทธ๋๋ก ๋ฐํ."""
|
|
|
|
| 55 |
category: str,
|
| 56 |
system_prompt: str,
|
| 57 |
user_template: str,
|
|
|
|
| 58 |
temperature: float = 0.0,
|
| 59 |
reasoning_effort: str = "low",
|
| 60 |
max_tokens: int = 2000,
|
| 61 |
) -> dict[str, Any]:
|
| 62 |
+
"""๋จ์ผ LLM ํธ์ถ. ๋ชจ๋ธ์ ํญ์ `solar-pro2`.
|
| 63 |
|
| 64 |
Returns:
|
| 65 |
{
|
| 66 |
+
"output": str, # ๋ชจ๋ธ ์๋ต (strip + think-token ์ ๊ฑฐ ํ)
|
| 67 |
+
"user_message": str, # placeholder ์นํ๋ ์ค user content
|
| 68 |
"model": str,
|
| 69 |
"latency_ms": int,
|
| 70 |
"usage": dict, # {prompt_tokens, completion_tokens, total_tokens}
|
| 71 |
+
"error": str | None,
|
| 72 |
}
|
| 73 |
"""
|
| 74 |
user_msg = render_user_message(user_template, original, category)
|
| 75 |
start = time.time()
|
| 76 |
try:
|
| 77 |
kwargs: dict[str, Any] = {
|
| 78 |
+
"model": MODEL,
|
| 79 |
"messages": [
|
| 80 |
{"role": "system", "content": system_prompt},
|
| 81 |
{"role": "user", "content": user_msg},
|
|
|
|
| 90 |
return {
|
| 91 |
"output": "",
|
| 92 |
"user_message": user_msg,
|
| 93 |
+
"model": MODEL,
|
| 94 |
"latency_ms": int((time.time() - start) * 1000),
|
| 95 |
"usage": {},
|
| 96 |
"error": f"{type(exc).__name__}: {exc}",
|
| 97 |
}
|
| 98 |
|
| 99 |
elapsed_ms = int((time.time() - start) * 1000)
|
| 100 |
+
raw = resp.choices[0].message.content or ""
|
| 101 |
+
cleaned = _strip_think(raw)
|
| 102 |
usage = getattr(resp, "usage", None)
|
| 103 |
usage_dict: dict[str, int] = {}
|
| 104 |
if usage:
|
|
|
|
| 108 |
usage_dict[k] = v
|
| 109 |
|
| 110 |
return {
|
| 111 |
+
"output": cleaned,
|
| 112 |
"user_message": user_msg,
|
| 113 |
+
"model": MODEL,
|
| 114 |
"latency_ms": elapsed_ms,
|
| 115 |
"usage": usage_dict,
|
| 116 |
"error": None,
|
title_proofread/ui.py
CHANGED
|
@@ -1,22 +1,19 @@
|
|
| 1 |
-
"""Gradio UI โ ์ ๋ชฉ ๊ต์ด sandbox ํญ.
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
์ข์ฐ ์ปฌ๋ผ์์ ๋์์ ๋น๊ตํ๋ค.
|
| 6 |
"""
|
| 7 |
|
| 8 |
from __future__ import annotations
|
| 9 |
|
| 10 |
-
from concurrent.futures import ThreadPoolExecutor
|
| 11 |
from typing import Any
|
| 12 |
|
| 13 |
import gradio as gr
|
| 14 |
from diff_utils import highlight_diff
|
| 15 |
|
| 16 |
-
from .runner import
|
| 17 |
|
| 18 |
# UI ๋จ์ํ๋ฅผ ์ํด category ๋ ์
๋ ฅ ๋ฐ์ง ์๊ณ ๋ด๋ถ ๊ณ ์ .
|
| 19 |
-
# ๋ชจ๋ธ ๊ฑฐ๋์ ์นดํ
๊ณ ๋ฆฌ๋ณ๋ก ์๋ฏธ ์๋ ์ฐจ์ด๊ฐ ๊ด์ฐฐ๋์ง ์์ ์ ํ UI ์ ๊ฑฐ.
|
| 20 |
DEFAULT_CATEGORY = "์ผ๋ฐ๊ธฐ์ฌ"
|
| 21 |
|
| 22 |
|
|
@@ -26,13 +23,9 @@ def build_title_proofread_tab(client: Any) -> None:
|
|
| 26 |
Args:
|
| 27 |
client: openai.OpenAI ํธํ ํด๋ผ์ด์ธํธ (Upstage base_url ์ค์ ).
|
| 28 |
"""
|
| 29 |
-
# Default prompts loaded once at module init โ never exposed to users.
|
| 30 |
default_system, default_user = load_default_prompts()
|
| 31 |
|
| 32 |
-
gr.Markdown(
|
| 33 |
-
"## ์ ๋ชฉ ๊ต์ด\n"
|
| 34 |
-
f"ํ๊ตญ ์ ๋ฌธ ์ ๋ชฉ ๊ต์ด ๊ฒฐ๊ณผ๋ฅผ `{MODELS[0]}` ์ `{MODELS[1]}` ๋ ๋ชจ๋ธ๋ก ๋น๊ต."
|
| 35 |
-
)
|
| 36 |
|
| 37 |
original = gr.Textbox(
|
| 38 |
label="์ ๋ชฉ ์
๋ ฅ",
|
|
@@ -40,7 +33,7 @@ def build_title_proofread_tab(client: Any) -> None:
|
|
| 40 |
lines=1,
|
| 41 |
)
|
| 42 |
|
| 43 |
-
with gr.Accordion("์ถ๋ก ์ต์
|
| 44 |
with gr.Row():
|
| 45 |
temperature = gr.Slider(
|
| 46 |
minimum=0.0,
|
|
@@ -61,24 +54,12 @@ def build_title_proofread_tab(client: Any) -> None:
|
|
| 61 |
elem_id="title-proofread-run-btn",
|
| 62 |
)
|
| 63 |
|
| 64 |
-
# โโโ ๊ฒฐ๊ณผ โ
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
gr.Markdown(f"### {MODELS[0]}")
|
| 68 |
-
output_pro2 = gr.Textbox(label="๊ต์ ๊ฒฐ๊ณผ", lines=2, interactive=False)
|
| 69 |
-
diff_pro2 = gr.HTML(label="์๋ณธ ๋๋น diff")
|
| 70 |
-
with gr.Column():
|
| 71 |
-
gr.Markdown(f"### {MODELS[1]}")
|
| 72 |
-
output_pro3 = gr.Textbox(label="๊ต์ ๊ฒฐ๊ณผ", lines=2, interactive=False)
|
| 73 |
-
diff_pro3 = gr.HTML(label="์๋ณธ ๋๋น diff")
|
| 74 |
|
| 75 |
def _empty():
|
| 76 |
-
return (
|
| 77 |
-
gr.update(value=""),
|
| 78 |
-
gr.update(value=""),
|
| 79 |
-
gr.update(value=""),
|
| 80 |
-
gr.update(value=""),
|
| 81 |
-
)
|
| 82 |
|
| 83 |
def _on_run(
|
| 84 |
original_text: str,
|
|
@@ -94,43 +75,24 @@ def build_title_proofread_tab(client: Any) -> None:
|
|
| 94 |
|
| 95 |
orig_clean = original_text.strip()
|
| 96 |
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
category=DEFAULT_CATEGORY,
|
| 106 |
-
system_prompt=default_system,
|
| 107 |
-
user_template=default_user,
|
| 108 |
-
model=m,
|
| 109 |
-
temperature=temperature_val,
|
| 110 |
-
reasoning_effort=reasoning_effort_val,
|
| 111 |
-
)
|
| 112 |
-
for m in MODELS
|
| 113 |
-
}
|
| 114 |
-
results = {m: f.result() for m, f in futures.items()}
|
| 115 |
-
|
| 116 |
-
r2 = results[MODELS[0]]
|
| 117 |
-
r3 = results[MODELS[1]]
|
| 118 |
-
|
| 119 |
-
# ๋ชจ๋ธ ํธ์ถ ์์ฒด๊ฐ ์คํจํ๋ฉด toast ๋ก ์๋ฆฌ๊ณ ๊ฒฐ๊ณผ ๋น์.
|
| 120 |
-
for m, r in ((MODELS[0], r2), (MODELS[1], r3)):
|
| 121 |
-
if r.get("error"):
|
| 122 |
-
gr.Warning(f"{m} ํธ์ถ ์คํจ: {r['error']}")
|
| 123 |
-
|
| 124 |
-
def _diff(out: str) -> str:
|
| 125 |
-
return highlight_diff(orig_clean, out) if out else ""
|
| 126 |
-
|
| 127 |
-
return (
|
| 128 |
-
gr.update(value=r2["output"]),
|
| 129 |
-
gr.update(value=_diff(r2["output"])),
|
| 130 |
-
gr.update(value=r3["output"]),
|
| 131 |
-
gr.update(value=_diff(r3["output"])),
|
| 132 |
)
|
| 133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
run_btn.click(
|
| 135 |
_on_run,
|
| 136 |
inputs=[
|
|
@@ -139,9 +101,7 @@ def build_title_proofread_tab(client: Any) -> None:
|
|
| 139 |
reasoning_effort,
|
| 140 |
],
|
| 141 |
outputs=[
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
output_pro3,
|
| 145 |
-
diff_pro3,
|
| 146 |
],
|
| 147 |
)
|
|
|
|
| 1 |
+
"""Gradio UI โ ์ ๋ชฉ ๊ต์ด sandbox ํญ (solar-pro2 ๋จ์ผ ๋ชจ๋ธ).
|
| 2 |
|
| 3 |
+
production extension ๊ณผ ๋์ผ ๋ชจ๋ธ(solar-pro2) ๋ก ๊ณ ์ . ์์คํ
/์ ์ ํ๋กฌํํธ๋
|
| 4 |
+
๋ด๋ถ default ์ฌ์ฉ โ UI ์ ๋
ธ์ถํ์ง ์์. ํธ์ถ ๋ฉํ๋ฐ์ดํฐ๋ ํ์ํ์ง ์์.
|
|
|
|
| 5 |
"""
|
| 6 |
|
| 7 |
from __future__ import annotations
|
| 8 |
|
|
|
|
| 9 |
from typing import Any
|
| 10 |
|
| 11 |
import gradio as gr
|
| 12 |
from diff_utils import highlight_diff
|
| 13 |
|
| 14 |
+
from .runner import MODEL, load_default_prompts, run_title_proofread
|
| 15 |
|
| 16 |
# UI ๋จ์ํ๋ฅผ ์ํด category ๋ ์
๋ ฅ ๋ฐ์ง ์๊ณ ๋ด๋ถ ๊ณ ์ .
|
|
|
|
| 17 |
DEFAULT_CATEGORY = "์ผ๋ฐ๊ธฐ์ฌ"
|
| 18 |
|
| 19 |
|
|
|
|
| 23 |
Args:
|
| 24 |
client: openai.OpenAI ํธํ ํด๋ผ์ด์ธํธ (Upstage base_url ์ค์ ).
|
| 25 |
"""
|
|
|
|
| 26 |
default_system, default_user = load_default_prompts()
|
| 27 |
|
| 28 |
+
gr.Markdown(f"## ์ ๋ชฉ ๊ต์ด ({MODEL})")
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
original = gr.Textbox(
|
| 31 |
label="์ ๋ชฉ ์
๋ ฅ",
|
|
|
|
| 33 |
lines=1,
|
| 34 |
)
|
| 35 |
|
| 36 |
+
with gr.Accordion("์ถ๋ก ์ต์
", open=False):
|
| 37 |
with gr.Row():
|
| 38 |
temperature = gr.Slider(
|
| 39 |
minimum=0.0,
|
|
|
|
| 54 |
elem_id="title-proofread-run-btn",
|
| 55 |
)
|
| 56 |
|
| 57 |
+
# โโโ ๊ฒฐ๊ณผ โ ๋จ์ผ ์ปฌ๋ผ โโโ
|
| 58 |
+
output = gr.Textbox(label="๊ต์ ๊ฒฐ๊ณผ", lines=2, interactive=False)
|
| 59 |
+
diff_html = gr.HTML(label="์๋ณธ ๋๋น diff")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
def _empty():
|
| 62 |
+
return gr.update(value=""), gr.update(value="")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
def _on_run(
|
| 65 |
original_text: str,
|
|
|
|
| 75 |
|
| 76 |
orig_clean = original_text.strip()
|
| 77 |
|
| 78 |
+
result = run_title_proofread(
|
| 79 |
+
client=client,
|
| 80 |
+
original=orig_clean,
|
| 81 |
+
category=DEFAULT_CATEGORY,
|
| 82 |
+
system_prompt=default_system,
|
| 83 |
+
user_template=default_user,
|
| 84 |
+
temperature=temperature_val,
|
| 85 |
+
reasoning_effort=reasoning_effort_val,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
)
|
| 87 |
|
| 88 |
+
if result.get("error"):
|
| 89 |
+
gr.Warning(f"{MODEL} ํธ์ถ ์คํจ: {result['error']}")
|
| 90 |
+
return _empty()
|
| 91 |
+
|
| 92 |
+
out_text = result["output"]
|
| 93 |
+
diff = highlight_diff(orig_clean, out_text) if out_text else ""
|
| 94 |
+
return gr.update(value=out_text), gr.update(value=diff)
|
| 95 |
+
|
| 96 |
run_btn.click(
|
| 97 |
_on_run,
|
| 98 |
inputs=[
|
|
|
|
| 101 |
reasoning_effort,
|
| 102 |
],
|
| 103 |
outputs=[
|
| 104 |
+
output,
|
| 105 |
+
diff_html,
|
|
|
|
|
|
|
| 106 |
],
|
| 107 |
)
|