dev-strender Claude Opus 4.7 (1M context) commited on
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 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๋งŒ9585๊ฑด`, `22๋งŒ8000๋ช…`, `30%`, `2๋ฐฐ`
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 / solar-pro3 ๋น„๊ต์šฉ.
2
 
3
- UI ๊ฐ€ ์‹œ์Šคํ…œยท์œ ์ € ํ”„๋กฌํ”„ํŠธ๋ฅผ ์ง์ ‘ ํŽธ์ง‘ํ•  ์ˆ˜ ์žˆ๋„๋ก prompt ์ธ์ž๋ฅผ ์ „๋ถ€ ์™ธ๋ถ€์—์„œ ๋ฐ›์Œ.
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
- MODELS = ["solar-pro2", "solar-pro3"]
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 ํ˜ธ์ถœ. UI ์—์„œ ๋ชจ๋ธ๋‹น ํ•œ ๋ฒˆ์”ฉ (๋ณ‘๋ ฌ) ํ˜ธ์ถœ.
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": 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": 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 = (resp.choices[0].message.content or "").strip()
 
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": raw,
90
  "user_message": user_msg,
91
- "model": 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
- ์‚ฌ์šฉ์ž์—๊ฒŒ system/user ํ”„๋กฌํ”„ํŠธ์™€ ํ˜ธ์ถœ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ๋ฅผ ๋…ธ์ถœํ•˜์ง€ ์•Š๊ณ ,
4
- ์ž…๋ ฅ ์ œ๋ชฉยท์นดํ…Œ๊ณ ๋ฆฌยท์ถ”๋ก  ์˜ต์…˜๋งŒ ๋ฐ›์•„ solar-pro2 / solar-pro3 ๊ฒฐ๊ณผ๋ฅผ
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 MODELS, load_default_prompts, run_title_proofread
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("์ถ”๋ก  ์˜ต์…˜ (์–‘์ชฝ ๋ชจ๋ธ ๊ณตํ†ต ์ ์šฉ)", open=False):
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
- with gr.Row(equal_height=False):
66
- with gr.Column():
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
- # ๋‘ ๋ชจ๋ธ ๋ณ‘๋ ฌ ํ˜ธ์ถœ (์ด latency = max(pro2, pro3)).
98
- # ์‹œ์Šคํ…œยท์œ ์ € ํ”„๋กฌํ”„ํŠธ๋Š” ๋‚ด๋ถ€ default ๊ณ ์ • โ€” UI ์— ๋…ธ์ถœํ•˜์ง€ ์•Š์Œ.
99
- with ThreadPoolExecutor(max_workers=2) as ex:
100
- futures = {
101
- m: ex.submit(
102
- run_title_proofread,
103
- client=client,
104
- original=orig_clean,
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
- output_pro2,
143
- diff_pro2,
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
  )