Spaces:
Sleeping

dev-strender commited on
Commit
6095079
ยท
1 Parent(s): 9c4997d

Limit input to 500 chars (UI cap + handler validation)

Browse files
Files changed (1) hide show
  1. blindtest/ui.py +13 -2
blindtest/ui.py CHANGED
@@ -48,10 +48,13 @@ def build_feedback_tab(
48
 
49
  pipeline_run_id_state = gr.State(None)
50
 
 
 
51
  input_text = gr.Textbox(
52
- label="์›๋ฌธ ์ž…๋ ฅ",
53
  lines=8,
54
- placeholder="๊ต์ •ํ•  ํ…์ŠคํŠธ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”.",
 
55
  )
56
 
57
  run_btn = gr.Button(
@@ -84,6 +87,14 @@ def build_feedback_tab(
84
  None,
85
  gr.update(value=""),
86
  )
 
 
 
 
 
 
 
 
87
  if client is None:
88
  return (
89
  gr.update(value="UPSTAGE_API_KEY ๋ฏธ์„ค์ •."),
 
48
 
49
  pipeline_run_id_state = gr.State(None)
50
 
51
+ MAX_CHARS = 500
52
+
53
  input_text = gr.Textbox(
54
+ label=f"์›๋ฌธ ์ž…๋ ฅ (์ตœ๋Œ€ {MAX_CHARS}์ž)",
55
  lines=8,
56
+ placeholder=f"๊ต์ •ํ•  ํ…์ŠคํŠธ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”. ({MAX_CHARS}์ž ์ด๋‚ด)",
57
+ max_length=MAX_CHARS,
58
  )
59
 
60
  run_btn = gr.Button(
 
87
  None,
88
  gr.update(value=""),
89
  )
90
+ if len(text) > MAX_CHARS:
91
+ return (
92
+ gr.update(value=f"์ž…๋ ฅ์ด {MAX_CHARS}์ž๋ฅผ ์ดˆ๊ณผํ–ˆ์Šต๋‹ˆ๋‹ค ({len(text)}์ž). ์ค„์—ฌ์„œ ๋‹ค์‹œ ์‹œ๋„ํ•ด์ฃผ์„ธ์š”."),
93
+ gr.update(value=""),
94
+ gr.update(value=""),
95
+ None,
96
+ gr.update(value=""),
97
+ )
98
  if client is None:
99
  return (
100
  gr.update(value="UPSTAGE_API_KEY ๋ฏธ์„ค์ •."),