Update SSCrow Ai
Browse files
SSCrow Ai
CHANGED
|
@@ -1,586 +1,67 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
Complete AI-powered analysis system with Transformers integration
|
| 4 |
-
"""
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM
|
| 9 |
-
import json
|
| 10 |
-
import requests
|
| 11 |
-
from datetime import datetime
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
#
|
| 15 |
-
|
| 16 |
|
| 17 |
-
|
| 18 |
-
OLLAMA_API = "http://localhost:11434/api/generate"
|
| 19 |
-
|
| 20 |
-
# S.S.CROW Constants
|
| 21 |
-
SSCROW_FREQUENCY = 80192
|
| 22 |
-
NEXUS_VALUE = 1166
|
| 23 |
-
PACKET_SIZE = 1.0 # kh
|
| 24 |
-
|
| 25 |
-
# ============================================
|
| 26 |
-
# AI MODEL INITIALIZATION
|
| 27 |
-
# ============================================
|
| 28 |
-
|
| 29 |
-
print("🔄 Initializing S.S.CROW AI Systems...")
|
| 30 |
-
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 31 |
-
print(f"⚡ Compute Device: {device.upper()}")
|
| 32 |
-
|
| 33 |
-
# Initialize sentiment analyzer
|
| 34 |
-
try:
|
| 35 |
-
sentiment_analyzer = pipeline(
|
| 36 |
-
"sentiment-analysis",
|
| 37 |
-
model="distilbert-base-uncased-finetuned-sst-2-english",
|
| 38 |
-
device=0 if device == "cuda" else -1
|
| 39 |
-
)
|
| 40 |
-
print("✓ Sentiment Analysis Module: ONLINE")
|
| 41 |
-
except Exception as e:
|
| 42 |
-
sentiment_analyzer = None
|
| 43 |
-
print(f"⚠ Sentiment Analysis Module: OFFLINE ({e})")
|
| 44 |
-
|
| 45 |
-
# Initialize text generator (smaller model for compatibility)
|
| 46 |
-
try:
|
| 47 |
-
generator = pipeline(
|
| 48 |
-
"text-generation",
|
| 49 |
-
model="distilgpt2",
|
| 50 |
-
device=0 if device == "cuda" else -1
|
| 51 |
-
)
|
| 52 |
-
print("✓ Text Generation Module: ONLINE")
|
| 53 |
-
except Exception as e:
|
| 54 |
-
generator = None
|
| 55 |
-
print(f"⚠ Text Generation Module: OFFLINE ({e})")
|
| 56 |
-
|
| 57 |
-
print("✓ S.S.CROW AI Systems Ready\n")
|
| 58 |
-
|
| 59 |
-
# ============================================
|
| 60 |
-
# CORE PROCESSING FUNCTIONS
|
| 61 |
-
# ============================================
|
| 62 |
-
|
| 63 |
-
def calculate_zcf_metrics(input_text):
|
| 64 |
-
"""Calculate ZCF field metrics based on input"""
|
| 65 |
-
# Use text length and content for deterministic calculations
|
| 66 |
-
text_hash = sum(ord(c) for c in input_text)
|
| 67 |
-
|
| 68 |
-
field_strength = (text_hash % 100) + 1
|
| 69 |
-
stability = min(100, (len(input_text) * 7) % 100 + 50)
|
| 70 |
-
resonance = (text_hash % 50) + 50
|
| 71 |
-
|
| 72 |
-
return {
|
| 73 |
-
"field_strength": field_strength,
|
| 74 |
-
"stability": stability,
|
| 75 |
-
"resonance": resonance,
|
| 76 |
-
"keyhole_alignment": "OPTIMAL" if stability > 75 else "CALIBRATING"
|
| 77 |
-
}
|
| 78 |
-
|
| 79 |
-
def process_intake(input_val):
|
| 80 |
-
"""Main processing function - S.S.CROW packet logic"""
|
| 81 |
-
if not input_val or not input_val.strip():
|
| 82 |
-
return "⚠ ERROR: No input detected. Awaiting transmission..."
|
| 83 |
-
|
| 84 |
-
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
| 85 |
-
|
| 86 |
-
# Calculate ZCF metrics
|
| 87 |
-
metrics = calculate_zcf_metrics(input_val)
|
| 88 |
-
|
| 89 |
-
# Build response
|
| 90 |
-
response = f"""╔════════════════════════════════════════╗
|
| 91 |
-
║ S.S.CROW PROTOCOL ANALYSIS ║
|
| 92 |
-
╚════════════════════════════════════════╝
|
| 93 |
-
|
| 94 |
-
⚡ TRANSMISSION RECEIVED
|
| 95 |
-
├─ Timestamp: {timestamp}
|
| 96 |
-
├─ Input Length: {len(input_val)} chars
|
| 97 |
-
└─ Packet Size: {PACKET_SIZE} kh
|
| 98 |
-
|
| 99 |
-
🔷 ZCF FIELD METRICS
|
| 100 |
-
├─ Field Strength: {metrics['field_strength']}%
|
| 101 |
-
├─ Stability Index: {metrics['stability']}%
|
| 102 |
-
├─ Resonance Level: {metrics['resonance']}%
|
| 103 |
-
└─ Keyhole Alignment: {metrics['keyhole_alignment']}
|
| 104 |
-
|
| 105 |
-
📡 SYSTEM STATUS
|
| 106 |
-
├─ S.S.CROW Frequency: {SSCROW_FREQUENCY} Hz
|
| 107 |
-
├─ Nexus Terminal Sum: {NEXUS_VALUE}
|
| 108 |
-
├─ Compute Device: {device.upper()}
|
| 109 |
-
└─ Status: OPERATIONAL
|
| 110 |
-
|
| 111 |
-
🎯 ANALYSIS COMPLETE
|
| 112 |
-
Input processed through geometric stress matrix.
|
| 113 |
-
Skeleton Keyhole geometry verified.
|
| 114 |
-
Ready for traversal sequence."""
|
| 115 |
-
|
| 116 |
-
return response
|
| 117 |
-
|
| 118 |
-
def ai_sentiment_analysis(text):
|
| 119 |
-
"""Analyze sentiment using Transformers"""
|
| 120 |
-
if not sentiment_analyzer:
|
| 121 |
-
return "⚠ Sentiment Analysis Module OFFLINE"
|
| 122 |
-
|
| 123 |
-
if not text or not text.strip():
|
| 124 |
-
return "⚠ No text provided"
|
| 125 |
-
|
| 126 |
-
try:
|
| 127 |
-
result = sentiment_analyzer(text[:512])[0] # Limit to 512 chars
|
| 128 |
-
label = result['label']
|
| 129 |
-
score = result['score']
|
| 130 |
-
|
| 131 |
-
return f"""╔════════════════════════════════════════╗
|
| 132 |
-
║ SENTIMENT ANALYSIS REPORT ║
|
| 133 |
-
╚════════════════════════════════════════╝
|
| 134 |
-
|
| 135 |
-
📊 CLASSIFICATION: {label}
|
| 136 |
-
📈 Confidence: {score:.2%}
|
| 137 |
-
|
| 138 |
-
🔍 INTERPRETATION:
|
| 139 |
-
{"Positive emotional resonance detected." if label == "POSITIVE" else "Negative emotional resonance detected."}
|
| 140 |
-
Field stability: {"HIGH" if score > 0.9 else "MODERATE" if score > 0.7 else "LOW"}
|
| 141 |
-
|
| 142 |
-
Device: {device.upper()}
|
| 143 |
-
Model: DistilBERT-SST2"""
|
| 144 |
-
except Exception as e:
|
| 145 |
-
return f"⚠ Analysis Error: {str(e)}"
|
| 146 |
-
|
| 147 |
-
def ai_text_generation(prompt):
|
| 148 |
-
"""Generate text using Transformers"""
|
| 149 |
-
if not generator:
|
| 150 |
-
return "⚠ Text Generation Module OFFLINE"
|
| 151 |
-
|
| 152 |
-
if not prompt or not prompt.strip():
|
| 153 |
-
return "⚠ No prompt provided"
|
| 154 |
-
|
| 155 |
-
try:
|
| 156 |
-
result = generator(
|
| 157 |
-
prompt,
|
| 158 |
-
max_length=150,
|
| 159 |
-
num_return_sequences=1,
|
| 160 |
-
temperature=0.7,
|
| 161 |
-
do_sample=True
|
| 162 |
-
)[0]['generated_text']
|
| 163 |
-
|
| 164 |
-
return f"""╔════════════════════════════════════════╗
|
| 165 |
-
║ AI TEXT GENERATION ║
|
| 166 |
-
╚════════════════════════════════════════╝
|
| 167 |
-
|
| 168 |
-
📝 GENERATED OUTPUT:
|
| 169 |
-
|
| 170 |
-
{result}
|
| 171 |
|
| 172 |
---
|
| 173 |
-
Device: {device.upper()}
|
| 174 |
-
Model: DistilGPT2
|
| 175 |
-
Temperature: 0.7"""
|
| 176 |
-
except Exception as e:
|
| 177 |
-
return f"⚠ Generation Error: {str(e)}"
|
| 178 |
-
|
| 179 |
-
def query_ollama(prompt, model="llama3"):
|
| 180 |
-
"""Query local Ollama instance"""
|
| 181 |
-
try:
|
| 182 |
-
response = requests.post(
|
| 183 |
-
OLLAMA_API,
|
| 184 |
-
json={
|
| 185 |
-
"model": model,
|
| 186 |
-
"prompt": prompt,
|
| 187 |
-
"stream": False,
|
| 188 |
-
"system": "You are the MULE-Link AI system. Provide technical analysis of ZCF field topology and geometric stress calculations."
|
| 189 |
-
},
|
| 190 |
-
timeout=60
|
| 191 |
-
)
|
| 192 |
-
|
| 193 |
-
if response.status_code == 200:
|
| 194 |
-
data = response.json()
|
| 195 |
-
return f"""╔════════════════════════════════════════╗
|
| 196 |
-
║ OLLAMA MULE-LINK RESPONSE ║
|
| 197 |
-
╚════════════════════════════════════════╝
|
| 198 |
|
| 199 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
|
| 201 |
---
|
| 202 |
-
Model: {model}
|
| 203 |
-
Status: ONLINE"""
|
| 204 |
-
else:
|
| 205 |
-
return f"⚠ Ollama returned status {response.status_code}"
|
| 206 |
-
|
| 207 |
-
except requests.exceptions.ConnectionError:
|
| 208 |
-
return "⚠ Cannot connect to Ollama. Ensure 'ollama serve' is running."
|
| 209 |
-
except Exception as e:
|
| 210 |
-
return f"⚠ Ollama Query Error: {str(e)}"
|
| 211 |
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
try:
|
| 218 |
-
response = requests.post(
|
| 219 |
-
f"{SSCROW_API}/send",
|
| 220 |
-
json={
|
| 221 |
-
"cmd": "SEND",
|
| 222 |
-
"to": to,
|
| 223 |
-
"subject": subject,
|
| 224 |
-
"body": body,
|
| 225 |
-
"timestamp": datetime.now().isoformat()
|
| 226 |
-
},
|
| 227 |
-
timeout=10
|
| 228 |
-
)
|
| 229 |
-
|
| 230 |
-
if response.status_code == 200:
|
| 231 |
-
data = response.json()
|
| 232 |
-
return f"""✓ TRANSMISSION DELIVERED
|
| 233 |
-
|
| 234 |
-
Email ID: {data.get('emailId', 'N/A')}
|
| 235 |
-
Timestamp: {data.get('timestamp', 'N/A')}
|
| 236 |
-
Status: {data.get('message', 'SENT')}"""
|
| 237 |
-
else:
|
| 238 |
-
return f"⚠ Transmission failed: HTTP {response.status_code}"
|
| 239 |
-
|
| 240 |
-
except requests.exceptions.ConnectionError:
|
| 241 |
-
return f"⚠ Cannot connect to SSCROW API at {SSCROW_API}"
|
| 242 |
-
except Exception as e:
|
| 243 |
-
return f"⚠ Email Error: {str(e)}"
|
| 244 |
-
|
| 245 |
-
def fetch_inbox_api():
|
| 246 |
-
"""Fetch inbox from SSCROW API"""
|
| 247 |
-
try:
|
| 248 |
-
response = requests.get(f"{SSCROW_API}/inbox", timeout=10)
|
| 249 |
-
|
| 250 |
-
if response.status_code == 200:
|
| 251 |
-
data = response.json()
|
| 252 |
-
messages = data.get('messages', [])
|
| 253 |
-
|
| 254 |
-
if not messages:
|
| 255 |
-
return "📥 INBOX EMPTY - No transmissions received"
|
| 256 |
-
|
| 257 |
-
output = f"""╔════════════════════════════════════════╗
|
| 258 |
-
║ SECURE MAILBOX ║
|
| 259 |
╚════════════════════════════════════════╝
|
| 260 |
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
output += f"""───────────────────────────────────────
|
| 268 |
-
{status} | {msg.get('timestamp', 'N/A')}
|
| 269 |
-
FROM: {msg.get('from', 'UNKNOWN')}
|
| 270 |
-
SUBJECT: {msg.get('subject', 'No Subject')}
|
| 271 |
-
BODY: {msg.get('body', '')[:100]}...
|
| 272 |
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
except requests.exceptions.ConnectionError:
|
| 279 |
-
return f"⚠ Cannot connect to SSCROW API at {SSCROW_API}"
|
| 280 |
-
except Exception as e:
|
| 281 |
-
return f"⚠ Inbox Error: {str(e)}"
|
| 282 |
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
try:
|
| 286 |
-
response = requests.post(
|
| 287 |
-
f"{SSCROW_API}/send",
|
| 288 |
-
json={"cmd": "SEED"},
|
| 289 |
-
timeout=10
|
| 290 |
-
)
|
| 291 |
-
|
| 292 |
-
if response.status_code == 200:
|
| 293 |
-
data = response.json()
|
| 294 |
-
return f"""⚡ LATTICE SEED COMPLETE
|
| 295 |
-
|
| 296 |
-
Status: {data.get('message', 'SUCCESS')}
|
| 297 |
-
Timestamp: {data.get('timestamp', 'N/A')}
|
| 298 |
-
|
| 299 |
-
ZCF topology initialized.
|
| 300 |
-
Skeleton Keyhole geometry active.
|
| 301 |
-
System ready for traversal."""
|
| 302 |
-
else:
|
| 303 |
-
return f"⚠ Lattice seeding failed: HTTP {response.status_code}"
|
| 304 |
-
|
| 305 |
-
except requests.exceptions.ConnectionError:
|
| 306 |
-
return f"⚠ Cannot connect to SSCROW API at {SSCROW_API}"
|
| 307 |
-
except Exception as e:
|
| 308 |
-
return f"⚠ Lattice Seed Error: {str(e)}"
|
| 309 |
-
|
| 310 |
-
def system_diagnostics():
|
| 311 |
-
"""Run system diagnostics"""
|
| 312 |
-
diagnostics = f"""╔════════════════════════════════════════╗
|
| 313 |
-
║ SYSTEM DIAGNOSTICS REPORT ║
|
| 314 |
╚════════════════════════════════════════╝
|
| 315 |
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
├─ GPU Count: {torch.cuda.device_count() if torch.cuda.is_available() else 0}
|
| 320 |
-
└─ GPU Name: {torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'N/A'}
|
| 321 |
-
|
| 322 |
-
🤖 AI MODULES
|
| 323 |
-
├─ Sentiment Analysis: {"ONLINE" if sentiment_analyzer else "OFFLINE"}
|
| 324 |
-
├─ Text Generation: {"ONLINE" if generator else "OFFLINE"}
|
| 325 |
-
└─ Model Device: {device.upper()}
|
| 326 |
-
|
| 327 |
-
📡 API ENDPOINTS
|
| 328 |
-
├─ SSCROW API: {SSCROW_API}
|
| 329 |
-
└─ Ollama API: {OLLAMA_API}
|
| 330 |
-
|
| 331 |
-
🔷 S.S.CROW CONSTANTS
|
| 332 |
-
├─ Frequency: {SSCROW_FREQUENCY} Hz
|
| 333 |
-
├─ Nexus Value: {NEXUS_VALUE}
|
| 334 |
-
└─ Packet Size: {PACKET_SIZE} kh
|
| 335 |
-
|
| 336 |
-
✓ All systems operational
|
| 337 |
-
Ready for ZCF exploitation protocol."""
|
| 338 |
-
|
| 339 |
-
return diagnostics
|
| 340 |
-
|
| 341 |
-
# ============================================
|
| 342 |
-
# GRADIO INTERFACE
|
| 343 |
-
# ============================================
|
| 344 |
-
|
| 345 |
-
with gr.Blocks(
|
| 346 |
-
theme=gr.themes.Base(
|
| 347 |
-
primary_hue="orange",
|
| 348 |
-
secondary_hue="amber"
|
| 349 |
-
),
|
| 350 |
-
css="""
|
| 351 |
-
.gradio-container {
|
| 352 |
-
font-family: 'Courier New', monospace !important;
|
| 353 |
-
background: #0a0a0a;
|
| 354 |
-
}
|
| 355 |
-
.header {
|
| 356 |
-
text-align: center;
|
| 357 |
-
padding: 20px;
|
| 358 |
-
background: black;
|
| 359 |
-
border: 2px solid #f59e0b;
|
| 360 |
-
margin-bottom: 20px;
|
| 361 |
-
}
|
| 362 |
-
.header h1 {
|
| 363 |
-
color: #fbbf24;
|
| 364 |
-
font-size: 28px;
|
| 365 |
-
letter-spacing: 4px;
|
| 366 |
-
margin: 0;
|
| 367 |
-
}
|
| 368 |
-
.header p {
|
| 369 |
-
color: #78350f;
|
| 370 |
-
font-size: 12px;
|
| 371 |
-
letter-spacing: 2px;
|
| 372 |
-
}
|
| 373 |
-
"""
|
| 374 |
-
) as demo:
|
| 375 |
-
|
| 376 |
-
# Header
|
| 377 |
-
gr.HTML("""
|
| 378 |
-
<div class="header">
|
| 379 |
-
<h1>⚡ S.S.CROW PROTOCOL ⚡</h1>
|
| 380 |
-
<p>CLASSIFIED // ZCF EXPLOITATION ANALYSIS SYSTEM</p>
|
| 381 |
-
</div>
|
| 382 |
-
""")
|
| 383 |
-
|
| 384 |
-
with gr.Tabs():
|
| 385 |
-
# TAB 1: Main Processing
|
| 386 |
-
with gr.Tab("🔷 ZCF Analysis"):
|
| 387 |
-
gr.Markdown("### S.S.CROW Packet Processing")
|
| 388 |
-
with gr.Row():
|
| 389 |
-
input_text = gr.Textbox(
|
| 390 |
-
label="INPUT TRANSMISSION",
|
| 391 |
-
placeholder="Enter data for ZCF field analysis...",
|
| 392 |
-
lines=5
|
| 393 |
-
)
|
| 394 |
-
with gr.Row():
|
| 395 |
-
process_btn = gr.Button("⚡ PROCESS PACKET", variant="primary")
|
| 396 |
-
with gr.Row():
|
| 397 |
-
output_text = gr.Textbox(
|
| 398 |
-
label="ANALYSIS REPORT",
|
| 399 |
-
lines=20,
|
| 400 |
-
interactive=False
|
| 401 |
-
)
|
| 402 |
-
|
| 403 |
-
process_btn.click(
|
| 404 |
-
fn=process_intake,
|
| 405 |
-
inputs=input_text,
|
| 406 |
-
outputs=output_text
|
| 407 |
-
)
|
| 408 |
-
|
| 409 |
-
# TAB 2: AI Sentiment Analysis
|
| 410 |
-
with gr.Tab("📊 Sentiment Analysis"):
|
| 411 |
-
gr.Markdown("### AI-Powered Sentiment Detection")
|
| 412 |
-
with gr.Row():
|
| 413 |
-
sentiment_input = gr.Textbox(
|
| 414 |
-
label="TEXT TO ANALYZE",
|
| 415 |
-
placeholder="Enter text for sentiment analysis...",
|
| 416 |
-
lines=5
|
| 417 |
-
)
|
| 418 |
-
with gr.Row():
|
| 419 |
-
sentiment_btn = gr.Button("🔍 ANALYZE SENTIMENT", variant="primary")
|
| 420 |
-
with gr.Row():
|
| 421 |
-
sentiment_output = gr.Textbox(
|
| 422 |
-
label="SENTIMENT REPORT",
|
| 423 |
-
lines=15,
|
| 424 |
-
interactive=False
|
| 425 |
-
)
|
| 426 |
-
|
| 427 |
-
sentiment_btn.click(
|
| 428 |
-
fn=ai_sentiment_analysis,
|
| 429 |
-
inputs=sentiment_input,
|
| 430 |
-
outputs=sentiment_output
|
| 431 |
-
)
|
| 432 |
-
|
| 433 |
-
# TAB 3: AI Text Generation
|
| 434 |
-
with gr.Tab("✍️ Text Generation"):
|
| 435 |
-
gr.Markdown("### AI Text Generation Engine")
|
| 436 |
-
with gr.Row():
|
| 437 |
-
gen_input = gr.Textbox(
|
| 438 |
-
label="PROMPT",
|
| 439 |
-
placeholder="Enter prompt for AI generation...",
|
| 440 |
-
lines=3
|
| 441 |
-
)
|
| 442 |
-
with gr.Row():
|
| 443 |
-
gen_btn = gr.Button("🤖 GENERATE TEXT", variant="primary")
|
| 444 |
-
with gr.Row():
|
| 445 |
-
gen_output = gr.Textbox(
|
| 446 |
-
label="GENERATED OUTPUT",
|
| 447 |
-
lines=15,
|
| 448 |
-
interactive=False
|
| 449 |
-
)
|
| 450 |
-
|
| 451 |
-
gen_btn.click(
|
| 452 |
-
fn=ai_text_generation,
|
| 453 |
-
inputs=gen_input,
|
| 454 |
-
outputs=gen_output
|
| 455 |
-
)
|
| 456 |
-
|
| 457 |
-
# TAB 4: Ollama Integration
|
| 458 |
-
with gr.Tab("🔗 MULE-Link (Ollama)"):
|
| 459 |
-
gr.Markdown("### Local Ollama Model Interface")
|
| 460 |
-
with gr.Row():
|
| 461 |
-
with gr.Column():
|
| 462 |
-
ollama_prompt = gr.Textbox(
|
| 463 |
-
label="QUERY",
|
| 464 |
-
placeholder="Ask the MULE-Link AI...",
|
| 465 |
-
lines=5
|
| 466 |
-
)
|
| 467 |
-
ollama_model = gr.Dropdown(
|
| 468 |
-
choices=["llama3", "llama2", "mistral", "phi"],
|
| 469 |
-
value="llama3",
|
| 470 |
-
label="MODEL"
|
| 471 |
-
)
|
| 472 |
-
with gr.Row():
|
| 473 |
-
ollama_btn = gr.Button("📡 QUERY MULE-LINK", variant="primary")
|
| 474 |
-
with gr.Row():
|
| 475 |
-
ollama_output = gr.Textbox(
|
| 476 |
-
label="MULE-LINK RESPONSE",
|
| 477 |
-
lines=20,
|
| 478 |
-
interactive=False
|
| 479 |
-
)
|
| 480 |
-
|
| 481 |
-
ollama_btn.click(
|
| 482 |
-
fn=query_ollama,
|
| 483 |
-
inputs=[ollama_prompt, ollama_model],
|
| 484 |
-
outputs=ollama_output
|
| 485 |
-
)
|
| 486 |
-
|
| 487 |
-
# TAB 5: Email System
|
| 488 |
-
with gr.Tab("📧 Secure Mail"):
|
| 489 |
-
gr.Markdown("### SSCROW Mail API Interface")
|
| 490 |
-
|
| 491 |
-
with gr.Row():
|
| 492 |
-
with gr.Column():
|
| 493 |
-
gr.Markdown("#### Send Transmission")
|
| 494 |
-
email_to = gr.Textbox(label="TO", placeholder="commander@sscrow.local")
|
| 495 |
-
email_subject = gr.Textbox(label="SUBJECT", placeholder="RE: ZCF Analysis")
|
| 496 |
-
email_body = gr.Textbox(label="BODY", placeholder="Enter message...", lines=5)
|
| 497 |
-
send_btn = gr.Button("📤 SEND EMAIL", variant="primary")
|
| 498 |
-
send_output = gr.Textbox(label="SEND STATUS", lines=5, interactive=False)
|
| 499 |
-
|
| 500 |
-
with gr.Column():
|
| 501 |
-
gr.Markdown("#### Inbox")
|
| 502 |
-
inbox_btn = gr.Button("📥 FETCH INBOX")
|
| 503 |
-
inbox_output = gr.Textbox(label="MAILBOX", lines=15, interactive=False)
|
| 504 |
-
|
| 505 |
-
send_btn.click(
|
| 506 |
-
fn=send_email_api,
|
| 507 |
-
inputs=[email_to, email_subject, email_body],
|
| 508 |
-
outputs=send_output
|
| 509 |
-
)
|
| 510 |
-
|
| 511 |
-
inbox_btn.click(
|
| 512 |
-
fn=fetch_inbox_api,
|
| 513 |
-
outputs=inbox_output
|
| 514 |
-
)
|
| 515 |
-
|
| 516 |
-
# TAB 6: System Control
|
| 517 |
-
with gr.Tab("⚙️ System Control"):
|
| 518 |
-
gr.Markdown("### System Diagnostics & Control")
|
| 519 |
-
|
| 520 |
-
with gr.Row():
|
| 521 |
-
diag_btn = gr.Button("🔍 RUN DIAGNOSTICS", variant="primary")
|
| 522 |
-
seed_btn = gr.Button("⚡ SEED LATTICE", variant="secondary")
|
| 523 |
-
|
| 524 |
-
with gr.Row():
|
| 525 |
-
system_output = gr.Textbox(
|
| 526 |
-
label="SYSTEM STATUS",
|
| 527 |
-
lines=25,
|
| 528 |
-
interactive=False
|
| 529 |
-
)
|
| 530 |
-
|
| 531 |
-
diag_btn.click(
|
| 532 |
-
fn=system_diagnostics,
|
| 533 |
-
outputs=system_output
|
| 534 |
-
)
|
| 535 |
-
|
| 536 |
-
seed_btn.click(
|
| 537 |
-
fn=seed_lattice_api,
|
| 538 |
-
outputs=system_output
|
| 539 |
-
)
|
| 540 |
-
|
| 541 |
-
# ============================================
|
| 542 |
-
# LAUNCH
|
| 543 |
-
# ============================================
|
| 544 |
-
|
| 545 |
-
if __name__ == "__main__":
|
| 546 |
-
print("\n╔════════════════════════════════════════╗")
|
| 547 |
-
print("║ S.S.CROW PROTOCOL INTERFACE ║")
|
| 548 |
-
print("╚════════════════════════════════════════╝\n")
|
| 549 |
-
print("🚀 Launching Gradio interface...")
|
| 550 |
-
print(f"⚡ Device: {device.upper()}")
|
| 551 |
-
print(f"📡 SSCROW API: {SSCROW_API}")
|
| 552 |
-
print(f"🔗 Ollama API: {OLLAMA_API}\n")
|
| 553 |
-
|
| 554 |
-
demo.launch(
|
| 555 |
-
server_name="0.0.0.0", # Accessible from network
|
| 556 |
-
server_port=7860,
|
| 557 |
-
share=False, # Set to True for public link
|
| 558 |
-
show_error=True
|
| 559 |
-
)# S.S.CROW PROTOCOL - Python Dependencies
|
| 560 |
-
# Install: pip install -r requirements.txt
|
| 561 |
-
|
| 562 |
-
# Core AI/ML Libraries
|
| 563 |
-
torch>=2.0.0
|
| 564 |
-
transformers>=4.30.0
|
| 565 |
-
gradio>=4.0.0
|
| 566 |
-
|
| 567 |
-
# API Communication
|
| 568 |
-
requests>=2.31.0
|
| 569 |
-
|
| 570 |
-
# Additional utilities
|
| 571 |
-
numpy>=1.24.0
|
| 572 |
-
scipy>=1.11.0
|
| 573 |
-
|
| 574 |
-
# Optional: Accelerate for faster inference
|
| 575 |
-
accelerate>=0.20.0
|
| 576 |
-
|
| 577 |
-
# Optional: Better CUDA support
|
| 578 |
-
# Only install if you have NVIDIA GPU
|
| 579 |
-
# nvidia-cuda-runtime-cu12>=12.0.0mkdir sscrow-ai
|
| 580 |
-
cd sscrow-ai # Windows
|
| 581 |
-
python -m venv venv
|
| 582 |
-
venv\Scripts\activate
|
| 583 |
|
| 584 |
-
|
| 585 |
-
python3 -m venv venv
|
| 586 |
-
source venv/bin/activatepip install -r requirements.txtpython app.py
|
|
|
|
| 1 |
+
# 1. Install dependencies (one time, 5-15 min)
|
| 2 |
+
pip install -r requirements_unified.txt
|
|
|
|
|
|
|
| 3 |
|
| 4 |
+
# 2. Run the system
|
| 5 |
+
python sscrow_unified.py
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
# 3. Open browser
|
| 8 |
+
# Visit: http://localhost:7860
|
| 9 |
+
```
|
| 10 |
|
| 11 |
+
**That's it!** 🎊
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
+
## 🔥 What Makes This Special
|
| 16 |
+
|
| 17 |
+
### **Fully Integrated:**
|
| 18 |
+
- ✅ No separate servers to manage
|
| 19 |
+
- ✅ Flask API embedded inside Gradio app
|
| 20 |
+
- ✅ Everything starts with ONE command
|
| 21 |
+
- ✅ Auto-starts API server in background thread
|
| 22 |
+
- ✅ All features work out of the box
|
| 23 |
+
|
| 24 |
+
### **Smart Features:**
|
| 25 |
+
- ✅ Auto-detects GPU/CPU
|
| 26 |
+
- ✅ Graceful fallbacks if AI offline
|
| 27 |
+
- ✅ In-memory email storage
|
| 28 |
+
- ✅ Network accessible (0.0.0.0)
|
| 29 |
+
- ✅ Clean error messages
|
| 30 |
+
|
| 31 |
+
### **6 Powerful Tabs:**
|
| 32 |
+
1. **🔷 ZCF Analysis** - Field metrics & calculations
|
| 33 |
+
2. **📊 Sentiment** - AI emotion detection
|
| 34 |
+
3. **✍️ Text Gen** - AI writing
|
| 35 |
+
4. **🔗 MULE-Link** - Ollama integration
|
| 36 |
+
5. **📧 Secure Mail** - Send/receive emails
|
| 37 |
+
6. **⚙️ System** - Diagnostics & control
|
| 38 |
|
| 39 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
+
## 📊 When You Run It:
|
| 42 |
+
```
|
| 43 |
+
╔════════════════════════════════════════╗
|
| 44 |
+
║ S.S.CROW PROTOCOL INITIALIZATION ║
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
╚════════════════════════════════════════╝
|
| 46 |
|
| 47 |
+
🔄 Initializing AI Systems...
|
| 48 |
+
⚡ Compute Device: CPU
|
| 49 |
+
📥 Loading Sentiment Analysis Model...
|
| 50 |
+
✓ Sentiment Analysis: ONLINE
|
| 51 |
+
📥 Loading Text Generation Model...
|
| 52 |
+
✓ Text Generation: ONLINE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
+
✓ AI Systems Ready
|
| 55 |
+
🚀 Starting Embedded API Server...
|
| 56 |
+
* Running on http://0.0.0.0:3000
|
| 57 |
+
✓ API Server Running on http://localhost:3000
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
+
╔════════════════════════════════════════╗
|
| 60 |
+
║ LAUNCHING GRADIO INTERFACE ║
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
╚════════════════════════════════════════╝
|
| 62 |
|
| 63 |
+
⚡ Device: CPU
|
| 64 |
+
📡 Embedded API: http://localhost:3000
|
| 65 |
+
🌐 Gradio UI: http://localhost:7860
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
+
Running on local URL: http://127.0.0.1:7860
|
|
|
|
|
|