Spaces:
Sleeping
Sleeping
ใ
ใ
ใ
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- 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 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 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():
|