Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,44 +1,44 @@
|
|
| 1 |
# Create wrapper function for proper chat handling
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
{"role": "user", "content": message},
|
| 31 |
-
{"role": "assistant", "content": response_chunk}
|
| 32 |
-
]
|
| 33 |
-
yield "", new_history
|
| 34 |
-
|
| 35 |
-
except Exception as e:
|
| 36 |
-
print(f"β Error in respond: {e}")
|
| 37 |
-
error_history = history + [
|
| 38 |
{"role": "user", "content": message},
|
| 39 |
-
{"role": "assistant", "content":
|
| 40 |
]
|
| 41 |
-
yield "",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
"""
|
| 43 |
πΈ Creed Bratton AI - Using phxdev/creed-qwen-0.5b-lora
|
| 44 |
The REAL Creed, trained by Mark, not some knockoff prompt engineering
|
|
@@ -59,267 +59,267 @@ os.environ['GRADIO_MCP_ENABLED'] = 'true'
|
|
| 59 |
|
| 60 |
# Spaces compatibility
|
| 61 |
try:
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
except ImportError:
|
| 68 |
-
|
| 69 |
|
| 70 |
class CreedBrattonAI:
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
|
|
|
| 85 |
|
| 86 |
-
|
| 87 |
-
self.load_model()
|
| 88 |
|
| 89 |
-
|
| 90 |
-
"
|
| 91 |
-
if self.loading or self.model_loaded:
|
| 92 |
-
return
|
| 93 |
-
|
| 94 |
-
self.loading = True
|
| 95 |
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
model_name,
|
|
|
|
|
|
|
| 105 |
trust_remote_code=True,
|
| 106 |
-
|
| 107 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
|
| 109 |
-
# Fix pad token
|
| 110 |
if self.tokenizer.pad_token is None:
|
| 111 |
self.tokenizer.pad_token = self.tokenizer.unk_token or "[PAD]"
|
| 112 |
-
print(f"π§ Set pad_token to: {self.tokenizer.pad_token}")
|
| 113 |
-
|
| 114 |
-
# Add Creed's custom tokens
|
| 115 |
-
custom_tokens = ["<thinking>", "<conspiracy>", "<tangent>"]
|
| 116 |
-
print(f"πΈ Adding Creed's custom tokens: {custom_tokens}")
|
| 117 |
-
|
| 118 |
-
num_added_tokens = self.tokenizer.add_tokens(custom_tokens)
|
| 119 |
-
print(f"β
Added {num_added_tokens} custom tokens")
|
| 120 |
-
|
| 121 |
-
print(f"π€ Loading model on {self.device}...")
|
| 122 |
|
| 123 |
-
# Load model with proper device handling
|
| 124 |
if self.device == "cuda":
|
| 125 |
self.model = AutoModelForCausalLM.from_pretrained(
|
| 126 |
-
|
| 127 |
-
torch_dtype=torch.float16,
|
| 128 |
-
device_map="auto"
|
| 129 |
-
trust_remote_code=True,
|
| 130 |
-
low_cpu_mem_usage=True
|
| 131 |
)
|
| 132 |
-
# Explicitly ensure model is on CUDA
|
| 133 |
if self.model.device.type != "cuda":
|
| 134 |
-
print("π§ Explicitly moving model to CUDA...")
|
| 135 |
self.model = self.model.to(self.device)
|
| 136 |
else:
|
| 137 |
self.model = AutoModelForCausalLM.from_pretrained(
|
| 138 |
-
|
| 139 |
-
torch_dtype=torch.float32,
|
| 140 |
-
device_map=None
|
| 141 |
-
trust_remote_code=True,
|
| 142 |
-
low_cpu_mem_usage=True
|
| 143 |
)
|
| 144 |
self.model = self.model.to("cpu")
|
| 145 |
|
| 146 |
-
# Resize embeddings for custom tokens
|
| 147 |
-
if num_added_tokens > 0:
|
| 148 |
-
print(f"π§ Resizing model embeddings for {num_added_tokens} custom tokens")
|
| 149 |
-
self.model.resize_token_embeddings(len(self.tokenizer))
|
| 150 |
-
|
| 151 |
self.model.eval()
|
| 152 |
-
|
| 153 |
-
# Verify device placement
|
| 154 |
-
model_device = next(self.model.parameters()).device
|
| 155 |
-
print(f"π― Model is actually on: {model_device}")
|
| 156 |
-
|
| 157 |
self.model_loaded = True
|
| 158 |
-
|
| 159 |
-
print(f"β
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
print(f"β Error loading Creed model: {e}")
|
| 168 |
-
print("π Falling back to base model...")
|
| 169 |
-
try:
|
| 170 |
-
base_model = "Qwen/Qwen2.5-0.5B-Instruct"
|
| 171 |
-
self.tokenizer = AutoTokenizer.from_pretrained(base_model)
|
| 172 |
-
|
| 173 |
-
# Fix pad token for fallback too
|
| 174 |
-
if self.tokenizer.pad_token is None:
|
| 175 |
-
self.tokenizer.pad_token = self.tokenizer.unk_token or "[PAD]"
|
| 176 |
-
|
| 177 |
-
if self.device == "cuda":
|
| 178 |
-
self.model = AutoModelForCausalLM.from_pretrained(
|
| 179 |
-
base_model,
|
| 180 |
-
torch_dtype=torch.float16,
|
| 181 |
-
device_map="auto"
|
| 182 |
-
)
|
| 183 |
-
if self.model.device.type != "cuda":
|
| 184 |
-
self.model = self.model.to(self.device)
|
| 185 |
-
else:
|
| 186 |
-
self.model = AutoModelForCausalLM.from_pretrained(
|
| 187 |
-
base_model,
|
| 188 |
-
torch_dtype=torch.float32,
|
| 189 |
-
device_map=None
|
| 190 |
-
)
|
| 191 |
-
self.model = self.model.to("cpu")
|
| 192 |
-
|
| 193 |
-
self.model.eval()
|
| 194 |
-
self.model_loaded = True
|
| 195 |
-
model_device = next(self.model.parameters()).device
|
| 196 |
-
print(f"β
Fallback model loaded on {model_device}")
|
| 197 |
-
except Exception as fallback_error:
|
| 198 |
-
print(f"β Fallback also failed: {fallback_error}")
|
| 199 |
-
self.loading = False
|
| 200 |
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 225 |
)
|
| 226 |
-
|
| 227 |
-
print(f"π Tokenized input_ids shape: {inputs['input_ids'].shape}")
|
| 228 |
-
print(f"π First few tokens: {inputs['input_ids'][0][:10]}")
|
| 229 |
-
|
| 230 |
-
# Move inputs to same device as model
|
| 231 |
-
input_ids = inputs['input_ids'].to(self.device)
|
| 232 |
-
attention_mask = inputs['attention_mask'].to(self.device)
|
| 233 |
-
|
| 234 |
-
print(f"π Model device: {self.model.device}, Input device: {input_ids.device}")
|
| 235 |
-
|
| 236 |
-
# Generate response with proper attention mask
|
| 237 |
-
with torch.no_grad():
|
| 238 |
-
outputs = self.model.generate(
|
| 239 |
-
input_ids=input_ids,
|
| 240 |
-
attention_mask=attention_mask, # Pass attention mask
|
| 241 |
-
max_new_tokens=100, # Reduce to debug
|
| 242 |
-
do_sample=True,
|
| 243 |
-
temperature=0.7, # Lower temperature
|
| 244 |
-
top_p=0.9,
|
| 245 |
-
top_k=50,
|
| 246 |
-
repetition_penalty=1.1,
|
| 247 |
-
pad_token_id=self.tokenizer.pad_token_id,
|
| 248 |
-
eos_token_id=self.tokenizer.eos_token_id,
|
| 249 |
-
use_cache=True
|
| 250 |
-
)
|
| 251 |
-
|
| 252 |
-
print(f"π Generated output shape: {outputs.shape}")
|
| 253 |
-
print(f"π Generated tokens: {outputs[0][-20:]}") # Last 20 tokens
|
| 254 |
-
|
| 255 |
-
# Decode response
|
| 256 |
-
full_response = self.tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 257 |
-
input_text = self.tokenizer.decode(input_ids[0], skip_special_tokens=True)
|
| 258 |
-
response = full_response[len(input_text):].strip()
|
| 259 |
-
|
| 260 |
-
print(f"π Raw response: {response[:200]}...")
|
| 261 |
-
|
| 262 |
-
cleaned_response = self._clean_response(response)
|
| 263 |
-
print(f"π Cleaned response: {cleaned_response[:200]}...")
|
| 264 |
-
|
| 265 |
-
return cleaned_response
|
| 266 |
-
|
| 267 |
-
except Exception as e:
|
| 268 |
-
print(f"β Generation error: {e}")
|
| 269 |
-
import traceback
|
| 270 |
-
traceback.print_exc()
|
| 271 |
-
return f"πΈ *Creed scratches his head* Something weird happened... {str(e)[:100]}"
|
| 272 |
-
|
| 273 |
-
def generate_response(self, message: str, history: List[Dict]) -> Iterator[str]:
|
| 274 |
-
"""Generate response using the trained Creed model - works with messages format"""
|
| 275 |
-
|
| 276 |
-
if not self.model_loaded:
|
| 277 |
-
if self.loading:
|
| 278 |
-
yield "π§ Creed's consciousness is still loading... give me a moment..."
|
| 279 |
-
return
|
| 280 |
-
else:
|
| 281 |
-
yield "β Something went wrong loading Creed's mind. Try refreshing the page."
|
| 282 |
-
return
|
| 283 |
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
formatted_history.append([user_msg, assistant_msg])
|
| 294 |
-
elif msg.get('role') == 'assistant':
|
| 295 |
-
# Update the last entry with assistant response
|
| 296 |
-
if formatted_history:
|
| 297 |
-
formatted_history[-1][1] = msg.get('content', '')
|
| 298 |
-
|
| 299 |
-
# Format the conversation
|
| 300 |
-
conversation = self._format_conversation(message, formatted_history)
|
| 301 |
-
|
| 302 |
-
# Generate response using GPU function
|
| 303 |
-
response = self.generate_response_gpu(conversation)
|
| 304 |
-
|
| 305 |
-
# Stream the response word by word for effect
|
| 306 |
-
words = response.split()
|
| 307 |
-
current_response = ""
|
| 308 |
-
|
| 309 |
-
for word in words:
|
| 310 |
-
current_response += word + " "
|
| 311 |
-
time.sleep(0.05)
|
| 312 |
-
yield current_response.strip()
|
| 313 |
-
|
| 314 |
-
except Exception as e:
|
| 315 |
-
print(f"β Error generating response: {e}")
|
| 316 |
-
yield f"πΈ *Creed scratches his head* Something weird happened in my brain... {str(e)[:100]}"
|
| 317 |
-
|
| 318 |
-
def _format_conversation(self, message: str, history: List[List[str]]) -> str:
|
| 319 |
-
"""Format the conversation for the model with proper system prompt"""
|
| 320 |
|
| 321 |
-
|
| 322 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 323 |
|
| 324 |
CORE IDENTITY:
|
| 325 |
- Former member of The Grass Roots (1960s rock band)
|
|
@@ -359,554 +359,554 @@ RESPONSE GUIDELINES:
|
|
| 359 |
Remember: You're not trying to be helpful in a traditional sense - you're being Creed Bratton.
|
| 360 |
|
| 361 |
"""
|
| 362 |
-
|
| 363 |
-
# Add conversation history
|
| 364 |
-
conversation = system_prompt
|
| 365 |
-
for user_msg, creed_msg in history[-4:]: # Keep recent context
|
| 366 |
-
if user_msg and creed_msg: # Only add complete exchanges
|
| 367 |
-
conversation += f"Human: {user_msg}\n"
|
| 368 |
-
conversation += f"Creed: {creed_msg}\n"
|
| 369 |
-
|
| 370 |
-
# Add current message
|
| 371 |
-
conversation += f"Human: {message}\n"
|
| 372 |
-
conversation += "Creed:"
|
| 373 |
-
|
| 374 |
-
return conversation
|
| 375 |
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
#
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
# Format Creed's custom tokens for better UI display
|
| 383 |
-
response = response.replace("<thinking>", "π€ *thinking* ")
|
| 384 |
-
response = response.replace("</thinking>", "")
|
| 385 |
-
response = response.replace("<conspiracy>", "π΅οΈ *conspiracy mode* ")
|
| 386 |
-
response = response.replace("</conspiracy>", "")
|
| 387 |
-
response = response.replace("<tangent>", "π *tangent* ")
|
| 388 |
-
response = response.replace("</tangent>", "")
|
| 389 |
-
|
| 390 |
-
# Remove excessive whitespace
|
| 391 |
-
response = " ".join(response.split())
|
| 392 |
-
|
| 393 |
-
# Ensure it ends properly
|
| 394 |
-
if response and not response.endswith(('.', '!', '?', '...', '*')):
|
| 395 |
-
response += "."
|
| 396 |
-
|
| 397 |
-
return response
|
| 398 |
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
return "π§ Creed's consciousness is still loading..."
|
| 403 |
-
|
| 404 |
-
prompt = f"Give me your wisdom about {topic}."
|
| 405 |
-
|
| 406 |
-
# Generate a one-shot response
|
| 407 |
-
final_response = ""
|
| 408 |
-
for response in self.generate_response(prompt, []):
|
| 409 |
-
final_response = response
|
| 410 |
-
|
| 411 |
-
return final_response
|
| 412 |
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
print(f"π§Ή GPU Memory cleaned. Current: {torch.cuda.memory_allocated() // 1024**2} MB")
|
| 418 |
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 432 |
|
| 433 |
-
def
|
| 434 |
-
"""
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
/* Creed AI - Modern Glassmorphism Design */
|
| 467 |
-
:root {
|
| 468 |
-
--primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 469 |
-
--secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
|
| 470 |
-
--glass-bg: rgba(255, 255, 255, 0.08);
|
| 471 |
-
--glass-border: rgba(255, 255, 255, 0.18);
|
| 472 |
-
--text-primary: #ffffff;
|
| 473 |
-
--text-secondary: rgba(255, 255, 255, 0.8);
|
| 474 |
-
--accent-purple: #8b5cf6;
|
| 475 |
-
--accent-blue: #3b82f6;
|
| 476 |
-
--shadow-glow: 0 8px 32px rgba(139, 92, 246, 0.3);
|
| 477 |
-
}
|
| 478 |
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
min-height: 100vh !important;
|
| 482 |
-
background: var(--primary-gradient) !important;
|
| 483 |
-
background-attachment: fixed !important;
|
| 484 |
-
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
|
| 485 |
-
color: var(--text-primary) !important;
|
| 486 |
-
padding: 20px !important;
|
| 487 |
-
position: relative !important;
|
| 488 |
-
overflow-x: hidden !important;
|
| 489 |
-
}
|
| 490 |
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
position: fixed;
|
| 494 |
-
top: 0;
|
| 495 |
-
left: 0;
|
| 496 |
-
width: 100%;
|
| 497 |
-
height: 100%;
|
| 498 |
-
background:
|
| 499 |
-
radial-gradient(circle at 20% 80%, rgba(139, 92, 246, 0.3) 0%, transparent 50%),
|
| 500 |
-
radial-gradient(circle at 80% 20%, rgba(59, 130, 246, 0.3) 0%, transparent 50%),
|
| 501 |
-
radial-gradient(circle at 40% 40%, rgba(167, 139, 250, 0.2) 0%, transparent 50%);
|
| 502 |
-
pointer-events: none;
|
| 503 |
-
z-index: -1;
|
| 504 |
-
}
|
| 505 |
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
content: '';
|
| 509 |
-
position: fixed;
|
| 510 |
-
top: 0;
|
| 511 |
-
left: 0;
|
| 512 |
-
width: 100%;
|
| 513 |
-
height: 100%;
|
| 514 |
-
background-image:
|
| 515 |
-
radial-gradient(2px 2px at 20px 30px, rgba(255, 255, 255, 0.3), transparent),
|
| 516 |
-
radial-gradient(2px 2px at 40px 70px, rgba(139, 92, 246, 0.4), transparent),
|
| 517 |
-
radial-gradient(1px 1px at 90px 40px, rgba(59, 130, 246, 0.3), transparent);
|
| 518 |
-
background-size: 120px 120px;
|
| 519 |
-
animation: float 20s ease-in-out infinite;
|
| 520 |
-
pointer-events: none;
|
| 521 |
-
z-index: -1;
|
| 522 |
-
}
|
| 523 |
|
| 524 |
-
|
| 525 |
-
|
| 526 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 527 |
}
|
| 528 |
-
|
| 529 |
-
/* Header styling */
|
| 530 |
.header {
|
| 531 |
-
|
| 532 |
-
|
| 533 |
-
border: 1px solid var(--glass-border) !important;
|
| 534 |
-
border-radius: 24px !important;
|
| 535 |
-
padding: 32px !important;
|
| 536 |
-
margin-bottom: 24px !important;
|
| 537 |
-
text-align: center !important;
|
| 538 |
-
box-shadow: var(--shadow-glow) !important;
|
| 539 |
-
position: relative !important;
|
| 540 |
-
overflow: hidden !important;
|
| 541 |
-
}
|
| 542 |
-
|
| 543 |
-
.header::before {
|
| 544 |
-
content: '';
|
| 545 |
-
position: absolute;
|
| 546 |
-
top: 0;
|
| 547 |
-
left: 0;
|
| 548 |
-
right: 0;
|
| 549 |
-
height: 1px;
|
| 550 |
-
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
|
| 551 |
}
|
| 552 |
-
|
| 553 |
.header h1 {
|
| 554 |
-
font-size:
|
| 555 |
-
font-weight: 700 !important;
|
| 556 |
-
background: linear-gradient(135deg, #ffffff 0%, #a855f7 50%, #3b82f6 100%) !important;
|
| 557 |
-
-webkit-background-clip: text !important;
|
| 558 |
-
-webkit-text-fill-color: transparent !important;
|
| 559 |
-
background-clip: text !important;
|
| 560 |
-
margin: 0 0 12px 0 !important;
|
| 561 |
-
text-shadow: 0 0 30px rgba(168, 85, 247, 0.5) !important;
|
| 562 |
}
|
| 563 |
-
|
| 564 |
-
.
|
| 565 |
-
|
| 566 |
-
color: var(--text-secondary) !important;
|
| 567 |
-
margin: 0 !important;
|
| 568 |
-
font-weight: 500 !important;
|
| 569 |
-
}
|
| 570 |
-
|
| 571 |
-
/* Info boxes with glass effect */
|
| 572 |
-
.info-box {
|
| 573 |
-
background: rgba(255, 255, 255, 0.06) !important;
|
| 574 |
-
backdrop-filter: blur(16px) !important;
|
| 575 |
-
border: 1px solid rgba(255, 255, 255, 0.12) !important;
|
| 576 |
border-radius: 16px !important;
|
| 577 |
padding: 20px !important;
|
| 578 |
-
margin: 16px 0 !important;
|
| 579 |
-
color: var(--text-secondary) !important;
|
| 580 |
-
font-size: 14px !important;
|
| 581 |
-
line-height: 1.6 !important;
|
| 582 |
-
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1) !important;
|
| 583 |
-
}
|
| 584 |
-
|
| 585 |
-
.status-box {
|
| 586 |
-
background: rgba(16, 185, 129, 0.1) !important;
|
| 587 |
-
backdrop-filter: blur(16px) !important;
|
| 588 |
-
border: 1px solid rgba(16, 185, 129, 0.3) !important;
|
| 589 |
-
border-radius: 16px !important;
|
| 590 |
-
padding: 16px 20px !important;
|
| 591 |
-
margin: 16px 0 !important;
|
| 592 |
-
color: #10b981 !important;
|
| 593 |
-
font-weight: 600 !important;
|
| 594 |
-
box-shadow: 0 4px 20px rgba(16, 185, 129, 0.2) !important;
|
| 595 |
-
}
|
| 596 |
-
|
| 597 |
-
/* Chat area styling */
|
| 598 |
-
.chat-area {
|
| 599 |
-
background: var(--glass-bg) !important;
|
| 600 |
-
backdrop-filter: blur(20px) !important;
|
| 601 |
-
border: 1px solid var(--glass-border) !important;
|
| 602 |
-
border-radius: 20px !important;
|
| 603 |
-
margin: 16px 0 !important;
|
| 604 |
-
overflow: hidden !important;
|
| 605 |
-
box-shadow: var(--shadow-glow) !important;
|
| 606 |
-
}
|
| 607 |
-
|
| 608 |
-
/* Tools section */
|
| 609 |
-
.tools-area {
|
| 610 |
-
background: var(--glass-bg) !important;
|
| 611 |
-
backdrop-filter: blur(20px) !important;
|
| 612 |
-
border: 1px solid var(--glass-border) !important;
|
| 613 |
-
border-radius: 20px !important;
|
| 614 |
-
padding: 28px !important;
|
| 615 |
-
margin: 24px 0 !important;
|
| 616 |
-
box-shadow: var(--shadow-glow) !important;
|
| 617 |
-
}
|
| 618 |
-
|
| 619 |
-
.tools-title {
|
| 620 |
-
font-size: 22px !important;
|
| 621 |
-
font-weight: 600 !important;
|
| 622 |
-
color: var(--text-primary) !important;
|
| 623 |
-
margin: 0 0 20px 0 !important;
|
| 624 |
-
padding-bottom: 12px !important;
|
| 625 |
-
border-bottom: 1px solid rgba(255, 255, 255, 0.2) !important;
|
| 626 |
-
background: linear-gradient(135deg, #ffffff 0%, #a855f7 100%) !important;
|
| 627 |
-
-webkit-background-clip: text !important;
|
| 628 |
-
-webkit-text-fill-color: transparent !important;
|
| 629 |
-
}
|
| 630 |
-
|
| 631 |
-
/* Form elements */
|
| 632 |
-
.gradio-textbox input,
|
| 633 |
-
.gradio-textbox textarea {
|
| 634 |
-
background: rgba(255, 255, 255, 0.08) !important;
|
| 635 |
-
backdrop-filter: blur(10px) !important;
|
| 636 |
-
border: 1px solid rgba(255, 255, 255, 0.16) !important;
|
| 637 |
-
color: var(--text-primary) !important;
|
| 638 |
-
border-radius: 12px !important;
|
| 639 |
-
padding: 12px 16px !important;
|
| 640 |
-
transition: all 0.3s ease !important;
|
| 641 |
-
font-size: 14px !important;
|
| 642 |
-
}
|
| 643 |
-
|
| 644 |
-
.gradio-textbox input:focus,
|
| 645 |
-
.gradio-textbox textarea:focus {
|
| 646 |
-
border-color: var(--accent-purple) !important;
|
| 647 |
-
outline: none !important;
|
| 648 |
-
box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.3) !important;
|
| 649 |
-
background: rgba(255, 255, 255, 0.12) !important;
|
| 650 |
-
}
|
| 651 |
-
|
| 652 |
-
.gradio-textbox input::placeholder,
|
| 653 |
-
.gradio-textbox textarea::placeholder {
|
| 654 |
-
color: rgba(255, 255, 255, 0.5) !important;
|
| 655 |
-
}
|
| 656 |
-
|
| 657 |
-
/* Labels */
|
| 658 |
-
.gradio-container label {
|
| 659 |
-
color: var(--text-secondary) !important;
|
| 660 |
-
font-weight: 500 !important;
|
| 661 |
-
font-size: 14px !important;
|
| 662 |
-
margin-bottom: 6px !important;
|
| 663 |
-
display: block !important;
|
| 664 |
-
}
|
| 665 |
-
|
| 666 |
-
/* Buttons */
|
| 667 |
-
.gradio-container button {
|
| 668 |
-
background: linear-gradient(135deg, var(--accent-purple) 0%, var(--accent-blue) 100%) !important;
|
| 669 |
-
color: var(--text-primary) !important;
|
| 670 |
-
border: none !important;
|
| 671 |
-
border-radius: 12px !important;
|
| 672 |
-
padding: 12px 24px !important;
|
| 673 |
-
font-weight: 600 !important;
|
| 674 |
-
cursor: pointer !important;
|
| 675 |
-
transition: all 0.3s ease !important;
|
| 676 |
-
box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4) !important;
|
| 677 |
-
backdrop-filter: blur(10px) !important;
|
| 678 |
-
min-height: 44px !important;
|
| 679 |
-
display: flex !important;
|
| 680 |
-
align-items: center !important;
|
| 681 |
-
justify-content: center !important;
|
| 682 |
-
}
|
| 683 |
-
|
| 684 |
-
.gradio-container button:hover {
|
| 685 |
-
transform: translateY(-2px) !important;
|
| 686 |
-
box-shadow: 0 8px 25px rgba(139, 92, 246, 0.6) !important;
|
| 687 |
-
background: linear-gradient(135deg, #9333ea 0%, #2563eb 100%) !important;
|
| 688 |
-
}
|
| 689 |
-
|
| 690 |
-
.gradio-container button:active {
|
| 691 |
-
transform: translateY(0px) !important;
|
| 692 |
-
}
|
| 693 |
-
|
| 694 |
-
/* Send button specific styling */
|
| 695 |
-
.gradio-container .gr-button {
|
| 696 |
-
background: linear-gradient(135deg, var(--accent-purple) 0%, var(--accent-blue) 100%) !important;
|
| 697 |
-
border: 1px solid rgba(255, 255, 255, 0.2) !important;
|
| 698 |
-
color: white !important;
|
| 699 |
-
font-weight: 600 !important;
|
| 700 |
-
text-transform: none !important;
|
| 701 |
-
letter-spacing: 0.5px !important;
|
| 702 |
-
}
|
| 703 |
-
|
| 704 |
-
/* Chatbot specific styling */
|
| 705 |
-
.gradio-chatbot {
|
| 706 |
-
background: transparent !important;
|
| 707 |
-
border: none !important;
|
| 708 |
-
}
|
| 709 |
-
|
| 710 |
-
/* Footer */
|
| 711 |
-
.footer {
|
| 712 |
-
text-align: center !important;
|
| 713 |
-
padding: 28px !important;
|
| 714 |
-
color: var(--text-secondary) !important;
|
| 715 |
-
background: var(--glass-bg) !important;
|
| 716 |
-
backdrop-filter: blur(20px) !important;
|
| 717 |
-
border: 1px solid var(--glass-border) !important;
|
| 718 |
-
border-radius: 20px !important;
|
| 719 |
-
margin-top: 32px !important;
|
| 720 |
-
box-shadow: var(--shadow-glow) !important;
|
| 721 |
-
}
|
| 722 |
-
|
| 723 |
-
/* Scrollbar styling */
|
| 724 |
-
::-webkit-scrollbar {
|
| 725 |
-
width: 8px;
|
| 726 |
-
}
|
| 727 |
-
|
| 728 |
-
::-webkit-scrollbar-track {
|
| 729 |
-
background: rgba(255, 255, 255, 0.05);
|
| 730 |
-
border-radius: 4px;
|
| 731 |
-
}
|
| 732 |
-
|
| 733 |
-
::-webkit-scrollbar-thumb {
|
| 734 |
-
background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
|
| 735 |
-
border-radius: 4px;
|
| 736 |
-
}
|
| 737 |
-
|
| 738 |
-
::-webkit-scrollbar-thumb:hover {
|
| 739 |
-
background: linear-gradient(135deg, #9333ea, #2563eb);
|
| 740 |
}
|
|
|
|
|
|
|
| 741 |
|
| 742 |
-
|
| 743 |
-
|
| 744 |
-
|
| 745 |
-
|
| 746 |
-
|
| 747 |
-
|
| 748 |
-
|
| 749 |
-
|
| 750 |
-
|
| 751 |
-
|
| 752 |
-
|
| 753 |
-
|
| 754 |
-
|
| 755 |
-
|
| 756 |
-
|
| 757 |
-
|
| 758 |
-
|
| 759 |
-
|
| 760 |
-
|
| 761 |
-
|
| 762 |
-
|
| 763 |
-
|
| 764 |
-
|
| 765 |
-
|
| 766 |
-
|
| 767 |
-
|
| 768 |
-
|
| 769 |
-
|
| 770 |
-
|
| 771 |
-
|
| 772 |
-
|
| 773 |
-
|
| 774 |
-
|
| 775 |
-
|
| 776 |
-
|
| 777 |
-
|
| 778 |
-
|
| 779 |
-
css=modern_css,
|
| 780 |
-
theme=gr.themes.Base() # Use base theme for better CSS control
|
| 781 |
-
) as demo:
|
| 782 |
-
|
| 783 |
-
# Modern header
|
| 784 |
-
gr.HTML(f"""
|
| 785 |
-
<div class="header">
|
| 786 |
-
<h1>πΈ Creed Bratton AI</h1>
|
| 787 |
-
<p>Powered by phxdev/creed-qwen-0.5b-lora β’ Running on {'π GPU' if creed_ai.device == 'cuda' else 'π₯οΈ CPU'}</p>
|
| 788 |
-
</div>
|
| 789 |
-
""")
|
| 790 |
-
|
| 791 |
-
# Model info with glass styling
|
| 792 |
gr.HTML("""
|
| 793 |
-
<div class="
|
| 794 |
-
|
| 795 |
-
<strong>Base:</strong> Qwen 0.5B + LoRA fine-tuning<br>
|
| 796 |
-
<strong>Tokens:</strong> <thinking>, <conspiracy>, <tangent>
|
| 797 |
</div>
|
| 798 |
""")
|
| 799 |
-
|
| 800 |
-
|
| 801 |
-
|
| 802 |
-
|
| 803 |
-
|
| 804 |
-
|
| 805 |
-
|
| 806 |
-
|
| 807 |
-
|
| 808 |
-
|
| 809 |
-
|
| 810 |
-
|
| 811 |
-
|
| 812 |
-
|
| 813 |
-
|
| 814 |
-
|
| 815 |
-
|
| 816 |
-
|
| 817 |
-
|
| 818 |
-
placeholder="
|
| 819 |
-
container=False
|
|
|
|
|
|
|
| 820 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 821 |
|
| 822 |
-
# Input with explicit send button
|
| 823 |
with gr.Row():
|
| 824 |
-
with gr.Column(
|
| 825 |
-
|
| 826 |
-
|
| 827 |
-
|
| 828 |
-
submit_btn=False, # Disable built-in submit
|
| 829 |
-
stop_btn=False
|
| 830 |
)
|
| 831 |
-
|
| 832 |
-
|
| 833 |
-
|
| 834 |
-
|
| 835 |
-
|
| 836 |
-
|
| 837 |
-
|
| 838 |
-
|
| 839 |
-
|
| 840 |
-
|
| 841 |
-
|
| 842 |
-
|
| 843 |
-
|
| 844 |
-
|
| 845 |
-
|
| 846 |
-
|
| 847 |
-
|
| 848 |
-
|
| 849 |
-
# MCP Tools section with glass styling
|
| 850 |
-
with gr.Row(elem_classes="tools-area"):
|
| 851 |
-
gr.HTML('<div class="tools-title">π οΈ MCP Tools</div>')
|
| 852 |
-
|
| 853 |
-
with gr.Row():
|
| 854 |
-
with gr.Column():
|
| 855 |
-
wisdom_topic = gr.Textbox(
|
| 856 |
-
label="Wisdom Topic",
|
| 857 |
-
placeholder="life, business, relationships..."
|
| 858 |
-
)
|
| 859 |
-
wisdom_output = gr.Textbox(
|
| 860 |
-
label="Creed's Response",
|
| 861 |
-
interactive=False,
|
| 862 |
-
lines=3
|
| 863 |
-
)
|
| 864 |
-
wisdom_btn = gr.Button("Ask Creed", variant="primary")
|
| 865 |
-
|
| 866 |
-
with gr.Column():
|
| 867 |
-
story_situation = gr.Textbox(
|
| 868 |
-
label="Story Request",
|
| 869 |
-
placeholder="Tell me about..."
|
| 870 |
-
)
|
| 871 |
-
story_output = gr.Textbox(
|
| 872 |
-
label="Creed's Story",
|
| 873 |
-
interactive=False,
|
| 874 |
-
lines=3
|
| 875 |
-
)
|
| 876 |
-
story_btn = gr.Button("Get Story", variant="primary")
|
| 877 |
-
|
| 878 |
-
# Wire up the tools
|
| 879 |
-
wisdom_btn.click(
|
| 880 |
-
creed_ai.creed_wisdom_tool,
|
| 881 |
-
inputs=[wisdom_topic],
|
| 882 |
-
outputs=[wisdom_output]
|
| 883 |
-
)
|
| 884 |
-
|
| 885 |
-
story_btn.click(
|
| 886 |
-
creed_ai.creed_story_tool,
|
| 887 |
-
inputs=[story_situation],
|
| 888 |
-
outputs=[story_output]
|
| 889 |
-
)
|
| 890 |
-
|
| 891 |
-
# Modern footer
|
| 892 |
-
gr.HTML("""
|
| 893 |
-
<div class="footer">
|
| 894 |
-
<strong>Creed Bratton AI</strong><br>
|
| 895 |
-
Model: phxdev/creed-qwen-0.5b-lora β’ Trained by Mark Scott<br>
|
| 896 |
-
<em>"Sometimes a guy's gotta ride the bull, am I right?"</em>
|
| 897 |
-
</div>
|
| 898 |
-
""")
|
| 899 |
|
| 900 |
-
#
|
| 901 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 902 |
|
| 903 |
-
|
| 904 |
-
|
| 905 |
-
|
| 906 |
-
|
| 907 |
-
share=True, # Create public link
|
| 908 |
-
show_error=True
|
| 909 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 910 |
|
| 911 |
if __name__ == "__main__":
|
| 912 |
-
|
|
|
|
| 1 |
# Create wrapper function for proper chat handling
|
| 2 |
+
def respond(message, history):
|
| 3 |
+
"""Response handler for Gradio messages format"""
|
| 4 |
+
if not message.strip():
|
| 5 |
+
return "", history
|
| 6 |
+
|
| 7 |
+
print(f"π Input message: {message}")
|
| 8 |
+
print(f"π History length: {len(history)}")
|
| 9 |
+
|
| 10 |
+
# Convert messages format to simple tuples for model processing
|
| 11 |
+
simple_history = []
|
| 12 |
+
for i in range(0, len(history) - 1, 2):
|
| 13 |
+
if i + 1 < len(history):
|
| 14 |
+
user_msg = history[i].get('content', '') if isinstance(history[i], dict) else str(history[i])
|
| 15 |
+
bot_msg = history[i + 1].get('content', '') if isinstance(history[i + 1], dict) else str(history[i + 1])
|
| 16 |
+
if user_msg and bot_msg:
|
| 17 |
+
simple_history.append([user_msg, bot_msg])
|
| 18 |
+
|
| 19 |
+
print(f"π Simple history: {simple_history}")
|
| 20 |
+
|
| 21 |
+
# Generate response with debugging
|
| 22 |
+
try:
|
| 23 |
+
response_generator = creed_ai.generate_response(message, simple_history)
|
| 24 |
+
final_response = ""
|
| 25 |
+
|
| 26 |
+
for response_chunk in response_generator:
|
| 27 |
+
final_response = response_chunk
|
| 28 |
+
# Create new history with the streaming response
|
| 29 |
+
new_history = history + [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
{"role": "user", "content": message},
|
| 31 |
+
{"role": "assistant", "content": response_chunk}
|
| 32 |
]
|
| 33 |
+
yield "", new_history
|
| 34 |
+
|
| 35 |
+
except Exception as e:
|
| 36 |
+
print(f"β Error in respond: {e}")
|
| 37 |
+
error_history = history + [
|
| 38 |
+
{"role": "user", "content": message},
|
| 39 |
+
{"role": "assistant", "content": f"πΈ *Creed's brain malfunctioned* Error: {str(e)[:100]}"}
|
| 40 |
+
]
|
| 41 |
+
yield "", error_history#!/usr/bin/env python3
|
| 42 |
"""
|
| 43 |
πΈ Creed Bratton AI - Using phxdev/creed-qwen-0.5b-lora
|
| 44 |
The REAL Creed, trained by Mark, not some knockoff prompt engineering
|
|
|
|
| 59 |
|
| 60 |
# Spaces compatibility
|
| 61 |
try:
|
| 62 |
+
import spaces
|
| 63 |
+
SPACES_AVAILABLE = True
|
| 64 |
+
@spaces.GPU
|
| 65 |
+
def gpu_placeholder():
|
| 66 |
+
return "GPU satisfied"
|
| 67 |
except ImportError:
|
| 68 |
+
SPACES_AVAILABLE = False
|
| 69 |
|
| 70 |
class CreedBrattonAI:
|
| 71 |
+
"""Real Creed AI using Mark's trained model - GPU optimized"""
|
| 72 |
+
|
| 73 |
+
def __init__(self):
|
| 74 |
+
self.model = None
|
| 75 |
+
self.tokenizer = None
|
| 76 |
+
self.model_loaded = False
|
| 77 |
+
self.loading = False
|
| 78 |
+
self.device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 79 |
|
| 80 |
+
print(f"πΈ Initializing Creed AI")
|
| 81 |
+
print(f"π₯οΈ Device detected: {self.device}")
|
| 82 |
+
if torch.cuda.is_available():
|
| 83 |
+
print(f"π GPU: {torch.cuda.get_device_name()}")
|
| 84 |
+
print(f"πΎ GPU Memory: {torch.cuda.get_device_properties(0).total_memory // 1024**3} GB")
|
| 85 |
+
|
| 86 |
+
# Load model with proper GPU detection
|
| 87 |
+
self.load_model()
|
| 88 |
+
|
| 89 |
+
def load_model(self):
|
| 90 |
+
"""Load the model with GPU optimization when available"""
|
| 91 |
+
if self.loading or self.model_loaded:
|
| 92 |
+
return
|
| 93 |
|
| 94 |
+
self.loading = True
|
|
|
|
| 95 |
|
| 96 |
+
try:
|
| 97 |
+
print(f"π§ Loading Creed's consciousness on {self.device}...")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
+
# Load model and tokenizer
|
| 100 |
+
model_name = "phxdev/creed-qwen-0.5b-lora"
|
| 101 |
+
|
| 102 |
+
print("π¦ Loading tokenizer...")
|
| 103 |
+
self.tokenizer = AutoTokenizer.from_pretrained(
|
| 104 |
+
model_name,
|
| 105 |
+
trust_remote_code=True,
|
| 106 |
+
padding_side="left"
|
| 107 |
+
)
|
| 108 |
+
|
| 109 |
+
# Fix pad token issue
|
| 110 |
+
if self.tokenizer.pad_token is None:
|
| 111 |
+
self.tokenizer.pad_token = self.tokenizer.unk_token or "[PAD]"
|
| 112 |
+
print(f"π§ Set pad_token to: {self.tokenizer.pad_token}")
|
| 113 |
+
|
| 114 |
+
# Add Creed's custom tokens
|
| 115 |
+
custom_tokens = ["<thinking>", "<conspiracy>", "<tangent>"]
|
| 116 |
+
print(f"πΈ Adding Creed's custom tokens: {custom_tokens}")
|
| 117 |
+
|
| 118 |
+
num_added_tokens = self.tokenizer.add_tokens(custom_tokens)
|
| 119 |
+
print(f"β
Added {num_added_tokens} custom tokens")
|
| 120 |
+
|
| 121 |
+
print(f"π€ Loading model on {self.device}...")
|
| 122 |
+
|
| 123 |
+
# Load model with proper device handling
|
| 124 |
+
if self.device == "cuda":
|
| 125 |
+
self.model = AutoModelForCausalLM.from_pretrained(
|
| 126 |
model_name,
|
| 127 |
+
torch_dtype=torch.float16, # Use float16 for GPU efficiency
|
| 128 |
+
device_map="auto", # Auto device mapping for GPU
|
| 129 |
trust_remote_code=True,
|
| 130 |
+
low_cpu_mem_usage=True
|
| 131 |
)
|
| 132 |
+
# Explicitly ensure model is on CUDA
|
| 133 |
+
if self.model.device.type != "cuda":
|
| 134 |
+
print("π§ Explicitly moving model to CUDA...")
|
| 135 |
+
self.model = self.model.to(self.device)
|
| 136 |
+
else:
|
| 137 |
+
self.model = AutoModelForCausalLM.from_pretrained(
|
| 138 |
+
model_name,
|
| 139 |
+
torch_dtype=torch.float32, # Use float32 for CPU
|
| 140 |
+
device_map=None,
|
| 141 |
+
trust_remote_code=True,
|
| 142 |
+
low_cpu_mem_usage=True
|
| 143 |
+
)
|
| 144 |
+
self.model = self.model.to("cpu")
|
| 145 |
+
|
| 146 |
+
# Resize embeddings for custom tokens
|
| 147 |
+
if num_added_tokens > 0:
|
| 148 |
+
print(f"π§ Resizing model embeddings for {num_added_tokens} custom tokens")
|
| 149 |
+
self.model.resize_token_embeddings(len(self.tokenizer))
|
| 150 |
+
|
| 151 |
+
self.model.eval()
|
| 152 |
+
|
| 153 |
+
# Verify device placement
|
| 154 |
+
model_device = next(self.model.parameters()).device
|
| 155 |
+
print(f"π― Model is actually on: {model_device}")
|
| 156 |
+
|
| 157 |
+
self.model_loaded = True
|
| 158 |
+
self.loading = False
|
| 159 |
+
print(f"β
Creed's consciousness loaded on {model_device}!")
|
| 160 |
+
|
| 161 |
+
# GPU memory info
|
| 162 |
+
if self.device == "cuda" and torch.cuda.is_available():
|
| 163 |
+
print(f"π₯ GPU Memory Used: {torch.cuda.memory_allocated() // 1024**2} MB")
|
| 164 |
+
print(f"π GPU Memory Cached: {torch.cuda.memory_reserved() // 1024**2} MB")
|
| 165 |
+
|
| 166 |
+
except Exception as e:
|
| 167 |
+
print(f"β Error loading Creed model: {e}")
|
| 168 |
+
print("π Falling back to base model...")
|
| 169 |
+
try:
|
| 170 |
+
base_model = "Qwen/Qwen2.5-0.5B-Instruct"
|
| 171 |
+
self.tokenizer = AutoTokenizer.from_pretrained(base_model)
|
| 172 |
|
| 173 |
+
# Fix pad token for fallback too
|
| 174 |
if self.tokenizer.pad_token is None:
|
| 175 |
self.tokenizer.pad_token = self.tokenizer.unk_token or "[PAD]"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
|
|
|
|
| 177 |
if self.device == "cuda":
|
| 178 |
self.model = AutoModelForCausalLM.from_pretrained(
|
| 179 |
+
base_model,
|
| 180 |
+
torch_dtype=torch.float16,
|
| 181 |
+
device_map="auto"
|
|
|
|
|
|
|
| 182 |
)
|
|
|
|
| 183 |
if self.model.device.type != "cuda":
|
|
|
|
| 184 |
self.model = self.model.to(self.device)
|
| 185 |
else:
|
| 186 |
self.model = AutoModelForCausalLM.from_pretrained(
|
| 187 |
+
base_model,
|
| 188 |
+
torch_dtype=torch.float32,
|
| 189 |
+
device_map=None
|
|
|
|
|
|
|
| 190 |
)
|
| 191 |
self.model = self.model.to("cpu")
|
| 192 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
self.model.eval()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
self.model_loaded = True
|
| 195 |
+
model_device = next(self.model.parameters()).device
|
| 196 |
+
print(f"β
Fallback model loaded on {model_device}")
|
| 197 |
+
except Exception as fallback_error:
|
| 198 |
+
print(f"β Fallback also failed: {fallback_error}")
|
| 199 |
+
self.loading = False
|
| 200 |
+
|
| 201 |
+
@spaces.GPU if SPACES_AVAILABLE else lambda func: func
|
| 202 |
+
def generate_response_gpu(self, conversation: str) -> str:
|
| 203 |
+
"""Generate response using the loaded model with proper device handling"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 204 |
|
| 205 |
+
if not self.model_loaded:
|
| 206 |
+
return "β Model not loaded"
|
| 207 |
+
|
| 208 |
+
try:
|
| 209 |
+
print(f"π Input conversation length: {len(conversation)}")
|
| 210 |
+
print(f"π Input sample: {conversation[:200]}...")
|
| 211 |
+
|
| 212 |
+
# Ensure model is on the correct device
|
| 213 |
+
if self.device == "cuda" and self.model.device.type != "cuda":
|
| 214 |
+
print(f"π Moving model from {self.model.device} to {self.device}")
|
| 215 |
+
self.model = self.model.to(self.device)
|
| 216 |
+
|
| 217 |
+
# Tokenize input with attention mask
|
| 218 |
+
inputs = self.tokenizer(
|
| 219 |
+
conversation,
|
| 220 |
+
return_tensors="pt",
|
| 221 |
+
padding=True,
|
| 222 |
+
truncation=True,
|
| 223 |
+
max_length=1024, # Reduce max length to avoid issues
|
| 224 |
+
add_special_tokens=True
|
| 225 |
+
)
|
| 226 |
|
| 227 |
+
print(f"π Tokenized input_ids shape: {inputs['input_ids'].shape}")
|
| 228 |
+
print(f"π First few tokens: {inputs['input_ids'][0][:10]}")
|
| 229 |
+
|
| 230 |
+
# Move inputs to same device as model
|
| 231 |
+
input_ids = inputs['input_ids'].to(self.device)
|
| 232 |
+
attention_mask = inputs['attention_mask'].to(self.device)
|
| 233 |
+
|
| 234 |
+
print(f"π Model device: {self.model.device}, Input device: {input_ids.device}")
|
| 235 |
+
|
| 236 |
+
# Generate response with proper attention mask
|
| 237 |
+
with torch.no_grad():
|
| 238 |
+
outputs = self.model.generate(
|
| 239 |
+
input_ids=input_ids,
|
| 240 |
+
attention_mask=attention_mask, # Pass attention mask
|
| 241 |
+
max_new_tokens=100, # Reduce to debug
|
| 242 |
+
do_sample=True,
|
| 243 |
+
temperature=0.7, # Lower temperature
|
| 244 |
+
top_p=0.9,
|
| 245 |
+
top_k=50,
|
| 246 |
+
repetition_penalty=1.1,
|
| 247 |
+
pad_token_id=self.tokenizer.pad_token_id,
|
| 248 |
+
eos_token_id=self.tokenizer.eos_token_id,
|
| 249 |
+
use_cache=True
|
| 250 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
|
| 252 |
+
print(f"π Generated output shape: {outputs.shape}")
|
| 253 |
+
print(f"π Generated tokens: {outputs[0][-20:]}") # Last 20 tokens
|
| 254 |
+
|
| 255 |
+
# Decode response
|
| 256 |
+
full_response = self.tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 257 |
+
input_text = self.tokenizer.decode(input_ids[0], skip_special_tokens=True)
|
| 258 |
+
response = full_response[len(input_text):].strip()
|
| 259 |
+
|
| 260 |
+
print(f"π Raw response: {response[:200]}...")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 261 |
|
| 262 |
+
cleaned_response = self._clean_response(response)
|
| 263 |
+
print(f"π Cleaned response: {cleaned_response[:200]}...")
|
| 264 |
+
|
| 265 |
+
return cleaned_response
|
| 266 |
+
|
| 267 |
+
except Exception as e:
|
| 268 |
+
print(f"β Generation error: {e}")
|
| 269 |
+
import traceback
|
| 270 |
+
traceback.print_exc()
|
| 271 |
+
return f"πΈ *Creed scratches his head* Something weird happened... {str(e)[:100]}"
|
| 272 |
+
|
| 273 |
+
def generate_response(self, message: str, history: List[Dict]) -> Iterator[str]:
|
| 274 |
+
"""Generate response using the trained Creed model - works with messages format"""
|
| 275 |
+
|
| 276 |
+
if not self.model_loaded:
|
| 277 |
+
if self.loading:
|
| 278 |
+
yield "π§ Creed's consciousness is still loading... give me a moment..."
|
| 279 |
+
return
|
| 280 |
+
else:
|
| 281 |
+
yield "β Something went wrong loading Creed's mind. Try refreshing the page."
|
| 282 |
+
return
|
| 283 |
+
|
| 284 |
+
try:
|
| 285 |
+
# Convert messages format to simple history
|
| 286 |
+
formatted_history = []
|
| 287 |
+
if history:
|
| 288 |
+
for msg in history:
|
| 289 |
+
if msg.get('role') == 'user':
|
| 290 |
+
user_msg = msg.get('content', '')
|
| 291 |
+
# Look for the next assistant message
|
| 292 |
+
assistant_msg = ""
|
| 293 |
+
formatted_history.append([user_msg, assistant_msg])
|
| 294 |
+
elif msg.get('role') == 'assistant':
|
| 295 |
+
# Update the last entry with assistant response
|
| 296 |
+
if formatted_history:
|
| 297 |
+
formatted_history[-1][1] = msg.get('content', '')
|
| 298 |
+
|
| 299 |
+
# Format the conversation
|
| 300 |
+
conversation = self._format_conversation(message, formatted_history)
|
| 301 |
+
|
| 302 |
+
# Generate response using GPU function
|
| 303 |
+
response = self.generate_response_gpu(conversation)
|
| 304 |
+
|
| 305 |
+
# Stream the response word by word for effect
|
| 306 |
+
words = response.split()
|
| 307 |
+
current_response = ""
|
| 308 |
+
|
| 309 |
+
for word in words:
|
| 310 |
+
current_response += word + " "
|
| 311 |
+
time.sleep(0.05)
|
| 312 |
+
yield current_response.strip()
|
| 313 |
+
|
| 314 |
+
except Exception as e:
|
| 315 |
+
print(f"β Error generating response: {e}")
|
| 316 |
+
yield f"πΈ *Creed scratches his head* Something weird happened in my brain... {str(e)[:100]}"
|
| 317 |
+
|
| 318 |
+
def _format_conversation(self, message: str, history: List[List[str]]) -> str:
|
| 319 |
+
"""Format the conversation for the model with proper system prompt"""
|
| 320 |
+
|
| 321 |
+
# Comprehensive Creed system prompt
|
| 322 |
+
system_prompt = """You are Creed Bratton from The Office. You embody his complete personality and speaking patterns.
|
| 323 |
|
| 324 |
CORE IDENTITY:
|
| 325 |
- Former member of The Grass Roots (1960s rock band)
|
|
|
|
| 359 |
Remember: You're not trying to be helpful in a traditional sense - you're being Creed Bratton.
|
| 360 |
|
| 361 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 362 |
|
| 363 |
+
# Add conversation history
|
| 364 |
+
conversation = system_prompt
|
| 365 |
+
for user_msg, creed_msg in history[-4:]: # Keep recent context
|
| 366 |
+
if user_msg and creed_msg: # Only add complete exchanges
|
| 367 |
+
conversation += f"Human: {user_msg}\n"
|
| 368 |
+
conversation += f"Creed: {creed_msg}\n"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 369 |
|
| 370 |
+
# Add current message
|
| 371 |
+
conversation += f"Human: {message}\n"
|
| 372 |
+
conversation += "Creed:"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 373 |
|
| 374 |
+
return conversation
|
| 375 |
+
|
| 376 |
+
def _clean_response(self, response: str) -> str:
|
| 377 |
+
"""Clean up the model response and format custom tokens"""
|
|
|
|
| 378 |
|
| 379 |
+
# Remove common artifacts
|
| 380 |
+
response = response.replace("Human:", "").replace("Creed:", "")
|
| 381 |
+
|
| 382 |
+
# Format Creed's custom tokens for better UI display
|
| 383 |
+
response = response.replace("<thinking>", "π€ *thinking* ")
|
| 384 |
+
response = response.replace("</thinking>", "")
|
| 385 |
+
response = response.replace("<conspiracy>", "π΅οΈ *conspiracy mode* ")
|
| 386 |
+
response = response.replace("</conspiracy>", "")
|
| 387 |
+
response = response.replace("<tangent>", "π *tangent* ")
|
| 388 |
+
response = response.replace("</tangent>", "")
|
| 389 |
+
|
| 390 |
+
# Remove excessive whitespace
|
| 391 |
+
response = " ".join(response.split())
|
| 392 |
+
|
| 393 |
+
# Ensure it ends properly
|
| 394 |
+
if response and not response.endswith(('.', '!', '?', '...', '*')):
|
| 395 |
+
response += "."
|
| 396 |
+
|
| 397 |
+
return response
|
| 398 |
|
| 399 |
+
def creed_wisdom_tool(self, topic: str = "life") -> str:
|
| 400 |
+
"""MCP tool: Get Creed's wisdom on a topic"""
|
| 401 |
+
if not self.model_loaded:
|
| 402 |
+
return "π§ Creed's consciousness is still loading..."
|
| 403 |
+
|
| 404 |
+
prompt = f"Give me your wisdom about {topic}."
|
| 405 |
+
|
| 406 |
+
# Generate a one-shot response
|
| 407 |
+
final_response = ""
|
| 408 |
+
for response in self.generate_response(prompt, []):
|
| 409 |
+
final_response = response
|
| 410 |
+
|
| 411 |
+
return final_response
|
| 412 |
+
|
| 413 |
+
def cleanup_gpu_memory(self):
|
| 414 |
+
"""Clean up GPU memory if using CUDA"""
|
| 415 |
+
if self.device == "cuda" and torch.cuda.is_available():
|
| 416 |
+
torch.cuda.empty_cache()
|
| 417 |
+
print(f"π§Ή GPU Memory cleaned. Current: {torch.cuda.memory_allocated() // 1024**2} MB")
|
| 418 |
+
|
| 419 |
+
def creed_story_tool(self, situation: str = "mysterious") -> str:
|
| 420 |
+
"""MCP tool: Get a Creed story"""
|
| 421 |
+
if not self.model_loaded:
|
| 422 |
+
return "π§ Creed's consciousness is still loading..."
|
| 423 |
+
|
| 424 |
+
prompt = f"Tell me a {situation} story from your past."
|
| 425 |
+
|
| 426 |
+
# Generate a one-shot response
|
| 427 |
+
final_response = ""
|
| 428 |
+
for response in self.generate_response(prompt, []):
|
| 429 |
+
final_response = response
|
| 430 |
+
|
| 431 |
+
return final_response
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 432 |
|
| 433 |
+
def main():
|
| 434 |
+
"""Initialize and launch the real Creed AI with modern styling"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 435 |
|
| 436 |
+
print("πΈ Initializing REAL Creed Bratton AI...")
|
| 437 |
+
print("π‘ Loading Mark's trained model: phxdev/creed-qwen-0.5b-lora")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 438 |
|
| 439 |
+
# Initialize Creed AI
|
| 440 |
+
creed_ai = CreedBrattonAI()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 441 |
|
| 442 |
+
# Test the model with a simple input
|
| 443 |
+
if creed_ai.model_loaded:
|
| 444 |
+
print("π§ͺ Testing model with simple input...")
|
| 445 |
+
test_response = creed_ai.generate_response_gpu("Hello, test.")
|
| 446 |
+
print(f"π§ͺ Test response: {test_response}")
|
| 447 |
+
|
| 448 |
+
if "Woah:" in test_response or len(test_response) > 100 and any(ord(c) > 127 for c in test_response):
|
| 449 |
+
print("β Model is outputting garbage! Trying fallback...")
|
| 450 |
+
# Force fallback to base model
|
| 451 |
+
creed_ai.model_loaded = False
|
| 452 |
+
creed_ai.load_model()
|
| 453 |
+
|
| 454 |
+
if SPACES_AVAILABLE:
|
| 455 |
+
gpu_placeholder()
|
| 456 |
+
print("β
Spaces GPU compatibility enabled")
|
| 457 |
+
|
| 458 |
+
# Memory status if GPU available
|
| 459 |
+
if torch.cuda.is_available() and creed_ai.model_loaded:
|
| 460 |
+
print(f"π― Model device verification: {next(creed_ai.model.parameters()).device}")
|
| 461 |
+
print(f"π₯ Final GPU Memory: {torch.cuda.memory_allocated() // 1024**2} MB allocated")
|
| 462 |
+
print(f"π GPU Memory Reserved: {torch.cuda.memory_reserved() // 1024**2} MB reserved")
|
| 463 |
+
|
| 464 |
+
# Modern glassmorphism CSS
|
| 465 |
+
modern_css = """
|
| 466 |
+
/* Creed AI - Modern Glassmorphism Design */
|
| 467 |
+
:root {
|
| 468 |
+
--primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 469 |
+
--secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
|
| 470 |
+
--glass-bg: rgba(255, 255, 255, 0.08);
|
| 471 |
+
--glass-border: rgba(255, 255, 255, 0.18);
|
| 472 |
+
--text-primary: #ffffff;
|
| 473 |
+
--text-secondary: rgba(255, 255, 255, 0.8);
|
| 474 |
+
--accent-purple: #8b5cf6;
|
| 475 |
+
--accent-blue: #3b82f6;
|
| 476 |
+
--shadow-glow: 0 8px 32px rgba(139, 92, 246, 0.3);
|
| 477 |
+
}
|
| 478 |
+
|
| 479 |
+
/* Main container with animated background */
|
| 480 |
+
.gradio-container {
|
| 481 |
+
min-height: 100vh !important;
|
| 482 |
+
background: var(--primary-gradient) !important;
|
| 483 |
+
background-attachment: fixed !important;
|
| 484 |
+
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
|
| 485 |
+
color: var(--text-primary) !important;
|
| 486 |
+
padding: 20px !important;
|
| 487 |
+
position: relative !important;
|
| 488 |
+
overflow-x: hidden !important;
|
| 489 |
+
}
|
| 490 |
+
|
| 491 |
+
.gradio-container::before {
|
| 492 |
+
content: '';
|
| 493 |
+
position: fixed;
|
| 494 |
+
top: 0;
|
| 495 |
+
left: 0;
|
| 496 |
+
width: 100%;
|
| 497 |
+
height: 100%;
|
| 498 |
+
background:
|
| 499 |
+
radial-gradient(circle at 20% 80%, rgba(139, 92, 246, 0.3) 0%, transparent 50%),
|
| 500 |
+
radial-gradient(circle at 80% 20%, rgba(59, 130, 246, 0.3) 0%, transparent 50%),
|
| 501 |
+
radial-gradient(circle at 40% 40%, rgba(167, 139, 250, 0.2) 0%, transparent 50%);
|
| 502 |
+
pointer-events: none;
|
| 503 |
+
z-index: -1;
|
| 504 |
+
}
|
| 505 |
+
|
| 506 |
+
/* Floating particles animation */
|
| 507 |
+
.gradio-container::after {
|
| 508 |
+
content: '';
|
| 509 |
+
position: fixed;
|
| 510 |
+
top: 0;
|
| 511 |
+
left: 0;
|
| 512 |
+
width: 100%;
|
| 513 |
+
height: 100%;
|
| 514 |
+
background-image:
|
| 515 |
+
radial-gradient(2px 2px at 20px 30px, rgba(255, 255, 255, 0.3), transparent),
|
| 516 |
+
radial-gradient(2px 2px at 40px 70px, rgba(139, 92, 246, 0.4), transparent),
|
| 517 |
+
radial-gradient(1px 1px at 90px 40px, rgba(59, 130, 246, 0.3), transparent);
|
| 518 |
+
background-size: 120px 120px;
|
| 519 |
+
animation: float 20s ease-in-out infinite;
|
| 520 |
+
pointer-events: none;
|
| 521 |
+
z-index: -1;
|
| 522 |
+
}
|
| 523 |
+
|
| 524 |
+
@keyframes float {
|
| 525 |
+
0%, 100% { transform: translateY(0px) rotate(0deg); }
|
| 526 |
+
50% { transform: translateY(-20px) rotate(180deg); }
|
| 527 |
+
}
|
| 528 |
+
|
| 529 |
+
/* Header styling */
|
| 530 |
+
.header {
|
| 531 |
+
background: var(--glass-bg) !important;
|
| 532 |
+
backdrop-filter: blur(20px) !important;
|
| 533 |
+
border: 1px solid var(--glass-border) !important;
|
| 534 |
+
border-radius: 24px !important;
|
| 535 |
+
padding: 32px !important;
|
| 536 |
+
margin-bottom: 24px !important;
|
| 537 |
+
text-align: center !important;
|
| 538 |
+
box-shadow: var(--shadow-glow) !important;
|
| 539 |
+
position: relative !important;
|
| 540 |
+
overflow: hidden !important;
|
| 541 |
+
}
|
| 542 |
+
|
| 543 |
+
.header::before {
|
| 544 |
+
content: '';
|
| 545 |
+
position: absolute;
|
| 546 |
+
top: 0;
|
| 547 |
+
left: 0;
|
| 548 |
+
right: 0;
|
| 549 |
+
height: 1px;
|
| 550 |
+
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
|
| 551 |
+
}
|
| 552 |
+
|
| 553 |
+
.header h1 {
|
| 554 |
+
font-size: 36px !important;
|
| 555 |
+
font-weight: 700 !important;
|
| 556 |
+
background: linear-gradient(135deg, #ffffff 0%, #a855f7 50%, #3b82f6 100%) !important;
|
| 557 |
+
-webkit-background-clip: text !important;
|
| 558 |
+
-webkit-text-fill-color: transparent !important;
|
| 559 |
+
background-clip: text !important;
|
| 560 |
+
margin: 0 0 12px 0 !important;
|
| 561 |
+
text-shadow: 0 0 30px rgba(168, 85, 247, 0.5) !important;
|
| 562 |
+
}
|
| 563 |
+
|
| 564 |
+
.header p {
|
| 565 |
+
font-size: 16px !important;
|
| 566 |
+
color: var(--text-secondary) !important;
|
| 567 |
+
margin: 0 !important;
|
| 568 |
+
font-weight: 500 !important;
|
| 569 |
+
}
|
| 570 |
+
|
| 571 |
+
/* Info boxes with glass effect */
|
| 572 |
+
.info-box {
|
| 573 |
+
background: rgba(255, 255, 255, 0.06) !important;
|
| 574 |
+
backdrop-filter: blur(16px) !important;
|
| 575 |
+
border: 1px solid rgba(255, 255, 255, 0.12) !important;
|
| 576 |
+
border-radius: 16px !important;
|
| 577 |
+
padding: 20px !important;
|
| 578 |
+
margin: 16px 0 !important;
|
| 579 |
+
color: var(--text-secondary) !important;
|
| 580 |
+
font-size: 14px !important;
|
| 581 |
+
line-height: 1.6 !important;
|
| 582 |
+
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1) !important;
|
| 583 |
+
}
|
| 584 |
+
|
| 585 |
+
.status-box {
|
| 586 |
+
background: rgba(16, 185, 129, 0.1) !important;
|
| 587 |
+
backdrop-filter: blur(16px) !important;
|
| 588 |
+
border: 1px solid rgba(16, 185, 129, 0.3) !important;
|
| 589 |
+
border-radius: 16px !important;
|
| 590 |
+
padding: 16px 20px !important;
|
| 591 |
+
margin: 16px 0 !important;
|
| 592 |
+
color: #10b981 !important;
|
| 593 |
+
font-weight: 600 !important;
|
| 594 |
+
box-shadow: 0 4px 20px rgba(16, 185, 129, 0.2) !important;
|
| 595 |
+
}
|
| 596 |
+
|
| 597 |
+
/* Chat area styling */
|
| 598 |
+
.chat-area {
|
| 599 |
+
background: var(--glass-bg) !important;
|
| 600 |
+
backdrop-filter: blur(20px) !important;
|
| 601 |
+
border: 1px solid var(--glass-border) !important;
|
| 602 |
+
border-radius: 20px !important;
|
| 603 |
+
margin: 16px 0 !important;
|
| 604 |
+
overflow: hidden !important;
|
| 605 |
+
box-shadow: var(--shadow-glow) !important;
|
| 606 |
+
}
|
| 607 |
+
|
| 608 |
+
/* Tools section */
|
| 609 |
+
.tools-area {
|
| 610 |
+
background: var(--glass-bg) !important;
|
| 611 |
+
backdrop-filter: blur(20px) !important;
|
| 612 |
+
border: 1px solid var(--glass-border) !important;
|
| 613 |
+
border-radius: 20px !important;
|
| 614 |
+
padding: 28px !important;
|
| 615 |
+
margin: 24px 0 !important;
|
| 616 |
+
box-shadow: var(--shadow-glow) !important;
|
| 617 |
+
}
|
| 618 |
+
|
| 619 |
+
.tools-title {
|
| 620 |
+
font-size: 22px !important;
|
| 621 |
+
font-weight: 600 !important;
|
| 622 |
+
color: var(--text-primary) !important;
|
| 623 |
+
margin: 0 0 20px 0 !important;
|
| 624 |
+
padding-bottom: 12px !important;
|
| 625 |
+
border-bottom: 1px solid rgba(255, 255, 255, 0.2) !important;
|
| 626 |
+
background: linear-gradient(135deg, #ffffff 0%, #a855f7 100%) !important;
|
| 627 |
+
-webkit-background-clip: text !important;
|
| 628 |
+
-webkit-text-fill-color: transparent !important;
|
| 629 |
+
}
|
| 630 |
+
|
| 631 |
+
/* Form elements */
|
| 632 |
+
.gradio-textbox input,
|
| 633 |
+
.gradio-textbox textarea {
|
| 634 |
+
background: rgba(255, 255, 255, 0.08) !important;
|
| 635 |
+
backdrop-filter: blur(10px) !important;
|
| 636 |
+
border: 1px solid rgba(255, 255, 255, 0.16) !important;
|
| 637 |
+
color: var(--text-primary) !important;
|
| 638 |
+
border-radius: 12px !important;
|
| 639 |
+
padding: 12px 16px !important;
|
| 640 |
+
transition: all 0.3s ease !important;
|
| 641 |
+
font-size: 14px !important;
|
| 642 |
+
}
|
| 643 |
+
|
| 644 |
+
.gradio-textbox input:focus,
|
| 645 |
+
.gradio-textbox textarea:focus {
|
| 646 |
+
border-color: var(--accent-purple) !important;
|
| 647 |
+
outline: none !important;
|
| 648 |
+
box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.3) !important;
|
| 649 |
+
background: rgba(255, 255, 255, 0.12) !important;
|
| 650 |
+
}
|
| 651 |
+
|
| 652 |
+
.gradio-textbox input::placeholder,
|
| 653 |
+
.gradio-textbox textarea::placeholder {
|
| 654 |
+
color: rgba(255, 255, 255, 0.5) !important;
|
| 655 |
+
}
|
| 656 |
+
|
| 657 |
+
/* Labels */
|
| 658 |
+
.gradio-container label {
|
| 659 |
+
color: var(--text-secondary) !important;
|
| 660 |
+
font-weight: 500 !important;
|
| 661 |
+
font-size: 14px !important;
|
| 662 |
+
margin-bottom: 6px !important;
|
| 663 |
+
display: block !important;
|
| 664 |
+
}
|
| 665 |
+
|
| 666 |
+
/* Buttons */
|
| 667 |
+
.gradio-container button {
|
| 668 |
+
background: linear-gradient(135deg, var(--accent-purple) 0%, var(--accent-blue) 100%) !important;
|
| 669 |
+
color: var(--text-primary) !important;
|
| 670 |
+
border: none !important;
|
| 671 |
+
border-radius: 12px !important;
|
| 672 |
+
padding: 12px 24px !important;
|
| 673 |
+
font-weight: 600 !important;
|
| 674 |
+
cursor: pointer !important;
|
| 675 |
+
transition: all 0.3s ease !important;
|
| 676 |
+
box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4) !important;
|
| 677 |
+
backdrop-filter: blur(10px) !important;
|
| 678 |
+
min-height: 44px !important;
|
| 679 |
+
display: flex !important;
|
| 680 |
+
align-items: center !important;
|
| 681 |
+
justify-content: center !important;
|
| 682 |
+
}
|
| 683 |
+
|
| 684 |
+
.gradio-container button:hover {
|
| 685 |
+
transform: translateY(-2px) !important;
|
| 686 |
+
box-shadow: 0 8px 25px rgba(139, 92, 246, 0.6) !important;
|
| 687 |
+
background: linear-gradient(135deg, #9333ea 0%, #2563eb 100%) !important;
|
| 688 |
+
}
|
| 689 |
+
|
| 690 |
+
.gradio-container button:active {
|
| 691 |
+
transform: translateY(0px) !important;
|
| 692 |
+
}
|
| 693 |
+
|
| 694 |
+
/* Send button specific styling */
|
| 695 |
+
.gradio-container .gr-button {
|
| 696 |
+
background: linear-gradient(135deg, var(--accent-purple) 0%, var(--accent-blue) 100%) !important;
|
| 697 |
+
border: 1px solid rgba(255, 255, 255, 0.2) !important;
|
| 698 |
+
color: white !important;
|
| 699 |
+
font-weight: 600 !important;
|
| 700 |
+
text-transform: none !important;
|
| 701 |
+
letter-spacing: 0.5px !important;
|
| 702 |
+
}
|
| 703 |
+
|
| 704 |
+
/* Chatbot specific styling */
|
| 705 |
+
.gradio-chatbot {
|
| 706 |
+
background: transparent !important;
|
| 707 |
+
border: none !important;
|
| 708 |
+
}
|
| 709 |
+
|
| 710 |
+
/* Footer */
|
| 711 |
+
.footer {
|
| 712 |
+
text-align: center !important;
|
| 713 |
+
padding: 28px !important;
|
| 714 |
+
color: var(--text-secondary) !important;
|
| 715 |
+
background: var(--glass-bg) !important;
|
| 716 |
+
backdrop-filter: blur(20px) !important;
|
| 717 |
+
border: 1px solid var(--glass-border) !important;
|
| 718 |
+
border-radius: 20px !important;
|
| 719 |
+
margin-top: 32px !important;
|
| 720 |
+
box-shadow: var(--shadow-glow) !important;
|
| 721 |
+
}
|
| 722 |
+
|
| 723 |
+
/* Scrollbar styling */
|
| 724 |
+
::-webkit-scrollbar {
|
| 725 |
+
width: 8px;
|
| 726 |
+
}
|
| 727 |
+
|
| 728 |
+
::-webkit-scrollbar-track {
|
| 729 |
+
background: rgba(255, 255, 255, 0.05);
|
| 730 |
+
border-radius: 4px;
|
| 731 |
+
}
|
| 732 |
+
|
| 733 |
+
::-webkit-scrollbar-thumb {
|
| 734 |
+
background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
|
| 735 |
+
border-radius: 4px;
|
| 736 |
+
}
|
| 737 |
+
|
| 738 |
+
::-webkit-scrollbar-thumb:hover {
|
| 739 |
+
background: linear-gradient(135deg, #9333ea, #2563eb);
|
| 740 |
+
}
|
| 741 |
+
|
| 742 |
+
/* Responsive design */
|
| 743 |
+
@media (max-width: 768px) {
|
| 744 |
+
.gradio-container {
|
| 745 |
+
padding: 12px !important;
|
| 746 |
}
|
| 747 |
+
|
|
|
|
| 748 |
.header {
|
| 749 |
+
padding: 20px !important;
|
| 750 |
+
border-radius: 16px !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 751 |
}
|
| 752 |
+
|
| 753 |
.header h1 {
|
| 754 |
+
font-size: 28px !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 755 |
}
|
| 756 |
+
|
| 757 |
+
.tools-area,
|
| 758 |
+
.chat-area {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 759 |
border-radius: 16px !important;
|
| 760 |
padding: 20px !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 761 |
}
|
| 762 |
+
}
|
| 763 |
+
"""
|
| 764 |
|
| 765 |
+
# Create wrapper function for proper chat handling
|
| 766 |
+
def respond(message, history):
|
| 767 |
+
"""Response handler for Gradio messages format"""
|
| 768 |
+
for response_chunk in creed_ai.generate_response(message, history):
|
| 769 |
+
# Update the history with the current response in messages format
|
| 770 |
+
updated_history = history + [
|
| 771 |
+
{"role": "user", "content": message},
|
| 772 |
+
{"role": "assistant", "content": response_chunk}
|
| 773 |
+
]
|
| 774 |
+
yield "", updated_history
|
| 775 |
+
|
| 776 |
+
# Create the interface with modern theme
|
| 777 |
+
with gr.Blocks(
|
| 778 |
+
title="πΈ Creed Bratton AI",
|
| 779 |
+
css=modern_css,
|
| 780 |
+
theme=gr.themes.Base() # Use base theme for better CSS control
|
| 781 |
+
) as demo:
|
| 782 |
+
|
| 783 |
+
# Modern header
|
| 784 |
+
gr.HTML(f"""
|
| 785 |
+
<div class="header">
|
| 786 |
+
<h1>πΈ Creed Bratton AI</h1>
|
| 787 |
+
<p>Powered by phxdev/creed-qwen-0.5b-lora β’ Running on {'π GPU' if creed_ai.device == 'cuda' else 'π₯οΈ CPU'}</p>
|
| 788 |
+
</div>
|
| 789 |
+
""")
|
| 790 |
+
|
| 791 |
+
# Model info with glass styling
|
| 792 |
+
gr.HTML("""
|
| 793 |
+
<div class="info-box">
|
| 794 |
+
<strong>Model:</strong> phxdev/creed-qwen-0.5b-lora<br>
|
| 795 |
+
<strong>Base:</strong> Qwen 0.5B + LoRA fine-tuning<br>
|
| 796 |
+
<strong>Tokens:</strong> <thinking>, <conspiracy>, <tangent>
|
| 797 |
+
</div>
|
| 798 |
+
""")
|
| 799 |
+
|
| 800 |
+
# MCP status
|
| 801 |
+
if os.environ.get('GRADIO_MCP_ENABLED'):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 802 |
gr.HTML("""
|
| 803 |
+
<div class="status-box">
|
| 804 |
+
β MCP Server Active β’ Available as tool for Claude Desktop
|
|
|
|
|
|
|
| 805 |
</div>
|
| 806 |
""")
|
| 807 |
+
|
| 808 |
+
# Main chat interface with glass styling
|
| 809 |
+
with gr.Row(elem_classes="chat-area"):
|
| 810 |
+
chatbot = gr.Chatbot(
|
| 811 |
+
type='messages', # Use messages format (modern)
|
| 812 |
+
height=550,
|
| 813 |
+
show_copy_button=True,
|
| 814 |
+
show_share_button=False,
|
| 815 |
+
avatar_images=["π€", "πΈ"],
|
| 816 |
+
bubble_full_width=False,
|
| 817 |
+
show_label=False,
|
| 818 |
+
placeholder="πΈ Creed is ready...",
|
| 819 |
+
container=False
|
| 820 |
+
)
|
| 821 |
+
|
| 822 |
+
# Input with explicit send button
|
| 823 |
+
with gr.Row():
|
| 824 |
+
with gr.Column(scale=7):
|
| 825 |
+
msg = gr.Textbox(
|
| 826 |
+
placeholder="Ask Creed anything...",
|
| 827 |
+
container=False,
|
| 828 |
+
submit_btn=False, # Disable built-in submit
|
| 829 |
+
stop_btn=False
|
| 830 |
)
|
| 831 |
+
with gr.Column(scale=1, min_width=100):
|
| 832 |
+
send_btn = gr.Button("Send", variant="primary", size="lg")
|
| 833 |
+
|
| 834 |
+
# Wire up the chat - both Enter key and Send button
|
| 835 |
+
msg.submit(
|
| 836 |
+
respond,
|
| 837 |
+
inputs=[msg, chatbot],
|
| 838 |
+
outputs=[msg, chatbot],
|
| 839 |
+
show_progress="hidden"
|
| 840 |
+
)
|
| 841 |
+
|
| 842 |
+
send_btn.click(
|
| 843 |
+
respond,
|
| 844 |
+
inputs=[msg, chatbot],
|
| 845 |
+
outputs=[msg, chatbot],
|
| 846 |
+
show_progress="hidden"
|
| 847 |
+
)
|
| 848 |
+
|
| 849 |
+
# MCP Tools section with glass styling
|
| 850 |
+
with gr.Row(elem_classes="tools-area"):
|
| 851 |
+
gr.HTML('<div class="tools-title">π οΈ MCP Tools</div>')
|
| 852 |
|
|
|
|
| 853 |
with gr.Row():
|
| 854 |
+
with gr.Column():
|
| 855 |
+
wisdom_topic = gr.Textbox(
|
| 856 |
+
label="Wisdom Topic",
|
| 857 |
+
placeholder="life, business, relationships..."
|
|
|
|
|
|
|
| 858 |
)
|
| 859 |
+
wisdom_output = gr.Textbox(
|
| 860 |
+
label="Creed's Response",
|
| 861 |
+
interactive=False,
|
| 862 |
+
lines=3
|
| 863 |
+
)
|
| 864 |
+
wisdom_btn = gr.Button("Ask Creed", variant="primary")
|
| 865 |
+
|
| 866 |
+
with gr.Column():
|
| 867 |
+
story_situation = gr.Textbox(
|
| 868 |
+
label="Story Request",
|
| 869 |
+
placeholder="Tell me about..."
|
| 870 |
+
)
|
| 871 |
+
story_output = gr.Textbox(
|
| 872 |
+
label="Creed's Story",
|
| 873 |
+
interactive=False,
|
| 874 |
+
lines=3
|
| 875 |
+
)
|
| 876 |
+
story_btn = gr.Button("Get Story", variant="primary")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 877 |
|
| 878 |
+
# Wire up the tools
|
| 879 |
+
wisdom_btn.click(
|
| 880 |
+
creed_ai.creed_wisdom_tool,
|
| 881 |
+
inputs=[wisdom_topic],
|
| 882 |
+
outputs=[wisdom_output]
|
| 883 |
+
)
|
| 884 |
|
| 885 |
+
story_btn.click(
|
| 886 |
+
creed_ai.creed_story_tool,
|
| 887 |
+
inputs=[story_situation],
|
| 888 |
+
outputs=[story_output]
|
|
|
|
|
|
|
| 889 |
)
|
| 890 |
+
|
| 891 |
+
# Modern footer
|
| 892 |
+
gr.HTML("""
|
| 893 |
+
<div class="footer">
|
| 894 |
+
<strong>Creed Bratton AI</strong><br>
|
| 895 |
+
Model: phxdev/creed-qwen-0.5b-lora β’ Trained by Mark Scott<br>
|
| 896 |
+
<em>"Sometimes a guy's gotta ride the bull, am I right?"</em>
|
| 897 |
+
</div>
|
| 898 |
+
""")
|
| 899 |
+
|
| 900 |
+
# Launch with modern styling and public sharing
|
| 901 |
+
print("π Launching Real Creed AI with modern glassmorphism design...")
|
| 902 |
+
|
| 903 |
+
demo.launch(
|
| 904 |
+
ssr_mode=False,
|
| 905 |
+
server_name="0.0.0.0",
|
| 906 |
+
server_port=7860,
|
| 907 |
+
share=True, # Create public link
|
| 908 |
+
show_error=True
|
| 909 |
+
)
|
| 910 |
|
| 911 |
if __name__ == "__main__":
|
| 912 |
+
main()
|