Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
# ================================================================
|
| 2 |
-
# CodeSymb AI โ HuggingFace Space app.py (
|
| 3 |
-
#
|
| 4 |
-
#
|
| 5 |
-
#
|
| 6 |
-
#
|
| 7 |
# NiftyOracleAI ๐ฎ๐ณ | codesymb.com ๐
|
| 8 |
# ================================================================
|
| 9 |
|
|
@@ -26,8 +26,7 @@ if HF_TOKEN:
|
|
| 26 |
login(token=HF_TOKEN)
|
| 27 |
|
| 28 |
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 29 |
-
#
|
| 30 |
-
# (This is why .pt loading works perfectly!)
|
| 31 |
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 32 |
class RMSNorm(nn.Module):
|
| 33 |
def __init__(self, d, eps=1e-6):
|
|
@@ -100,14 +99,14 @@ class Block(nn.Module):
|
|
| 100 |
return x
|
| 101 |
|
| 102 |
class CodeSymb1B(nn.Module):
|
| 103 |
-
"""CodeSymb 1B | NiftyOracleAI ๐ฎ
|
| 104 |
-
def __init__(self):
|
| 105 |
super().__init__()
|
| 106 |
-
DM=2048; DF=8192; NL=16; NH=16; NKV=4
|
| 107 |
-
self.embed = nn.Embedding(
|
| 108 |
self.blocks = nn.ModuleList([Block(DM,DF,NH,NKV) for _ in range(NL)])
|
| 109 |
self.norm = RMSNorm(DM)
|
| 110 |
-
self.head = nn.Linear(DM,
|
| 111 |
def forward(self, tok):
|
| 112 |
x = self.embed(tok).bfloat16()
|
| 113 |
for b in self.blocks:
|
|
@@ -115,55 +114,44 @@ class CodeSymb1B(nn.Module):
|
|
| 115 |
return self.head(self.norm(x))
|
| 116 |
|
| 117 |
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 118 |
-
# LOAD
|
| 119 |
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 120 |
print("โณ Loading CodeSymb-1B tokenizer...")
|
| 121 |
-
tok_path = hf_hub_download(
|
| 122 |
-
TOK_REPO,
|
| 123 |
-
"niftyoracle_tokenizer.model",
|
| 124 |
-
token=HF_TOKEN or None,
|
| 125 |
-
)
|
| 126 |
sp = spm.SentencePieceProcessor()
|
| 127 |
sp.load(tok_path)
|
| 128 |
VOCAB = sp.get_piece_size()
|
| 129 |
print(f"โ
Tokenizer: {VOCAB:,} vocab")
|
| 130 |
|
| 131 |
-
# Special token IDs โ encode them
|
| 132 |
-
SYS_TOKEN = sp.encode("<|system|>")
|
| 133 |
-
USER_TOKEN = sp.encode("<|user|>")
|
| 134 |
-
ASST_TOKEN = sp.encode("<|assistant|>")
|
| 135 |
-
END_TOKEN = sp.encode("<|endoftext|>")
|
| 136 |
-
|
| 137 |
print("โณ Loading CodeSymb-1B model...")
|
| 138 |
-
model = CodeSymb1B()
|
| 139 |
|
| 140 |
-
|
| 141 |
for ckpt_name in ["checkpoints/sft_latest.pt",
|
| 142 |
"checkpoints/latest.pt",
|
| 143 |
"checkpoints/sft_chat_latest.pt"]:
|
| 144 |
try:
|
| 145 |
-
ckpt_path = hf_hub_download(
|
| 146 |
-
|
| 147 |
-
)
|
| 148 |
-
state = torch.load(ckpt_path, map_location="cpu")
|
| 149 |
model_state = state.get("model", state)
|
| 150 |
model.load_state_dict(model_state, strict=False)
|
| 151 |
step = state.get("step", 0)
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
print(f" Step: {step:,} | Loss: {loss:.4f}")
|
| 155 |
break
|
| 156 |
except Exception as e:
|
| 157 |
-
print(f" Not found: {ckpt_name}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
|
| 159 |
model.eval()
|
| 160 |
n_params = sum(p.numel() for p in model.parameters())
|
| 161 |
-
print(f"โ
CodeSymb-1B: {n_params/1e9:.2f}B params")
|
| 162 |
-
print("โ
Model ready! ๐ฅ")
|
| 163 |
|
| 164 |
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 165 |
-
#
|
| 166 |
-
# (Same as what was trained on!)
|
| 167 |
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 168 |
SYSTEM_PROMPT = (
|
| 169 |
"You are CodeSymb, the world's most intelligent, deeply empathetic, "
|
|
@@ -181,59 +169,56 @@ SYSTEM_PROMPT = (
|
|
| 181 |
)
|
| 182 |
|
| 183 |
def build_prompt(message: str, history: list) -> list:
|
| 184 |
-
"""
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
ids += USER_TOKEN
|
| 194 |
-
ids += sp.encode("\n" + str(user_msg) + "\n")
|
| 195 |
-
ids += ASST_TOKEN
|
| 196 |
-
ids += sp.encode("\n" + str(asst_msg) + "\n")
|
| 197 |
-
|
| 198 |
-
# Current message
|
| 199 |
-
ids += USER_TOKEN
|
| 200 |
-
ids += sp.encode("\n" + message + "\n")
|
| 201 |
-
ids += ASST_TOKEN
|
| 202 |
-
ids += sp.encode("\n")
|
| 203 |
|
| 204 |
-
|
|
|
|
|
|
|
|
|
|
| 205 |
|
| 206 |
@spaces.GPU(duration=60)
|
| 207 |
def chat_with_codesymb(message: str, history: list) -> str:
|
| 208 |
-
"""
|
| 209 |
-
Generate response from CodeSymb-1B.
|
| 210 |
-
Loads model to GPU just for this call (ZeroGPU!)
|
| 211 |
-
"""
|
| 212 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 213 |
model.to(device)
|
| 214 |
|
| 215 |
-
# Build prompt tokens
|
| 216 |
prompt_ids = build_prompt(message, history)
|
| 217 |
|
| 218 |
-
# Trim if too long
|
| 219 |
if len(prompt_ids) > 1024:
|
| 220 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
|
| 222 |
inp = torch.tensor([prompt_ids], dtype=torch.long).to(device)
|
| 223 |
|
| 224 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 225 |
generated = []
|
| 226 |
-
MAX_NEW
|
| 227 |
-
END_IDS = set(END_TOKEN + ASST_TOKEN[:1] + USER_TOKEN[:1])
|
| 228 |
|
| 229 |
with torch.no_grad():
|
| 230 |
for _ in range(MAX_NEW):
|
| 231 |
-
with torch.autocast("cuda" if device.type=="cuda" else "cpu",
|
| 232 |
dtype=torch.bfloat16):
|
| 233 |
-
logits = model(inp)[0, -1, :]
|
| 234 |
|
| 235 |
-
# Temperature
|
| 236 |
-
logits = logits / 0.7
|
| 237 |
|
| 238 |
# Top-p (nucleus) sampling
|
| 239 |
sorted_logits, sorted_idx = torch.sort(logits, descending=True)
|
|
@@ -245,8 +230,8 @@ def chat_with_codesymb(message: str, history: list) -> str:
|
|
| 245 |
logits_filtered = torch.zeros_like(logits)
|
| 246 |
logits_filtered.scatter_(0, sorted_idx, sorted_logits)
|
| 247 |
|
| 248 |
-
# Repetition penalty
|
| 249 |
-
if
|
| 250 |
for gid in set(generated[-20:]):
|
| 251 |
if 0 <= gid < logits_filtered.shape[0]:
|
| 252 |
logits_filtered[gid] /= 1.3
|
|
@@ -254,32 +239,32 @@ def chat_with_codesymb(message: str, history: list) -> str:
|
|
| 254 |
probs = F.softmax(logits_filtered, dim=-1)
|
| 255 |
next_t = torch.multinomial(probs, 1).item()
|
| 256 |
|
| 257 |
-
# Stop
|
| 258 |
-
if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 259 |
break
|
| 260 |
-
if len(generated) > 20 and next_t == generated[-1] == generated[-2]:
|
| 261 |
-
break # Stop repetition
|
| 262 |
|
| 263 |
generated.append(next_t)
|
| 264 |
-
|
| 265 |
-
inp = torch.cat([inp, new_tok], dim=1)
|
| 266 |
|
| 267 |
-
# Decode
|
| 268 |
response = sp.decode(generated).strip()
|
| 269 |
|
| 270 |
-
#
|
| 271 |
for tag in ["<|user|>", "<|system|>", "<|assistant|>", "<|endoftext|>"]:
|
| 272 |
response = response.split(tag)[0]
|
| 273 |
-
|
| 274 |
response = response.strip()
|
| 275 |
|
| 276 |
if not response:
|
| 277 |
response = (
|
| 278 |
"I'm CodeSymb, your coding partner! ๐ฅ\n"
|
| 279 |
-
"Built by Deepakkumar Malkar at NiftyOracle ๐ฎ
|
| 280 |
"Ask me anything about code!"
|
| 281 |
)
|
| 282 |
-
|
| 283 |
return response
|
| 284 |
|
| 285 |
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
@@ -287,14 +272,11 @@ def chat_with_codesymb(message: str, history: list) -> str:
|
|
| 287 |
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 288 |
with gr.Blocks(
|
| 289 |
title="CodeSymb AI โ codesymb.com",
|
| 290 |
-
theme=gr.themes.Base(
|
| 291 |
-
primary_hue="blue",
|
| 292 |
-
secondary_hue="indigo",
|
| 293 |
-
),
|
| 294 |
css="""
|
| 295 |
body { background: #060D1F !important; }
|
| 296 |
.gradio-container { max-width: 860px !important; }
|
| 297 |
-
h1 {
|
| 298 |
text-align: center;
|
| 299 |
background: linear-gradient(135deg, #00D4FF, #A855F7);
|
| 300 |
-webkit-background-clip: text;
|
|
@@ -302,26 +284,20 @@ with gr.Blocks(
|
|
| 302 |
font-size: 2.5em !important;
|
| 303 |
font-weight: 900 !important;
|
| 304 |
}
|
| 305 |
-
.subtitle {
|
| 306 |
-
|
| 307 |
-
color: #A0AEC0;
|
| 308 |
-
margin-bottom: 20px;
|
| 309 |
-
font-size: 1.1em;
|
| 310 |
-
}
|
| 311 |
-
"""
|
| 312 |
) as demo:
|
| 313 |
|
| 314 |
gr.HTML("""
|
| 315 |
<h1>โก CodeSymb AI</h1>
|
| 316 |
<p class='subtitle'>
|
| 317 |
World's Most Powerful Coding AI ๐<br>
|
| 318 |
-
Built by <strong>Deepakkumar Malkar</strong>
|
| 319 |
-
at NiftyOracle ๐ฎ๐<br>
|
| 320 |
<em>"Impossible is just a door with no handle yet invented."</em>
|
| 321 |
</p>
|
| 322 |
""")
|
| 323 |
|
| 324 |
-
|
| 325 |
fn=chat_with_codesymb,
|
| 326 |
examples=[
|
| 327 |
["Hi! Who are you and what can you build?"],
|
|
@@ -338,15 +314,9 @@ with gr.Blocks(
|
|
| 338 |
|
| 339 |
gr.HTML("""
|
| 340 |
<div style='text-align:center;padding:20px;color:#4A5568;font-size:13px'>
|
| 341 |
-
<strong>CodeSymb-1B</strong> | 1.08B params |
|
| 342 |
-
|
| 343 |
-
<a href='https://
|
| 344 |
-
codesymb.com
|
| 345 |
-
</a> ๐ |
|
| 346 |
-
<a href='https://huggingface.co/NiftyOracleAI'
|
| 347 |
-
style='color:#1D6FEB'>
|
| 348 |
-
HuggingFace
|
| 349 |
-
</a>
|
| 350 |
</div>
|
| 351 |
""")
|
| 352 |
|
|
|
|
| 1 |
# ================================================================
|
| 2 |
+
# CodeSymb AI โ HuggingFace Space app.py (FINAL v2.0)
|
| 3 |
+
# โ
Single-string tokenization (matches training exactly)
|
| 4 |
+
# โ
Full-sequence stop tags (no more "<" premature death)
|
| 5 |
+
# โ
Vocab size verification
|
| 6 |
+
# โ
Hard fail if no checkpoint (no silent random model)
|
| 7 |
# NiftyOracleAI ๐ฎ๐ณ | codesymb.com ๐
|
| 8 |
# ================================================================
|
| 9 |
|
|
|
|
| 26 |
login(token=HF_TOKEN)
|
| 27 |
|
| 28 |
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 29 |
+
# MODEL ARCHITECTURE (must match training exactly)
|
|
|
|
| 30 |
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 31 |
class RMSNorm(nn.Module):
|
| 32 |
def __init__(self, d, eps=1e-6):
|
|
|
|
| 99 |
return x
|
| 100 |
|
| 101 |
class CodeSymb1B(nn.Module):
|
| 102 |
+
"""CodeSymb 1B | NiftyOracleAI ๐ฎ๐ณ | codesymb.com"""
|
| 103 |
+
def __init__(self, vocab=50000):
|
| 104 |
super().__init__()
|
| 105 |
+
DM=2048; DF=8192; NL=16; NH=16; NKV=4
|
| 106 |
+
self.embed = nn.Embedding(vocab, DM)
|
| 107 |
self.blocks = nn.ModuleList([Block(DM,DF,NH,NKV) for _ in range(NL)])
|
| 108 |
self.norm = RMSNorm(DM)
|
| 109 |
+
self.head = nn.Linear(DM, vocab, bias=False)
|
| 110 |
def forward(self, tok):
|
| 111 |
x = self.embed(tok).bfloat16()
|
| 112 |
for b in self.blocks:
|
|
|
|
| 114 |
return self.head(self.norm(x))
|
| 115 |
|
| 116 |
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 117 |
+
# LOAD TOKENIZER + MODEL
|
| 118 |
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 119 |
print("โณ Loading CodeSymb-1B tokenizer...")
|
| 120 |
+
tok_path = hf_hub_download(TOK_REPO, "niftyoracle_tokenizer.model", token=HF_TOKEN or None)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
sp = spm.SentencePieceProcessor()
|
| 122 |
sp.load(tok_path)
|
| 123 |
VOCAB = sp.get_piece_size()
|
| 124 |
print(f"โ
Tokenizer: {VOCAB:,} vocab")
|
| 125 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
print("โณ Loading CodeSymb-1B model...")
|
| 127 |
+
model = CodeSymb1B(vocab=VOCAB) # โ
architecture built to match REAL vocab size
|
| 128 |
|
| 129 |
+
ckpt_found = False
|
| 130 |
for ckpt_name in ["checkpoints/sft_latest.pt",
|
| 131 |
"checkpoints/latest.pt",
|
| 132 |
"checkpoints/sft_chat_latest.pt"]:
|
| 133 |
try:
|
| 134 |
+
ckpt_path = hf_hub_download(REPO_ID, ckpt_name, token=HF_TOKEN or None)
|
| 135 |
+
state = torch.load(ckpt_path, map_location="cpu", mmap=True)
|
|
|
|
|
|
|
| 136 |
model_state = state.get("model", state)
|
| 137 |
model.load_state_dict(model_state, strict=False)
|
| 138 |
step = state.get("step", 0)
|
| 139 |
+
print(f"โ
Loaded: {ckpt_name} (step {step:,})")
|
| 140 |
+
ckpt_found = True
|
|
|
|
| 141 |
break
|
| 142 |
except Exception as e:
|
| 143 |
+
print(f" Not found: {ckpt_name}")
|
| 144 |
+
|
| 145 |
+
# โ
HARD FAIL โ never serve a random-weight model silently
|
| 146 |
+
if not ckpt_found:
|
| 147 |
+
raise RuntimeError("โ NO CHECKPOINT FOUND on HF! Fix repo before deploying!")
|
| 148 |
|
| 149 |
model.eval()
|
| 150 |
n_params = sum(p.numel() for p in model.parameters())
|
| 151 |
+
print(f"โ
CodeSymb-1B: {n_params/1e9:.2f}B params โ READY ๐ฅ")
|
|
|
|
| 152 |
|
| 153 |
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 154 |
+
# SYSTEM PROMPT (byte-identical to SFT training data)
|
|
|
|
| 155 |
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 156 |
SYSTEM_PROMPT = (
|
| 157 |
"You are CodeSymb, the world's most intelligent, deeply empathetic, "
|
|
|
|
| 169 |
)
|
| 170 |
|
| 171 |
def build_prompt(message: str, history: list) -> list:
|
| 172 |
+
"""
|
| 173 |
+
โ
Build ONE string exactly like training did, encode ONCE.
|
| 174 |
+
SentencePiece is not concatenative โ never encode pieces separately!
|
| 175 |
+
"""
|
| 176 |
+
parts = ["<|system|>\n" + SYSTEM_PROMPT + "\n"]
|
| 177 |
+
for user_msg, asst_msg in history[-4:]:
|
| 178 |
+
parts.append(f"<|user|>\n{user_msg}\n<|assistant|>\n{asst_msg}\n")
|
| 179 |
+
parts.append(f"<|user|>\n{message}\n<|assistant|>\n")
|
| 180 |
+
return sp.encode("".join(parts))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
|
| 182 |
+
def tail_matches(generated: list, seq: list) -> bool:
|
| 183 |
+
"""โ
Only stop on COMPLETE tag sequence โ a lone '<' won't kill generation"""
|
| 184 |
+
seq = list(seq)
|
| 185 |
+
return len(generated) >= len(seq) and generated[-len(seq):] == seq
|
| 186 |
|
| 187 |
@spaces.GPU(duration=60)
|
| 188 |
def chat_with_codesymb(message: str, history: list) -> str:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 190 |
model.to(device)
|
| 191 |
|
|
|
|
| 192 |
prompt_ids = build_prompt(message, history)
|
| 193 |
|
| 194 |
+
# โ
Trim safely: if too long, keep from a <|user|> boundary, never mid-tag
|
| 195 |
if len(prompt_ids) > 1024:
|
| 196 |
+
user_seq = sp.encode("<|user|>")
|
| 197 |
+
start = 0
|
| 198 |
+
for i in range(len(prompt_ids) - 6, 0, -1):
|
| 199 |
+
if prompt_ids[i:i+len(user_seq)] == list(user_seq):
|
| 200 |
+
start = i
|
| 201 |
+
break
|
| 202 |
+
prompt_ids = prompt_ids[start:][-1024:]
|
| 203 |
|
| 204 |
inp = torch.tensor([prompt_ids], dtype=torch.long).to(device)
|
| 205 |
|
| 206 |
+
# โ
Stop sequences (complete multi-piece tags, not single pieces)
|
| 207 |
+
END_SEQ = sp.encode("<|endoftext|>")
|
| 208 |
+
USER_SEQ = sp.encode("<|user|>")
|
| 209 |
+
SYS_SEQ = sp.encode("<|system|>")
|
| 210 |
+
|
| 211 |
generated = []
|
| 212 |
+
MAX_NEW = 512
|
|
|
|
| 213 |
|
| 214 |
with torch.no_grad():
|
| 215 |
for _ in range(MAX_NEW):
|
| 216 |
+
with torch.autocast("cuda" if device.type == "cuda" else "cpu",
|
| 217 |
dtype=torch.bfloat16):
|
| 218 |
+
logits = model(inp)[0, -1, :].float()
|
| 219 |
|
| 220 |
+
# Temperature
|
| 221 |
+
logits = logits / 0.7
|
| 222 |
|
| 223 |
# Top-p (nucleus) sampling
|
| 224 |
sorted_logits, sorted_idx = torch.sort(logits, descending=True)
|
|
|
|
| 230 |
logits_filtered = torch.zeros_like(logits)
|
| 231 |
logits_filtered.scatter_(0, sorted_idx, sorted_logits)
|
| 232 |
|
| 233 |
+
# Repetition penalty (last 20 tokens)
|
| 234 |
+
if generated:
|
| 235 |
for gid in set(generated[-20:]):
|
| 236 |
if 0 <= gid < logits_filtered.shape[0]:
|
| 237 |
logits_filtered[gid] /= 1.3
|
|
|
|
| 239 |
probs = F.softmax(logits_filtered, dim=-1)
|
| 240 |
next_t = torch.multinomial(probs, 1).item()
|
| 241 |
|
| 242 |
+
# โ
Stop ONLY on complete turn-ending tags
|
| 243 |
+
if tail_matches(generated, END_SEQ) or \
|
| 244 |
+
tail_matches(generated, USER_SEQ) or \
|
| 245 |
+
tail_matches(generated, SYS_SEQ):
|
| 246 |
+
break
|
| 247 |
+
|
| 248 |
+
# Anti-loop: same token 3x in a row
|
| 249 |
+
if len(generated) > 2 and generated[-1] == generated[-2] == next_t:
|
| 250 |
break
|
|
|
|
|
|
|
| 251 |
|
| 252 |
generated.append(next_t)
|
| 253 |
+
inp = torch.cat([inp, torch.tensor([[next_t]], device=device)], dim=1)
|
|
|
|
| 254 |
|
|
|
|
| 255 |
response = sp.decode(generated).strip()
|
| 256 |
|
| 257 |
+
# Strip any leaked tags
|
| 258 |
for tag in ["<|user|>", "<|system|>", "<|assistant|>", "<|endoftext|>"]:
|
| 259 |
response = response.split(tag)[0]
|
|
|
|
| 260 |
response = response.strip()
|
| 261 |
|
| 262 |
if not response:
|
| 263 |
response = (
|
| 264 |
"I'm CodeSymb, your coding partner! ๐ฅ\n"
|
| 265 |
+
"Built by Deepakkumar Malkar at NiftyOracle ๐ฎ๐ณ\n"
|
| 266 |
"Ask me anything about code!"
|
| 267 |
)
|
|
|
|
| 268 |
return response
|
| 269 |
|
| 270 |
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
| 272 |
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 273 |
with gr.Blocks(
|
| 274 |
title="CodeSymb AI โ codesymb.com",
|
| 275 |
+
theme=gr.themes.Base(primary_hue="blue", secondary_hue="indigo"),
|
|
|
|
|
|
|
|
|
|
| 276 |
css="""
|
| 277 |
body { background: #060D1F !important; }
|
| 278 |
.gradio-container { max-width: 860px !important; }
|
| 279 |
+
h1 {
|
| 280 |
text-align: center;
|
| 281 |
background: linear-gradient(135deg, #00D4FF, #A855F7);
|
| 282 |
-webkit-background-clip: text;
|
|
|
|
| 284 |
font-size: 2.5em !important;
|
| 285 |
font-weight: 900 !important;
|
| 286 |
}
|
| 287 |
+
.subtitle { text-align: center; color: #A0AEC0; margin-bottom: 20px; font-size: 1.1em; }
|
| 288 |
+
""",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 289 |
) as demo:
|
| 290 |
|
| 291 |
gr.HTML("""
|
| 292 |
<h1>โก CodeSymb AI</h1>
|
| 293 |
<p class='subtitle'>
|
| 294 |
World's Most Powerful Coding AI ๐<br>
|
| 295 |
+
Built by <strong>Deepakkumar Malkar</strong> at NiftyOracle ๐ฎ๐ณ<br>
|
|
|
|
| 296 |
<em>"Impossible is just a door with no handle yet invented."</em>
|
| 297 |
</p>
|
| 298 |
""")
|
| 299 |
|
| 300 |
+
gr.ChatInterface(
|
| 301 |
fn=chat_with_codesymb,
|
| 302 |
examples=[
|
| 303 |
["Hi! Who are you and what can you build?"],
|
|
|
|
| 314 |
|
| 315 |
gr.HTML("""
|
| 316 |
<div style='text-align:center;padding:20px;color:#4A5568;font-size:13px'>
|
| 317 |
+
<strong>CodeSymb-1B</strong> | 1.08B params | NiftyOracle ๐ฎ๐ณ<br>
|
| 318 |
+
<a href='https://codesymb.com' style='color:#1D6FEB'>codesymb.com</a> ๐ |
|
| 319 |
+
<a href='https://huggingface.co/NiftyOracleAI' style='color:#1D6FEB'>HuggingFace</a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 320 |
</div>
|
| 321 |
""")
|
| 322 |
|