Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -89,7 +89,7 @@ def respond(message, history):
|
|
| 89 |
"content": "You are MiniMax-M2.1, a helpful AI assistant built by MiniMax. You excel at coding, tool use, and complex reasoning tasks. Respond in the same language as the user."
|
| 90 |
}]
|
| 91 |
|
| 92 |
-
# Add history
|
| 93 |
for h in history:
|
| 94 |
if isinstance(h, dict):
|
| 95 |
api_messages.append({"role": h.get("role", "user"), "content": h.get("content", "")})
|
|
@@ -121,7 +121,7 @@ def respond(message, history):
|
|
| 121 |
# 2์ฐจ: MiniMax
|
| 122 |
try:
|
| 123 |
if not os.environ.get("MINIMAX_API_KEY"):
|
| 124 |
-
yield "โ Error: MINIMAX_API_KEY not configured."
|
| 125 |
return
|
| 126 |
|
| 127 |
for chunk in chat_with_minimax(api_messages):
|
|
@@ -135,69 +135,41 @@ def respond(message, history):
|
|
| 135 |
yield f"โ Error: {str(e)}"
|
| 136 |
|
| 137 |
# ============================================
|
| 138 |
-
#
|
| 139 |
# ============================================
|
| 140 |
-
|
|
|
|
| 141 |
@import url('https://fonts.googleapis.com/css2?family=Bangers&family=Comic+Neue:wght@400;700&display=swap');
|
| 142 |
|
| 143 |
.gradio-container {
|
| 144 |
background-color: #FEF9C3 !important;
|
| 145 |
background-image: radial-gradient(#1F2937 1px, transparent 1px) !important;
|
| 146 |
background-size: 20px 20px !important;
|
| 147 |
-
min-height: 100vh !important;
|
| 148 |
font-family: 'Comic Neue', cursive, sans-serif !important;
|
| 149 |
}
|
| 150 |
|
| 151 |
-
|
| 152 |
-
display: none !important;
|
| 153 |
-
}
|
| 154 |
-
|
| 155 |
-
footer, .footer, .gradio-footer, .built-with-gradio {
|
| 156 |
-
display: none !important;
|
| 157 |
-
}
|
| 158 |
|
| 159 |
h1 {
|
| 160 |
font-family: 'Bangers', cursive !important;
|
| 161 |
color: #1F2937 !important;
|
| 162 |
-
font-size: 3rem !important;
|
| 163 |
-
text-align: center !important;
|
| 164 |
text-shadow: 4px 4px 0px #FACC15, 6px 6px 0px #1F2937 !important;
|
| 165 |
letter-spacing: 3px !important;
|
| 166 |
}
|
| 167 |
|
| 168 |
-
|
| 169 |
-
background: #FFFFFF !important;
|
| 170 |
-
border: 3px solid #1F2937 !important;
|
| 171 |
-
border-radius: 12px !important;
|
| 172 |
-
box-shadow: 6px 6px 0px #1F2937 !important;
|
| 173 |
-
}
|
| 174 |
-
|
| 175 |
-
textarea, input[type="text"] {
|
| 176 |
-
background: #FFFFFF !important;
|
| 177 |
border: 3px solid #1F2937 !important;
|
| 178 |
border-radius: 8px !important;
|
| 179 |
-
color: #1F2937 !important;
|
| 180 |
font-family: 'Comic Neue', cursive !important;
|
| 181 |
-
font-size: 1rem !important;
|
| 182 |
-
font-weight: 700 !important;
|
| 183 |
-
}
|
| 184 |
-
|
| 185 |
-
textarea:focus, input[type="text"]:focus {
|
| 186 |
-
border-color: #3B82F6 !important;
|
| 187 |
-
box-shadow: 4px 4px 0px #3B82F6 !important;
|
| 188 |
-
outline: none !important;
|
| 189 |
}
|
| 190 |
|
| 191 |
button {
|
| 192 |
background: #3B82F6 !important;
|
| 193 |
border: 3px solid #1F2937 !important;
|
| 194 |
border-radius: 8px !important;
|
| 195 |
-
color:
|
| 196 |
font-family: 'Bangers', cursive !important;
|
| 197 |
-
font-size: 1.1rem !important;
|
| 198 |
-
letter-spacing: 2px !important;
|
| 199 |
box-shadow: 4px 4px 0px #1F2937 !important;
|
| 200 |
-
text-shadow: 1px 1px 0px #1F2937 !important;
|
| 201 |
}
|
| 202 |
|
| 203 |
button:hover {
|
|
@@ -206,74 +178,27 @@ button:hover {
|
|
| 206 |
box-shadow: 6px 6px 0px #1F2937 !important;
|
| 207 |
}
|
| 208 |
|
| 209 |
-
|
| 210 |
-
transform: translate(2px, 2px) !important;
|
| 211 |
-
box-shadow: 2px 2px 0px #1F2937 !important;
|
| 212 |
-
}
|
| 213 |
-
|
| 214 |
-
.secondary {
|
| 215 |
-
background: #EF4444 !important;
|
| 216 |
-
}
|
| 217 |
-
|
| 218 |
-
.secondary:hover {
|
| 219 |
-
background: #DC2626 !important;
|
| 220 |
-
}
|
| 221 |
-
|
| 222 |
-
.gr-panel, .gr-box, .block, .gr-group {
|
| 223 |
-
background: #FFFFFF !important;
|
| 224 |
-
border: 3px solid #1F2937 !important;
|
| 225 |
-
border-radius: 8px !important;
|
| 226 |
-
box-shadow: 6px 6px 0px #1F2937 !important;
|
| 227 |
-
}
|
| 228 |
-
|
| 229 |
-
.gr-accordion {
|
| 230 |
-
background: #FACC15 !important;
|
| 231 |
-
border: 3px solid #1F2937 !important;
|
| 232 |
-
border-radius: 8px !important;
|
| 233 |
-
box-shadow: 4px 4px 0px #1F2937 !important;
|
| 234 |
-
}
|
| 235 |
-
|
| 236 |
-
.model-info {
|
| 237 |
-
background: linear-gradient(135deg, #3B82F6 0%, #8B5CF6 100%) !important;
|
| 238 |
border: 3px solid #1F2937 !important;
|
| 239 |
border-radius: 12px !important;
|
| 240 |
-
|
| 241 |
-
color: white !important;
|
| 242 |
-
box-shadow: 5px 5px 0px #1F2937 !important;
|
| 243 |
-
margin: 20px 0 !important;
|
| 244 |
}
|
| 245 |
|
| 246 |
pre, code {
|
| 247 |
background: #1F2937 !important;
|
| 248 |
color: #10B981 !important;
|
| 249 |
-
border: 2px solid #10B981 !important;
|
| 250 |
border-radius: 6px !important;
|
| 251 |
-
font-family: 'Courier New', monospace !important;
|
| 252 |
-
}
|
| 253 |
-
|
| 254 |
-
::-webkit-scrollbar { width: 12px; }
|
| 255 |
-
::-webkit-scrollbar-track { background: #FEF9C3; border: 2px solid #1F2937; }
|
| 256 |
-
::-webkit-scrollbar-thumb { background: #3B82F6; border: 2px solid #1F2937; }
|
| 257 |
-
::-webkit-scrollbar-thumb:hover { background: #EF4444; }
|
| 258 |
-
|
| 259 |
-
@media (max-width: 768px) {
|
| 260 |
-
h1 { font-size: 2rem !important; }
|
| 261 |
}
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
# ============================================
|
| 265 |
-
# Gradio ChatInterface (Simple & Compatible)
|
| 266 |
-
# ============================================
|
| 267 |
|
| 268 |
-
# Header HTML
|
| 269 |
-
header_html = """
|
| 270 |
<div style="text-align: center; margin: 10px 0;">
|
| 271 |
-
<a href="https://www.humangen.ai" target="_blank"
|
| 272 |
<img src="https://img.shields.io/static/v1?label=๐ HOME&message=HUMANGEN.AI&color=0000ff&labelColor=ffcc00&style=for-the-badge" alt="HOME">
|
| 273 |
</a>
|
| 274 |
|
| 275 |
</div>
|
| 276 |
-
|
|
|
|
| 277 |
<div style="display: flex; justify-content: space-around; flex-wrap: wrap; text-align: center;">
|
| 278 |
<div><strong style="font-size: 1.5rem;">230B</strong><br><span style="font-size: 0.9rem;">Total Params</span></div>
|
| 279 |
<div><strong style="font-size: 1.5rem;">10B</strong><br><span style="font-size: 0.9rem;">Active Params</span></div>
|
|
@@ -281,9 +206,15 @@ header_html = """
|
|
| 281 |
<div><strong style="font-size: 1.5rem;">#1</strong><br><span style="font-size: 0.9rem;">Open Source</span></div>
|
| 282 |
</div>
|
| 283 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 284 |
"""
|
| 285 |
|
|
|
|
| 286 |
# Create ChatInterface
|
|
|
|
| 287 |
demo = gr.ChatInterface(
|
| 288 |
fn=respond,
|
| 289 |
title="๐ค MINIMAX-M2.1 CHAT ๐ฌ",
|
|
@@ -295,7 +226,6 @@ demo = gr.ChatInterface(
|
|
| 295 |
"FastAPI๋ก JWT ์ธ์ฆ ๊ตฌํํด์ค",
|
| 296 |
"๋จธ์ ๋ฌ๋ ๋ชจ๋ธ ๋ฐฐํฌ ํ์ดํ๋ผ์ธ์ ์ค๊ณํด์ค",
|
| 297 |
],
|
| 298 |
-
css=css,
|
| 299 |
theme=gr.themes.Soft(),
|
| 300 |
)
|
| 301 |
|
|
|
|
| 89 |
"content": "You are MiniMax-M2.1, a helpful AI assistant built by MiniMax. You excel at coding, tool use, and complex reasoning tasks. Respond in the same language as the user."
|
| 90 |
}]
|
| 91 |
|
| 92 |
+
# Add history (handle both dict and tuple formats)
|
| 93 |
for h in history:
|
| 94 |
if isinstance(h, dict):
|
| 95 |
api_messages.append({"role": h.get("role", "user"), "content": h.get("content", "")})
|
|
|
|
| 121 |
# 2์ฐจ: MiniMax
|
| 122 |
try:
|
| 123 |
if not os.environ.get("MINIMAX_API_KEY"):
|
| 124 |
+
yield "โ Error: MINIMAX_API_KEY not configured. Please add it to Space Secrets."
|
| 125 |
return
|
| 126 |
|
| 127 |
for chunk in chat_with_minimax(api_messages):
|
|
|
|
| 135 |
yield f"โ Error: {str(e)}"
|
| 136 |
|
| 137 |
# ============================================
|
| 138 |
+
# Header HTML with embedded styles
|
| 139 |
# ============================================
|
| 140 |
+
header_html = """
|
| 141 |
+
<style>
|
| 142 |
@import url('https://fonts.googleapis.com/css2?family=Bangers&family=Comic+Neue:wght@400;700&display=swap');
|
| 143 |
|
| 144 |
.gradio-container {
|
| 145 |
background-color: #FEF9C3 !important;
|
| 146 |
background-image: radial-gradient(#1F2937 1px, transparent 1px) !important;
|
| 147 |
background-size: 20px 20px !important;
|
|
|
|
| 148 |
font-family: 'Comic Neue', cursive, sans-serif !important;
|
| 149 |
}
|
| 150 |
|
| 151 |
+
footer { display: none !important; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
|
| 153 |
h1 {
|
| 154 |
font-family: 'Bangers', cursive !important;
|
| 155 |
color: #1F2937 !important;
|
|
|
|
|
|
|
| 156 |
text-shadow: 4px 4px 0px #FACC15, 6px 6px 0px #1F2937 !important;
|
| 157 |
letter-spacing: 3px !important;
|
| 158 |
}
|
| 159 |
|
| 160 |
+
textarea {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
border: 3px solid #1F2937 !important;
|
| 162 |
border-radius: 8px !important;
|
|
|
|
| 163 |
font-family: 'Comic Neue', cursive !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
}
|
| 165 |
|
| 166 |
button {
|
| 167 |
background: #3B82F6 !important;
|
| 168 |
border: 3px solid #1F2937 !important;
|
| 169 |
border-radius: 8px !important;
|
| 170 |
+
color: white !important;
|
| 171 |
font-family: 'Bangers', cursive !important;
|
|
|
|
|
|
|
| 172 |
box-shadow: 4px 4px 0px #1F2937 !important;
|
|
|
|
| 173 |
}
|
| 174 |
|
| 175 |
button:hover {
|
|
|
|
| 178 |
box-shadow: 6px 6px 0px #1F2937 !important;
|
| 179 |
}
|
| 180 |
|
| 181 |
+
.chatbot {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
border: 3px solid #1F2937 !important;
|
| 183 |
border-radius: 12px !important;
|
| 184 |
+
box-shadow: 6px 6px 0px #1F2937 !important;
|
|
|
|
|
|
|
|
|
|
| 185 |
}
|
| 186 |
|
| 187 |
pre, code {
|
| 188 |
background: #1F2937 !important;
|
| 189 |
color: #10B981 !important;
|
|
|
|
| 190 |
border-radius: 6px !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
}
|
| 192 |
+
</style>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
|
|
|
|
|
|
|
| 194 |
<div style="text-align: center; margin: 10px 0;">
|
| 195 |
+
<a href="https://www.humangen.ai" target="_blank">
|
| 196 |
<img src="https://img.shields.io/static/v1?label=๐ HOME&message=HUMANGEN.AI&color=0000ff&labelColor=ffcc00&style=for-the-badge" alt="HOME">
|
| 197 |
</a>
|
| 198 |
|
| 199 |
</div>
|
| 200 |
+
|
| 201 |
+
<div style="background: linear-gradient(135deg, #3B82F6, #8B5CF6); border: 3px solid #1F2937; border-radius: 12px; padding: 15px; color: white; box-shadow: 5px 5px 0px #1F2937; margin: 15px 0;">
|
| 202 |
<div style="display: flex; justify-content: space-around; flex-wrap: wrap; text-align: center;">
|
| 203 |
<div><strong style="font-size: 1.5rem;">230B</strong><br><span style="font-size: 0.9rem;">Total Params</span></div>
|
| 204 |
<div><strong style="font-size: 1.5rem;">10B</strong><br><span style="font-size: 0.9rem;">Active Params</span></div>
|
|
|
|
| 206 |
<div><strong style="font-size: 1.5rem;">#1</strong><br><span style="font-size: 0.9rem;">Open Source</span></div>
|
| 207 |
</div>
|
| 208 |
</div>
|
| 209 |
+
|
| 210 |
+
<p style="text-align: center; font-family: 'Comic Neue', sans-serif; font-weight: bold; color: #1F2937;">
|
| 211 |
+
โก Claude Sonnet 4.5 ์์ค์ ์ฝ๋ฉ & ์์ด์ ํธ ์ฑ๋ฅ! | ๐ Novita ํฌ๋ ๋ง ์์ง ์ MiniMax API๋ก ์๋ ์ ํ
|
| 212 |
+
</p>
|
| 213 |
"""
|
| 214 |
|
| 215 |
+
# ============================================
|
| 216 |
# Create ChatInterface
|
| 217 |
+
# ============================================
|
| 218 |
demo = gr.ChatInterface(
|
| 219 |
fn=respond,
|
| 220 |
title="๐ค MINIMAX-M2.1 CHAT ๐ฌ",
|
|
|
|
| 226 |
"FastAPI๋ก JWT ์ธ์ฆ ๊ตฌํํด์ค",
|
| 227 |
"๋จธ์ ๋ฌ๋ ๋ชจ๋ธ ๋ฐฐํฌ ํ์ดํ๋ผ์ธ์ ์ค๊ณํด์ค",
|
| 228 |
],
|
|
|
|
| 229 |
theme=gr.themes.Soft(),
|
| 230 |
)
|
| 231 |
|