Kim Juwon
commited on
Commit
Β·
9b89e2b
1
Parent(s):
4cee86c
update UI/UX
Browse files
app.py
CHANGED
|
@@ -88,22 +88,128 @@ For information on how to customize the ChatInterface, peruse the gradio docs: h
|
|
| 88 |
custom_css = """
|
| 89 |
.gradio-container {
|
| 90 |
font-family: 'Helvetica Neue', Arial, sans-serif;
|
|
|
|
|
|
|
|
|
|
| 91 |
}
|
|
|
|
| 92 |
.container {
|
| 93 |
max-width: 800px;
|
| 94 |
margin: auto;
|
| 95 |
padding: 20px;
|
| 96 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
.chat-message {
|
| 98 |
-
padding:
|
|
|
|
| 99 |
border-radius: 10px;
|
| 100 |
-
|
|
|
|
|
|
|
|
|
|
| 101 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
.user-message {
|
| 103 |
background-color: #f0f2f5;
|
|
|
|
|
|
|
| 104 |
}
|
|
|
|
|
|
|
| 105 |
.bot-message {
|
| 106 |
background-color: #e3f2fd;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
}
|
| 108 |
"""
|
| 109 |
|
|
@@ -117,23 +223,27 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 117 |
|
| 118 |
with gr.Row():
|
| 119 |
with gr.Column(scale=2):
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
|
| 135 |
with gr.Column(scale=1):
|
| 136 |
-
with gr.Group():
|
| 137 |
gr.Markdown("### π― μΆμ² μ€μ ")
|
| 138 |
genre = gr.Dropdown(
|
| 139 |
choices=["μ‘μ
", "μ½λ―Έλ", "λλΌλ§", "λ‘맨μ€", "μ€λ¦΄λ¬", "SF", "ννμ§", "μ λλ©μ΄μ
"],
|
|
@@ -146,7 +256,7 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 146 |
multiselect=True
|
| 147 |
)
|
| 148 |
|
| 149 |
-
with gr.Group():
|
| 150 |
gr.Markdown("### π€ Agent μ€μ ")
|
| 151 |
agent_type = gr.Dropdown(
|
| 152 |
choices=["μ λ¬Έκ°", "μΉκ΅¬", "μν νλ‘ κ°", "νλ μ΄ν°"],
|
|
@@ -169,7 +279,7 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 169 |
value="νκ΅μ΄"
|
| 170 |
)
|
| 171 |
|
| 172 |
-
with gr.Group():
|
| 173 |
gr.Markdown("### βοΈ κ³ κΈ μ€μ ")
|
| 174 |
max_tokens = gr.Slider(
|
| 175 |
minimum=1,
|
|
@@ -197,7 +307,8 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 197 |
settings_modal = gr.Modal(
|
| 198 |
title="μ€μ μ΄ λ³κ²½λμμ΅λλ€",
|
| 199 |
visible=False,
|
| 200 |
-
interactive=False
|
|
|
|
| 201 |
)
|
| 202 |
|
| 203 |
# μ€μ λ³κ²½ μ μ±ν
μ΄κΈ°ν λ° Modal νμ
|
|
|
|
| 88 |
custom_css = """
|
| 89 |
.gradio-container {
|
| 90 |
font-family: 'Helvetica Neue', Arial, sans-serif;
|
| 91 |
+
max-width: 1200px;
|
| 92 |
+
margin: auto;
|
| 93 |
+
padding: 20px;
|
| 94 |
}
|
| 95 |
+
|
| 96 |
.container {
|
| 97 |
max-width: 800px;
|
| 98 |
margin: auto;
|
| 99 |
padding: 20px;
|
| 100 |
}
|
| 101 |
+
|
| 102 |
+
/* μ±ν
컨ν
μ΄λ μ€νμΌ */
|
| 103 |
+
.chat-container {
|
| 104 |
+
display: flex;
|
| 105 |
+
flex-direction: column;
|
| 106 |
+
height: 100%;
|
| 107 |
+
background: #ffffff;
|
| 108 |
+
border-radius: 10px;
|
| 109 |
+
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
/* μ±ν
λ©μμ§ μ€νμΌ */
|
| 113 |
.chat-message {
|
| 114 |
+
padding: 20px;
|
| 115 |
+
margin: 10px;
|
| 116 |
border-radius: 10px;
|
| 117 |
+
max-width: 85%;
|
| 118 |
+
line-height: 1.5;
|
| 119 |
+
position: relative;
|
| 120 |
+
animation: fadeIn 0.3s ease-in-out;
|
| 121 |
}
|
| 122 |
+
|
| 123 |
+
@keyframes fadeIn {
|
| 124 |
+
from { opacity: 0; transform: translateY(10px); }
|
| 125 |
+
to { opacity: 1; transform: translateY(0); }
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
/* μ¬μ©μ λ©μμ§ μ€νμΌ */
|
| 129 |
.user-message {
|
| 130 |
background-color: #f0f2f5;
|
| 131 |
+
margin-left: auto;
|
| 132 |
+
border-bottom-right-radius: 0;
|
| 133 |
}
|
| 134 |
+
|
| 135 |
+
/* λ΄ λ©μμ§ μ€νμΌ */
|
| 136 |
.bot-message {
|
| 137 |
background-color: #e3f2fd;
|
| 138 |
+
margin-right: auto;
|
| 139 |
+
border-bottom-left-radius: 0;
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
/* μ
λ ₯ μμ μ€νμΌ */
|
| 143 |
+
.input-container {
|
| 144 |
+
display: flex;
|
| 145 |
+
gap: 10px;
|
| 146 |
+
padding: 20px;
|
| 147 |
+
background: #ffffff;
|
| 148 |
+
border-top: 1px solid #e0e0e0;
|
| 149 |
+
position: sticky;
|
| 150 |
+
bottom: 0;
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
/* μ
λ ₯ νλ μ€νμΌ */
|
| 154 |
+
input[type="text"] {
|
| 155 |
+
flex: 1;
|
| 156 |
+
padding: 12px;
|
| 157 |
+
border: 1px solid #e0e0e0;
|
| 158 |
+
border-radius: 8px;
|
| 159 |
+
font-size: 16px;
|
| 160 |
+
transition: border-color 0.3s ease;
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
input[type="text"]:focus {
|
| 164 |
+
border-color: #2196f3;
|
| 165 |
+
outline: none;
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
/* λ²νΌ μ€νμΌ */
|
| 169 |
+
button {
|
| 170 |
+
padding: 12px 24px;
|
| 171 |
+
border: none;
|
| 172 |
+
border-radius: 8px;
|
| 173 |
+
background-color: #2196f3;
|
| 174 |
+
color: white;
|
| 175 |
+
font-weight: 600;
|
| 176 |
+
cursor: pointer;
|
| 177 |
+
transition: background-color 0.3s ease;
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
button:hover {
|
| 181 |
+
background-color: #1976d2;
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
/* μ€μ ν¨λ μ€νμΌ */
|
| 185 |
+
.settings-panel {
|
| 186 |
+
background: #ffffff;
|
| 187 |
+
padding: 20px;
|
| 188 |
+
border-radius: 10px;
|
| 189 |
+
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
/* λλ‘λ€μ΄ μ€νμΌ */
|
| 193 |
+
select {
|
| 194 |
+
width: 100%;
|
| 195 |
+
padding: 8px;
|
| 196 |
+
border: 1px solid #e0e0e0;
|
| 197 |
+
border-radius: 6px;
|
| 198 |
+
margin-bottom: 10px;
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
/* μ¬λΌμ΄λ μ€νμΌ */
|
| 202 |
+
input[type="range"] {
|
| 203 |
+
width: 100%;
|
| 204 |
+
margin: 10px 0;
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
/* λͺ¨λ¬ μ€νμΌ */
|
| 208 |
+
.modal {
|
| 209 |
+
background: #ffffff;
|
| 210 |
+
border-radius: 10px;
|
| 211 |
+
padding: 20px;
|
| 212 |
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
| 213 |
}
|
| 214 |
"""
|
| 215 |
|
|
|
|
| 223 |
|
| 224 |
with gr.Row():
|
| 225 |
with gr.Column(scale=2):
|
| 226 |
+
with gr.Group(elem_classes="chat-container"):
|
| 227 |
+
chatbot = gr.Chatbot(
|
| 228 |
+
height=600,
|
| 229 |
+
show_copy_button=True,
|
| 230 |
+
avatar_images=("π€", "π¬"),
|
| 231 |
+
bubble_full_width=False,
|
| 232 |
+
elem_classes=["chat-message"],
|
| 233 |
+
)
|
| 234 |
+
with gr.Group(elem_classes="input-container"):
|
| 235 |
+
msg = gr.Textbox(
|
| 236 |
+
placeholder="μ΄λ€ μνλ₯Ό μ°Ύκ³ κ³μ κ°μ?",
|
| 237 |
+
show_label=False,
|
| 238 |
+
container=False,
|
| 239 |
+
scale=8
|
| 240 |
+
)
|
| 241 |
+
with gr.Row(scale=2):
|
| 242 |
+
submit = gr.Button("μΆμ² λ°κΈ°", variant="primary", size="sm")
|
| 243 |
+
clear = gr.Button("λν μ΄κΈ°ν", size="sm")
|
| 244 |
|
| 245 |
with gr.Column(scale=1):
|
| 246 |
+
with gr.Group(elem_classes="settings-panel"):
|
| 247 |
gr.Markdown("### π― μΆμ² μ€μ ")
|
| 248 |
genre = gr.Dropdown(
|
| 249 |
choices=["μ‘μ
", "μ½λ―Έλ", "λλΌλ§", "λ‘맨μ€", "μ€λ¦΄λ¬", "SF", "ννμ§", "μ λλ©μ΄μ
"],
|
|
|
|
| 256 |
multiselect=True
|
| 257 |
)
|
| 258 |
|
| 259 |
+
with gr.Group(elem_classes="settings-panel"):
|
| 260 |
gr.Markdown("### π€ Agent μ€μ ")
|
| 261 |
agent_type = gr.Dropdown(
|
| 262 |
choices=["μ λ¬Έκ°", "μΉκ΅¬", "μν νλ‘ κ°", "νλ μ΄ν°"],
|
|
|
|
| 279 |
value="νκ΅μ΄"
|
| 280 |
)
|
| 281 |
|
| 282 |
+
with gr.Group(elem_classes="settings-panel"):
|
| 283 |
gr.Markdown("### βοΈ κ³ κΈ μ€μ ")
|
| 284 |
max_tokens = gr.Slider(
|
| 285 |
minimum=1,
|
|
|
|
| 307 |
settings_modal = gr.Modal(
|
| 308 |
title="μ€μ μ΄ λ³κ²½λμμ΅λλ€",
|
| 309 |
visible=False,
|
| 310 |
+
interactive=False,
|
| 311 |
+
elem_classes="modal"
|
| 312 |
)
|
| 313 |
|
| 314 |
# μ€μ λ³κ²½ μ μ±ν
μ΄κΈ°ν λ° Modal νμ
|