ใ……ใ…Žใ…‡ commited on
Commit
1ffb9f7
ยท
1 Parent(s): 89d4719

Fix: Increase Session ID input width and add clear chat button - Add CSS to increase Session ID input min-width to 800px - Add scale=10 to Session ID Textbox in Row - Add clear chat button using chatbot_interface.chatbot_value - Follow official documentation pattern

Browse files
Files changed (1) hide show
  1. CodeWeaver/ui/app.py +31 -6
CodeWeaver/ui/app.py CHANGED
@@ -45,6 +45,12 @@ CSS = """
45
  padding-top: 1.5rem;
46
  }
47
  .message { font-size: 1.1rem; line-height: 1.6; }
 
 
 
 
 
 
48
  """
49
 
50
 
@@ -134,12 +140,14 @@ def create_demo() -> gr.Blocks:
134
  """)
135
 
136
  # 2. Session ID ์ž…๋ ฅ์ฐฝ
137
- session_id_input = gr.Textbox(
138
- label="Session ID (์ด ID๊ฐ€ ๊ฐ™์œผ๋ฉด ๋Œ€ํ™”๊ฐ€ ์œ ์ง€๋ฉ๋‹ˆ๋‹ค)",
139
- value=str(uuid.uuid4()),
140
- interactive=True,
141
- placeholder="์„ธ์…˜ ID๋ฅผ ์ž…๋ ฅํ•˜๊ฑฐ๋‚˜ ๊ทธ๋Œ€๋กœ ๋‘์„ธ์š”"
142
- )
 
 
143
 
144
  # 3. ์ฑ„ํŒ… ์ธํ„ฐํŽ˜์ด์Šค
145
  # Chatbot ๊ฐ์ฒด๋ฅผ ๋จผ์ € ์ƒ์„ฑํ•˜์—ฌ clear ์ด๋ฒคํŠธ๋ฅผ ๋ฐ”์ธ๋”ฉ
@@ -160,6 +168,23 @@ def create_demo() -> gr.Blocks:
160
  additional_inputs=[session_id_input],
161
  )
162
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
  # 4. ์˜ˆ์‹œ ์งˆ๋ฌธ
164
  gr.Markdown("### ๐Ÿ’ก ์ถ”์ฒœ ์งˆ๋ฌธ ์˜ˆ์‹œ")
165
  with gr.Row():
 
45
  padding-top: 1.5rem;
46
  }
47
  .message { font-size: 1.1rem; line-height: 1.6; }
48
+ /* Session ID ์ž…๋ ฅ ํ•„๋“œ ํฌ๊ธฐ ์กฐ์ • */
49
+ input[type="text"][placeholder*="์„ธ์…˜ ID"],
50
+ textarea[placeholder*="์„ธ์…˜ ID"] {
51
+ min-width: 800px !important;
52
+ width: 100% !important;
53
+ }
54
  """
55
 
56
 
 
140
  """)
141
 
142
  # 2. Session ID ์ž…๋ ฅ์ฐฝ
143
+ with gr.Row():
144
+ session_id_input = gr.Textbox(
145
+ label="Session ID (์ด ID๊ฐ€ ๊ฐ™์œผ๋ฉด ๋Œ€ํ™”๊ฐ€ ์œ ์ง€๋ฉ๋‹ˆ๋‹ค)",
146
+ value=str(uuid.uuid4()),
147
+ interactive=True,
148
+ placeholder="์„ธ์…˜ ID๋ฅผ ์ž…๋ ฅํ•˜๊ฑฐ๋‚˜ ๊ทธ๋Œ€๋กœ ๋‘์„ธ์š”",
149
+ scale=10
150
+ )
151
 
152
  # 3. ์ฑ„ํŒ… ์ธํ„ฐํŽ˜์ด์Šค
153
  # Chatbot ๊ฐ์ฒด๋ฅผ ๋จผ์ € ์ƒ์„ฑํ•˜์—ฌ clear ์ด๋ฒคํŠธ๋ฅผ ๋ฐ”์ธ๋”ฉ
 
168
  additional_inputs=[session_id_input],
169
  )
170
 
171
+ # ๋Œ€ํ™” ์ดˆ๊ธฐํ™” ๋ฒ„ํŠผ ์ถ”๊ฐ€ (๊ณต์‹ ๋ฌธ์„œ: https://www.gradio.app/guides/creating-a-custom-chatbot-with-blocks)
172
+ with gr.Row():
173
+ clear_chat_btn = gr.Button("๐Ÿ—‘๏ธ ๋Œ€ํ™” ์ดˆ๊ธฐํ™”", variant="secondary")
174
+
175
+ def clear_chat_and_reset():
176
+ # ๋Œ€ํ™” ์ดˆ๊ธฐํ™” ๋ฐ ์„ธ์…˜ ID ๋ฆฌ์…‹
177
+ return [], str(uuid.uuid4())
178
+
179
+ # Clear ๋ฒ„ํŠผ ํด๋ฆญ ์‹œ ๋Œ€ํ™”์™€ ์„ธ์…˜ ID ๋ชจ๋‘ ๋ฆฌ์…‹
180
+ # ChatInterface์˜ chatbot_value ์‚ฌ์šฉ (๊ณต์‹ ๋ฌธ์„œ ํŒจํ„ด)
181
+ clear_chat_btn.click(
182
+ clear_chat_and_reset,
183
+ None,
184
+ [chatbot_interface.chatbot_value, session_id_input],
185
+ queue=False
186
+ )
187
+
188
  # 4. ์˜ˆ์‹œ ์งˆ๋ฌธ
189
  gr.Markdown("### ๐Ÿ’ก ์ถ”์ฒœ ์งˆ๋ฌธ ์˜ˆ์‹œ")
190
  with gr.Row():