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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Legion Coder - Hugging Face Space
|
| 3 |
+
A powerful coding assistant powered by the Legion Coder 8M model.
|
| 4 |
+
10k Edition - 2026
|
| 5 |
+
|
| 6 |
+
MADE WITH BY DEATH LEGION
|
| 7 |
+
POWERED BY nvdya-kit
|
| 8 |
+
|
| 9 |
+
2026 DEATH LEGION. All rights reserved.
|
| 10 |
+
"""
|
| 11 |
+
|
| 12 |
+
import os
|
| 13 |
+
import sys
|
| 14 |
+
import torch
|
| 15 |
+
import streamlit as st
|
| 16 |
+
import time
|
| 17 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 18 |
+
|
| 19 |
+
# Page config with custom branding - 10k Edition 2026
|
| 20 |
+
st.set_page_config(
|
| 21 |
+
page_title="Legion Coder 2026 | DEATH LEGION",
|
| 22 |
+
page_icon="https://img.icons8.com/color/48/000000/code.png",
|
| 23 |
+
layout="wide",
|
| 24 |
+
initial_sidebar_state="expanded"
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
# Enhanced Custom CSS with 10k Edition branding - No emojis, professional icons
|
| 28 |
+
st.markdown("""
|
| 29 |
+
<style>
|
| 30 |
+
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600;700&family=Inter:wght@400;500;600;700&family=Orbitron:wght@400;700&display=swap');
|
| 31 |
+
|
| 32 |
+
.main {
|
| 33 |
+
font-family: 'Inter', sans-serif;
|
| 34 |
+
background: linear-gradient(135deg, #0a0a0f 0%, #1a1a2e 50%, #16213e 100%);
|
| 35 |
+
min-height: 100vh;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
.death-legion-banner {
|
| 39 |
+
background: linear-gradient(90deg, #ff0040 0%, #ff6b6b 25%, #7c4dff 75%, #9c27b0 100%);
|
| 40 |
+
background-size: 200% 200%;
|
| 41 |
+
padding: 1rem;
|
| 42 |
+
border-radius: 12px;
|
| 43 |
+
text-align: center;
|
| 44 |
+
margin-bottom: 1rem;
|
| 45 |
+
font-weight: 700;
|
| 46 |
+
font-size: 1.1rem;
|
| 47 |
+
color: white;
|
| 48 |
+
text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
|
| 49 |
+
animation: gradientShift 3s ease infinite, pulse 2s infinite;
|
| 50 |
+
font-family: 'Orbitron', sans-serif;
|
| 51 |
+
letter-spacing: 2px;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
@keyframes gradientShift {
|
| 55 |
+
0% { background-position: 0% 50%; }
|
| 56 |
+
50% { background-position: 100% 50%; }
|
| 57 |
+
100% { background-position: 0% 50%; }
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
.nvdya-banner {
|
| 61 |
+
background: linear-gradient(90deg, #00d4ff 0%, #7c4dff 100%);
|
| 62 |
+
padding: 0.6rem;
|
| 63 |
+
border-radius: 8px;
|
| 64 |
+
text-align: center;
|
| 65 |
+
margin-bottom: 1rem;
|
| 66 |
+
font-weight: 600;
|
| 67 |
+
font-size: 0.95rem;
|
| 68 |
+
color: white;
|
| 69 |
+
font-family: 'Orbitron', sans-serif;
|
| 70 |
+
letter-spacing: 1px;
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
@keyframes pulse {
|
| 74 |
+
0% { box-shadow: 0 0 0 0 rgba(255, 0, 64, 0.4); }
|
| 75 |
+
70% { box-shadow: 0 0 0 15px rgba(255, 0, 64, 0); }
|
| 76 |
+
100% { box-shadow: 0 0 0 0 rgba(255, 0, 64, 0); }
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
.cursor-blink {
|
| 80 |
+
display: inline-block;
|
| 81 |
+
width: 10px;
|
| 82 |
+
height: 1.3em;
|
| 83 |
+
background: linear-gradient(180deg, #ff4081, #ff0040);
|
| 84 |
+
animation: blink 0.8s step-end infinite;
|
| 85 |
+
vertical-align: text-bottom;
|
| 86 |
+
margin-left: 3px;
|
| 87 |
+
border-radius: 2px;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
@keyframes blink {
|
| 91 |
+
0%, 50% { opacity: 1; }
|
| 92 |
+
51%, 100% { opacity: 0; }
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
.header-container {
|
| 96 |
+
background: linear-gradient(90deg, #ff0040 0%, #ff4081 50%, #7c4dff 100%);
|
| 97 |
+
padding: 2.5rem;
|
| 98 |
+
border-radius: 20px;
|
| 99 |
+
margin-bottom: 2rem;
|
| 100 |
+
box-shadow: 0 15px 50px rgba(255, 0, 64, 0.4);
|
| 101 |
+
text-align: center;
|
| 102 |
+
position: relative;
|
| 103 |
+
overflow: hidden;
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
.header-title {
|
| 107 |
+
font-family: 'Orbitron', sans-serif;
|
| 108 |
+
font-size: 3rem;
|
| 109 |
+
font-weight: 700;
|
| 110 |
+
color: #ffffff;
|
| 111 |
+
text-shadow: 3px 3px 6px rgba(0,0,0,0.4);
|
| 112 |
+
margin: 0;
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
.header-subtitle {
|
| 116 |
+
font-size: 1.2rem;
|
| 117 |
+
color: rgba(255,255,255,0.9);
|
| 118 |
+
margin-top: 0.8rem;
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
.sidebar-content {
|
| 122 |
+
padding: 1.5rem 0;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
.sidebar-title {
|
| 126 |
+
font-family: 'Orbitron', sans-serif;
|
| 127 |
+
font-size: 1.3rem;
|
| 128 |
+
font-weight: 700;
|
| 129 |
+
color: #ff4081;
|
| 130 |
+
margin-bottom: 1.5rem;
|
| 131 |
+
text-align: center;
|
| 132 |
+
text-transform: uppercase;
|
| 133 |
+
letter-spacing: 2px;
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
.sidebar-section {
|
| 137 |
+
background: rgba(255,255,255,0.05);
|
| 138 |
+
border-radius: 16px;
|
| 139 |
+
padding: 1.2rem;
|
| 140 |
+
margin-bottom: 1.2rem;
|
| 141 |
+
border: 1px solid rgba(255,255,255,0.1);
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
.sidebar-label {
|
| 145 |
+
font-size: 0.9rem;
|
| 146 |
+
color: rgba(255,255,255,0.7);
|
| 147 |
+
margin-bottom: 0.4rem;
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
.sidebar-value {
|
| 151 |
+
font-family: 'JetBrains Mono', monospace;
|
| 152 |
+
font-size: 1.1rem;
|
| 153 |
+
font-weight: 600;
|
| 154 |
+
color: #ffffff;
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
.downloads-badge {
|
| 158 |
+
background: linear-gradient(135deg, rgba(255,0,64,0.2) 0%, rgba(124,77,255,0.2) 100%);
|
| 159 |
+
border: 2px solid rgba(255,0,64,0.5);
|
| 160 |
+
border-radius: 16px;
|
| 161 |
+
padding: 1.5rem;
|
| 162 |
+
margin-bottom: 1.2rem;
|
| 163 |
+
text-align: center;
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
.downloads-label {
|
| 167 |
+
color: #ff4081;
|
| 168 |
+
font-weight: 700;
|
| 169 |
+
font-size: 0.85rem;
|
| 170 |
+
margin-bottom: 0.5rem;
|
| 171 |
+
font-family: 'Orbitron', sans-serif;
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
.downloads-number {
|
| 175 |
+
font-family: 'JetBrains Mono', monospace;
|
| 176 |
+
font-size: 2.2rem;
|
| 177 |
+
font-weight: 800;
|
| 178 |
+
background: linear-gradient(90deg, #ff0040, #ff6b6b);
|
| 179 |
+
-webkit-background-clip: text;
|
| 180 |
+
-webkit-text-fill-color: transparent;
|
| 181 |
+
margin: 0.5rem 0;
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
.downloads-subtext {
|
| 185 |
+
font-size: 0.75rem;
|
| 186 |
+
color: rgba(255,255,255,0.6);
|
| 187 |
+
margin-top: 0.3rem;
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
.trending-indicator {
|
| 191 |
+
display: inline-flex;
|
| 192 |
+
align-items: center;
|
| 193 |
+
gap: 5px;
|
| 194 |
+
background: rgba(255,0,64,0.2);
|
| 195 |
+
padding: 0.3rem 0.8rem;
|
| 196 |
+
border-radius: 20px;
|
| 197 |
+
font-size: 0.75rem;
|
| 198 |
+
color: #ff4081;
|
| 199 |
+
margin-top: 0.5rem;
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
.trending-dot {
|
| 203 |
+
width: 8px;
|
| 204 |
+
height: 8px;
|
| 205 |
+
background: #ff0040;
|
| 206 |
+
border-radius: 50%;
|
| 207 |
+
animation: pulse-dot 1.5s infinite;
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
@keyframes pulse-dot {
|
| 211 |
+
0%, 100% { opacity: 1; transform: scale(1); }
|
| 212 |
+
50% { opacity: 0.5; transform: scale(1.2); }
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
.deploy-section {
|
| 216 |
+
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
|
| 217 |
+
border: 2px solid rgba(255, 0, 64, 0.4);
|
| 218 |
+
border-radius: 16px;
|
| 219 |
+
padding: 2rem;
|
| 220 |
+
margin: 1.5rem 0;
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
.deploy-title {
|
| 224 |
+
color: #ff4081;
|
| 225 |
+
font-weight: 700;
|
| 226 |
+
font-size: 1.3rem;
|
| 227 |
+
margin-bottom: 1rem;
|
| 228 |
+
font-family: 'Orbitron', sans-serif;
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
.chat-container {
|
| 232 |
+
max-width: 950px;
|
| 233 |
+
margin: 0 auto;
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
.footer {
|
| 237 |
+
text-align: center;
|
| 238 |
+
padding: 2.5rem;
|
| 239 |
+
color: rgba(255,255,255,0.5);
|
| 240 |
+
font-size: 0.9rem;
|
| 241 |
+
border-top: 2px solid rgba(255,255,255,0.1);
|
| 242 |
+
margin-top: 3rem;
|
| 243 |
+
}
|
| 244 |
+
|
| 245 |
+
.footer-brand {
|
| 246 |
+
color: #ff4081;
|
| 247 |
+
font-weight: 700;
|
| 248 |
+
font-family: 'Orbitron', sans-serif;
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
+
.footer-year {
|
| 252 |
+
color: #00d4ff;
|
| 253 |
+
font-weight: 600;
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
.loading-dots:after {
|
| 257 |
+
content: '.';
|
| 258 |
+
animation: dots 1.5s steps(5, end) infinite;
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
@keyframes dots {
|
| 262 |
+
0%, 20% { content: ''; }
|
| 263 |
+
40% { content: '.'; }
|
| 264 |
+
60% { content: '..'; }
|
| 265 |
+
80%, 100% { content: '...'; }
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
.typing-text {
|
| 269 |
+
font-family: 'JetBrains Mono', monospace;
|
| 270 |
+
line-height: 1.6;
|
| 271 |
+
}
|
| 272 |
+
</style>
|
| 273 |
+
""", unsafe_allow_html=True)
|
| 274 |
+
|
| 275 |
+
# Initialize session state
|
| 276 |
+
if "messages" not in st.session_state:
|
| 277 |
+
st.session_state.messages = []
|
| 278 |
+
|
| 279 |
+
# Model configuration - Using verified public repo
|
| 280 |
+
MODEL_ID = "dineth554/legion-coder-8m-10k"
|
| 281 |
+
|
| 282 |
+
# Cache the model loading
|
| 283 |
+
@st.cache_resource
|
| 284 |
+
def load_model():
|
| 285 |
+
"""Load the Legion Coder model and tokenizer."""
|
| 286 |
+
with st.spinner("Loading Legion Coder 8M model..."):
|
| 287 |
+
try:
|
| 288 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID, trust_remote_code=True)
|
| 289 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 290 |
+
MODEL_ID,
|
| 291 |
+
torch_dtype=torch.float32,
|
| 292 |
+
device_map="cpu",
|
| 293 |
+
trust_remote_code=True
|
| 294 |
+
)
|
| 295 |
+
return model, tokenizer
|
| 296 |
+
except Exception as e:
|
| 297 |
+
st.error(f"Error loading model: {e}")
|
| 298 |
+
return None, None
|
| 299 |
+
|
| 300 |
+
# Header
|
| 301 |
+
st.markdown("""
|
| 302 |
+
<div class="header-container">
|
| 303 |
+
<h1 class="header-title">LEGION CODER 2026</h1>
|
| 304 |
+
<p class="header-subtitle">Advanced AI Code Generation by DEATH LEGION</p>
|
| 305 |
+
<div style="margin-top: 0.8rem;">
|
| 306 |
+
<span style="background: rgba(0,0,0,0.3); padding: 0.4rem 1rem; border-radius: 25px; font-size: 0.8rem; font-weight: 600; color: #ff4081; border: 1px solid rgba(255,64,129,0.3);">
|
| 307 |
+
POWERED BY nvdya-kit
|
| 308 |
+
</span>
|
| 309 |
+
</div>
|
| 310 |
+
</div>
|
| 311 |
+
""", unsafe_allow_html=True)
|
| 312 |
+
|
| 313 |
+
# Death Legion Banner
|
| 314 |
+
st.markdown("""
|
| 315 |
+
<div class="death-legion-banner">
|
| 316 |
+
MADE WITH BY DEATH LEGION 2026
|
| 317 |
+
</div>
|
| 318 |
+
""", unsafe_allow_html=True)
|
| 319 |
+
|
| 320 |
+
# nvdya-kit Banner
|
| 321 |
+
st.markdown("""
|
| 322 |
+
<div class="nvdya-banner">
|
| 323 |
+
Powered by nvdya-kit | Next-Gen AI Infrastructure
|
| 324 |
+
</div>
|
| 325 |
+
""", unsafe_allow_html=True)
|
| 326 |
+
|
| 327 |
+
# Sidebar with 10k Edition specs
|
| 328 |
+
with st.sidebar:
|
| 329 |
+
st.markdown("""
|
| 330 |
+
<div class="sidebar-content">
|
| 331 |
+
<div class="sidebar-title">Model Specs 2026</div>
|
| 332 |
+
|
| 333 |
+
<div class="sidebar-section">
|
| 334 |
+
<div class="sidebar-label">[ARCH] Architecture</div>
|
| 335 |
+
<div class="sidebar-value">Transformer 2026</div>
|
| 336 |
+
</div>
|
| 337 |
+
|
| 338 |
+
<div class="sidebar-section">
|
| 339 |
+
<div class="sidebar-label">[PARAMS] Parameters</div>
|
| 340 |
+
<div class="sidebar-value">44,341,632</div>
|
| 341 |
+
</div>
|
| 342 |
+
|
| 343 |
+
<div class="sidebar-section">
|
| 344 |
+
<div class="sidebar-label">[SIZE] Model Size</div>
|
| 345 |
+
<div class="sidebar-value">~170 MB</div>
|
| 346 |
+
</div>
|
| 347 |
+
|
| 348 |
+
<div class="sidebar-section">
|
| 349 |
+
<div class="sidebar-label">[LAYERS] Layers</div>
|
| 350 |
+
<div class="sidebar-value">13</div>
|
| 351 |
+
</div>
|
| 352 |
+
|
| 353 |
+
<div class="sidebar-section">
|
| 354 |
+
<div class="sidebar-label">[HEADS] Attention Heads</div>
|
| 355 |
+
<div class="sidebar-value">16</div>
|
| 356 |
+
</div>
|
| 357 |
+
|
| 358 |
+
<div class="sidebar-section">
|
| 359 |
+
<div class="sidebar-label">[CONTEXT] Context Length</div>
|
| 360 |
+
<div class="sidebar-value">1,024 tokens</div>
|
| 361 |
+
</div>
|
| 362 |
+
|
| 363 |
+
<div class="sidebar-section">
|
| 364 |
+
<div class="sidebar-label">[VOCAB] Vocabulary</div>
|
| 365 |
+
<div class="sidebar-value">16,000 tokens</div>
|
| 366 |
+
</div>
|
| 367 |
+
|
| 368 |
+
<div class="sidebar-section">
|
| 369 |
+
<div class="sidebar-label">[FORMAT] Format</div>
|
| 370 |
+
<div class="sidebar-value">Safetensors</div>
|
| 371 |
+
</div>
|
| 372 |
+
|
| 373 |
+
<div class="sidebar-section">
|
| 374 |
+
<div class="sidebar-label">[YEAR] Release</div>
|
| 375 |
+
<div class="sidebar-value">2026 Edition</div>
|
| 376 |
+
</div>
|
| 377 |
+
|
| 378 |
+
<div class="downloads-badge">
|
| 379 |
+
<div class="downloads-label">10K+ DOWNLOADS MILESTONE</div>
|
| 380 |
+
<div class="downloads-number">10,000+</div>
|
| 381 |
+
<div class="downloads-subtext">Downloads and counting</div>
|
| 382 |
+
<div class="trending-indicator">
|
| 383 |
+
<span class="trending-dot"></span>
|
| 384 |
+
<span>TRENDING</span>
|
| 385 |
+
</div>
|
| 386 |
+
</div>
|
| 387 |
+
</div>
|
| 388 |
+
""", unsafe_allow_html=True)
|
| 389 |
+
|
| 390 |
+
# Deployment section
|
| 391 |
+
st.markdown("""
|
| 392 |
+
<div class="deploy-section">
|
| 393 |
+
<div class="deploy-title">Deploy 2026</div>
|
| 394 |
+
<div style="display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center;">
|
| 395 |
+
<a href="https://huggingface.co/pnny13/legion-coder-8m/deploy/sagemaker"
|
| 396 |
+
style="display: inline-block; background: linear-gradient(90deg, #ff9900 0%, #ff6600 100%);
|
| 397 |
+
color: white; padding: 0.7rem 1.2rem; border-radius: 8px; text-decoration: none;
|
| 398 |
+
font-weight: 600; margin: 0.3rem;">AWS SageMaker</a>
|
| 399 |
+
<a href="https://huggingface.co/pnny13/legion-coder-8m"
|
| 400 |
+
style="display: inline-block; background: linear-gradient(90deg, #ff9900 0%, #ff6600 100%);
|
| 401 |
+
color: white; padding: 0.7rem 1.2rem; border-radius: 8px; text-decoration: none;
|
| 402 |
+
font-weight: 600; margin: 0.3rem;">Model Hub</a>
|
| 403 |
+
</div>
|
| 404 |
+
</div>
|
| 405 |
+
""", unsafe_allow_html=True)
|
| 406 |
+
|
| 407 |
+
# Load model
|
| 408 |
+
model, tokenizer = load_model()
|
| 409 |
+
|
| 410 |
+
if model is None:
|
| 411 |
+
st.error("Failed to load model. Please check the repository configuration.")
|
| 412 |
+
else:
|
| 413 |
+
st.success("Model loaded successfully!")
|
| 414 |
+
|
| 415 |
+
# Main chat interface
|
| 416 |
+
st.markdown("""
|
| 417 |
+
<div class="chat-container">
|
| 418 |
+
<h3 style="color: #ff4081; font-family: 'Orbitron', sans-serif; margin-bottom: 1.5rem;">
|
| 419 |
+
[CHAT] Start Coding
|
| 420 |
+
</h3>
|
| 421 |
+
</div>
|
| 422 |
+
""", unsafe_allow_html=True)
|
| 423 |
+
|
| 424 |
+
# Display chat messages
|
| 425 |
+
for message in st.session_state.messages:
|
| 426 |
+
with st.chat_message(message["role"]):
|
| 427 |
+
st.markdown(message["content"])
|
| 428 |
+
|
| 429 |
+
# Chat input
|
| 430 |
+
if prompt := st.chat_input("Ask Legion Coder to write or explain code..."):
|
| 431 |
+
# Add user message
|
| 432 |
+
st.session_state.messages.append({"role": "user", "content": prompt})
|
| 433 |
+
with st.chat_message("user"):
|
| 434 |
+
st.markdown(prompt)
|
| 435 |
+
|
| 436 |
+
# Generate response with typing animation
|
| 437 |
+
with st.chat_message("assistant"):
|
| 438 |
+
message_placeholder = st.empty()
|
| 439 |
+
|
| 440 |
+
# Typing animation
|
| 441 |
+
with message_placeholder:
|
| 442 |
+
st.markdown("""
|
| 443 |
+
<div style="display: inline-block;">
|
| 444 |
+
<span class="loading-dots">Generating code</span>
|
| 445 |
+
<span class="cursor-blink"></span>
|
| 446 |
+
</div>
|
| 447 |
+
""", unsafe_allow_html=True)
|
| 448 |
+
|
| 449 |
+
if model is not None and tokenizer is not None:
|
| 450 |
+
try:
|
| 451 |
+
# Prepare input
|
| 452 |
+
system_prompt = "You are a helpful coding assistant. Write clean, efficient code."
|
| 453 |
+
full_prompt = f"{system_prompt}\n\nUser: {prompt}\n\nAssistant:"
|
| 454 |
+
|
| 455 |
+
# Tokenize
|
| 456 |
+
inputs = tokenizer(full_prompt, return_tensors="pt", max_length=1024, truncation=True)
|
| 457 |
+
|
| 458 |
+
# Generate
|
| 459 |
+
with torch.no_grad():
|
| 460 |
+
outputs = model.generate(
|
| 461 |
+
inputs["input_ids"],
|
| 462 |
+
max_new_tokens=200,
|
| 463 |
+
temperature=0.8,
|
| 464 |
+
top_p=0.95,
|
| 465 |
+
do_sample=True,
|
| 466 |
+
pad_token_id=tokenizer.eos_token_id
|
| 467 |
+
)
|
| 468 |
+
|
| 469 |
+
# Decode
|
| 470 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 471 |
+
|
| 472 |
+
# Extract just the assistant response
|
| 473 |
+
if "Assistant:" in response:
|
| 474 |
+
response = response.split("Assistant:")[-1].strip()
|
| 475 |
+
|
| 476 |
+
# Simulate typing delay for smooth animation
|
| 477 |
+
time.sleep(0.5)
|
| 478 |
+
|
| 479 |
+
except Exception as e:
|
| 480 |
+
response = f"Error generating response: {str(e)}"
|
| 481 |
+
else:
|
| 482 |
+
# Fallback response if model not loaded
|
| 483 |
+
time.sleep(1)
|
| 484 |
+
response = """Here is a solution for your request:
|
| 485 |
+
|
| 486 |
+
```python
|
| 487 |
+
# Legion Coder 2026 - Generated Code
|
| 488 |
+
# Powered by DEATH LEGION & nvdya-kit
|
| 489 |
+
|
| 490 |
+
def example_function():
|
| 491 |
+
\"\"\"
|
| 492 |
+
This is an example function generated by Legion Coder.
|
| 493 |
+
Replace this with your actual implementation.
|
| 494 |
+
\"\"\"
|
| 495 |
+
pass
|
| 496 |
+
|
| 497 |
+
# TODO: Implement your specific logic here
|
| 498 |
+
if __name__ == "__main__":
|
| 499 |
+
result = example_function()
|
| 500 |
+
print(f"Result: {result}")
|
| 501 |
+
```
|
| 502 |
+
|
| 503 |
+
**Explanation:**
|
| 504 |
+
- This code provides a starting structure for your request
|
| 505 |
+
- Modify the `example_function()` to implement your specific logic
|
| 506 |
+
- The code follows PEP 8 guidelines and best practices
|
| 507 |
+
- Generated by Legion Coder 2026 - DEATH LEGION
|
| 508 |
+
|
| 509 |
+
Would you like me to explain any part of this code or help you implement specific functionality?"""
|
| 510 |
+
|
| 511 |
+
# Display final response with typing effect
|
| 512 |
+
message_placeholder.markdown(f'<div class="typing-text">{response}</div>', unsafe_allow_html=True)
|
| 513 |
+
|
| 514 |
+
# Add assistant message to history
|
| 515 |
+
st.session_state.messages.append({"role": "assistant", "content": response})
|
| 516 |
+
|
| 517 |
+
# Footer with 2026 branding
|
| 518 |
+
st.markdown("""
|
| 519 |
+
<div class="footer">
|
| 520 |
+
<div style="margin-bottom: 0.5rem;">
|
| 521 |
+
<span class="footer-brand">DEATH LEGION</span> |
|
| 522 |
+
<span class="footer-year">2026 Edition</span>
|
| 523 |
+
</div>
|
| 524 |
+
<div>Powered by nvdya-kit | Next-Gen AI Infrastructure</div>
|
| 525 |
+
<div style="margin-top: 0.5rem; font-size: 0.8rem;">
|
| 526 |
+
Legion Coder 8M | 44M Parameters | ~170MB | CPU-Optimized | 10K+ Downloads
|
| 527 |
+
</div>
|
| 528 |
+
</div>
|
| 529 |
+
""", unsafe_allow_html=True)
|