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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
S.S.CROW PROTOCOL - GRADIO INTERFACE
|
| 3 |
+
Complete AI-powered analysis system with Transformers integration
|
| 4 |
+
"""
|
| 5 |
|
| 6 |
+
import gradio as gr
|
| 7 |
+
import torch
|
| 8 |
+
from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM
|
| 9 |
+
import json
|
| 10 |
+
import requests
|
| 11 |
+
from datetime import datetime
|
| 12 |
|
| 13 |
+
# ============================================
|
| 14 |
+
# CONFIGURATION
|
| 15 |
+
# ============================================
|
|
|
|
| 16 |
|
| 17 |
+
SSCROW_API = "http://localhost:3000/api/v1"
|
| 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 |
+
{data.get('response', 'No response')}
|
| 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 |
+
def send_email_api(to, subject, body):
|
| 213 |
+
"""Send email via SSCROW API"""
|
| 214 |
+
if not all([to, subject, body]):
|
| 215 |
+
return "β ERROR: All fields required (TO, SUBJECT, BODY)"
|
| 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 |
+
Total Messages: {data.get('count', 0)}
|
| 262 |
+
Unread: {data.get('unread', 0)}
|
| 263 |
+
|
| 264 |
+
"""
|
| 265 |
+
for msg in messages[:10]: # Show latest 10
|
| 266 |
+
status = "π΄ NEW" if not msg.get('read') else "β Read"
|
| 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 |
+
return output
|
| 275 |
+
else:
|
| 276 |
+
return f"β Failed to fetch inbox: HTTP {response.status_code}"
|
| 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 |
+
def seed_lattice_api():
|
| 284 |
+
"""Seed ZCF lattice via API"""
|
| 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 |
+
βοΈ HARDWARE
|
| 317 |
+
ββ Compute Device: {device.upper()}
|
| 318 |
+
ββ CUDA Available: {torch.cuda.is_available()}
|
| 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 |
+
)
|