Spaces:
Runtime error
Runtime error
GitHub Copilot commited on
Commit ·
27905ae
1
Parent(s): 86c7ee4
Tension Web topology, builder operations doc, casual chat
Browse files- app.py +142 -323
- logos/docs/builder_operations.md +109 -0
app.py
CHANGED
|
@@ -1,9 +1,7 @@
|
|
| 1 |
"""
|
| 2 |
-
LOGOS v1.0 -
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
Primary: Chat Interface (Neural Router)
|
| 6 |
-
Secondary: Concentric Network Topology
|
| 7 |
"""
|
| 8 |
|
| 9 |
import gradio as gr
|
|
@@ -17,21 +15,18 @@ import threading
|
|
| 17 |
import subprocess
|
| 18 |
import requests
|
| 19 |
|
| 20 |
-
# Ensure logos package is importable
|
| 21 |
current_dir = os.path.dirname(os.path.abspath(__file__))
|
| 22 |
if current_dir not in sys.path:
|
| 23 |
sys.path.insert(0, current_dir)
|
| 24 |
|
| 25 |
-
# --- LOGOS CORE
|
| 26 |
MTL_AVAILABLE = False
|
| 27 |
try:
|
| 28 |
from logos.mtl.interpreter import MTLInterpreter
|
| 29 |
MTL_AVAILABLE = True
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
print(f"[LOGOS] MTL not available: {e}")
|
| 33 |
|
| 34 |
-
# --- NEURAL ROUTER (Background) ---
|
| 35 |
ROUTER_URL = "http://localhost:5000"
|
| 36 |
|
| 37 |
def start_neural_router():
|
|
@@ -39,382 +34,206 @@ def start_neural_router():
|
|
| 39 |
subprocess.Popen(
|
| 40 |
[sys.executable, "-m", "logos.server"],
|
| 41 |
env={**os.environ, "PYTHONPATH": current_dir},
|
| 42 |
-
stdout=subprocess.DEVNULL,
|
| 43 |
-
stderr=subprocess.DEVNULL
|
| 44 |
)
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
print(f"[LOGOS] Router failed: {e}")
|
| 48 |
|
| 49 |
threading.Thread(target=start_neural_router, daemon=True).start()
|
| 50 |
|
| 51 |
# =============================================================================
|
| 52 |
-
#
|
| 53 |
-
# =============================================================================
|
| 54 |
-
CUSTOM_CSS = """
|
| 55 |
-
.gradio-container {
|
| 56 |
-
background: linear-gradient(135deg, #0a0e17 0%, #1a1f2e 100%) !important;
|
| 57 |
-
}
|
| 58 |
-
|
| 59 |
-
.chat-container {
|
| 60 |
-
border: 1px solid rgba(0, 255, 234, 0.2);
|
| 61 |
-
border-radius: 12px;
|
| 62 |
-
background: rgba(17, 24, 39, 0.95);
|
| 63 |
-
}
|
| 64 |
-
|
| 65 |
-
.header-gradient {
|
| 66 |
-
background: linear-gradient(90deg, #00ffea, #9d4edd, #ff0055);
|
| 67 |
-
-webkit-background-clip: text;
|
| 68 |
-
-webkit-text-fill-color: transparent;
|
| 69 |
-
font-weight: 800;
|
| 70 |
-
}
|
| 71 |
-
|
| 72 |
-
.status-online { color: #00ffea; }
|
| 73 |
-
.status-offline { color: #ff0055; }
|
| 74 |
-
|
| 75 |
-
.topology-info {
|
| 76 |
-
background: rgba(17, 24, 39, 0.9);
|
| 77 |
-
border: 1px solid rgba(157, 78, 221, 0.3);
|
| 78 |
-
border-radius: 8px;
|
| 79 |
-
padding: 1rem;
|
| 80 |
-
}
|
| 81 |
-
"""
|
| 82 |
-
|
| 83 |
-
# =============================================================================
|
| 84 |
-
# CHAT FUNCTIONS
|
| 85 |
# =============================================================================
|
| 86 |
-
def
|
| 87 |
-
"""
|
| 88 |
if not message.strip():
|
| 89 |
return history
|
| 90 |
|
| 91 |
-
# Add user message
|
| 92 |
history = history + [[message, None]]
|
|
|
|
| 93 |
|
| 94 |
try:
|
| 95 |
-
# Try
|
| 96 |
-
payload = {
|
| 97 |
-
"messages": [{"role": "user", "content": message}],
|
| 98 |
-
"model": "logos-matroska-router"
|
| 99 |
-
}
|
| 100 |
resp = requests.post(f"{ROUTER_URL}/v1/chat/completions", json=payload, timeout=60)
|
| 101 |
-
|
| 102 |
if resp.status_code == 200:
|
| 103 |
-
|
| 104 |
-
else:
|
| 105 |
-
bot_response = f"Router Error: {resp.status_code}"
|
| 106 |
-
except requests.exceptions.ConnectionError:
|
| 107 |
-
# Router offline - try MTL locally
|
| 108 |
-
if MTL_AVAILABLE and message.strip().startswith("("):
|
| 109 |
-
try:
|
| 110 |
-
mtl = MTLInterpreter()
|
| 111 |
-
result = mtl.execute(message)
|
| 112 |
-
bot_response = f"[MTL Direct] {result}"
|
| 113 |
-
except Exception as e:
|
| 114 |
-
bot_response = f"[MTL Error] {e}"
|
| 115 |
else:
|
| 116 |
-
|
| 117 |
-
except
|
| 118 |
-
|
| 119 |
|
| 120 |
-
history[-1][1] =
|
| 121 |
return history
|
| 122 |
|
| 123 |
-
def get_router_status():
|
| 124 |
-
"""Check if Neural Router is online."""
|
| 125 |
-
try:
|
| 126 |
-
resp = requests.get(f"{ROUTER_URL}/v1", timeout=2)
|
| 127 |
-
if resp.status_code == 200:
|
| 128 |
-
data = resp.json()
|
| 129 |
-
return f"🟢 ONLINE | {data.get('system', 'LOGOS')}"
|
| 130 |
-
return "🟡 Partial"
|
| 131 |
-
except:
|
| 132 |
-
return "🔴 OFFLINE"
|
| 133 |
-
|
| 134 |
# =============================================================================
|
| 135 |
-
#
|
| 136 |
# =============================================================================
|
| 137 |
-
def
|
| 138 |
"""
|
| 139 |
-
|
| 140 |
-
|
|
|
|
| 141 |
"""
|
| 142 |
fig = go.Figure()
|
| 143 |
|
| 144 |
-
#
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
3:
|
| 148 |
-
|
| 149 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
}
|
| 151 |
|
| 152 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
|
| 154 |
-
# Draw
|
| 155 |
-
for
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
# Mark primes with larger dots
|
| 163 |
-
is_prime = [sympy.isprime(n) for n in nums]
|
| 164 |
-
sizes = [16 if p else 6 for p in is_prime]
|
| 165 |
-
colors = [lane_colors[residue] if p else '#444' for p in is_prime]
|
| 166 |
|
| 167 |
fig.add_trace(go.Scatterpolar(
|
| 168 |
-
r=r,
|
| 169 |
-
theta=
|
| 170 |
-
mode='markers',
|
| 171 |
-
marker=dict(color=
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
name=
|
|
|
|
|
|
|
| 176 |
))
|
| 177 |
|
| 178 |
-
#
|
| 179 |
-
for
|
| 180 |
-
r_val = math.log10(decade)
|
| 181 |
fig.add_trace(go.Scatterpolar(
|
| 182 |
-
r=[
|
| 183 |
-
theta=
|
| 184 |
mode='lines',
|
| 185 |
-
line=dict(color='rgba(255,255,255,0.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
showlegend=False,
|
| 187 |
hoverinfo='skip'
|
| 188 |
))
|
| 189 |
|
| 190 |
fig.update_layout(
|
| 191 |
-
paper_bgcolor='
|
| 192 |
-
plot_bgcolor='
|
| 193 |
-
showlegend=
|
| 194 |
-
legend=dict(
|
| 195 |
-
font=dict(color='white', size=11),
|
| 196 |
-
bgcolor='rgba(17,24,39,0.8)',
|
| 197 |
-
bordercolor='rgba(255,255,255,0.1)',
|
| 198 |
-
x=0.82, y=0.98
|
| 199 |
-
),
|
| 200 |
polar=dict(
|
| 201 |
-
radialaxis=dict(
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
ticktext=['1', '10', '100'],
|
| 205 |
-
tickvals=[0, 1, 2],
|
| 206 |
-
gridcolor='rgba(255,255,255,0.1)',
|
| 207 |
-
tickfont=dict(color='#666')
|
| 208 |
-
),
|
| 209 |
-
angularaxis=dict(
|
| 210 |
-
visible=True,
|
| 211 |
-
gridcolor='rgba(255,255,255,0.1)',
|
| 212 |
-
tickfont=dict(color='#666')
|
| 213 |
-
),
|
| 214 |
-
bgcolor='rgba(10,14,23,0.95)'
|
| 215 |
),
|
| 216 |
-
margin=dict(l=
|
| 217 |
-
height=
|
| 218 |
title=dict(
|
| 219 |
-
text="
|
| 220 |
-
font=dict(color='#00ffea', size=
|
| 221 |
x=0.5
|
| 222 |
)
|
| 223 |
)
|
| 224 |
return fig
|
| 225 |
|
| 226 |
# =============================================================================
|
| 227 |
-
#
|
| 228 |
# =============================================================================
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
return "Enter MTL code"
|
| 234 |
-
try:
|
| 235 |
-
mtl = MTLInterpreter()
|
| 236 |
-
result = mtl.execute(code)
|
| 237 |
-
return f">>> {result}"
|
| 238 |
-
except Exception as e:
|
| 239 |
-
return f"Error: {e}"
|
| 240 |
|
| 241 |
# =============================================================================
|
| 242 |
-
#
|
| 243 |
# =============================================================================
|
| 244 |
-
with gr.Blocks(css=
|
| 245 |
|
| 246 |
-
# HEADER
|
| 247 |
gr.HTML("""
|
| 248 |
-
<div style="text-align:
|
| 249 |
-
<h1 style="
|
| 250 |
-
|
| 251 |
-
</h1>
|
| 252 |
-
<p style="color: #6b7280; margin: 0.5rem 0;">
|
| 253 |
-
Logarithmic Ordering Generation Operating Software
|
| 254 |
-
</p>
|
| 255 |
</div>
|
| 256 |
""")
|
| 257 |
|
| 258 |
-
# MAIN TABS - Chat is PRIMARY
|
| 259 |
with gr.Tabs():
|
| 260 |
|
| 261 |
-
#
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
with gr.Row():
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
label="Neural Router",
|
| 269 |
-
height=450,
|
| 270 |
-
elem_classes=["chat-container"]
|
| 271 |
-
)
|
| 272 |
-
with gr.Row():
|
| 273 |
-
msg = gr.Textbox(
|
| 274 |
-
label="Message",
|
| 275 |
-
placeholder="Ask LOGOS anything... or enter MTL: (mult [2] [3])",
|
| 276 |
-
scale=5
|
| 277 |
-
)
|
| 278 |
-
send_btn = gr.Button("Send", variant="primary", scale=1)
|
| 279 |
-
|
| 280 |
-
with gr.Row():
|
| 281 |
-
clear_btn = gr.Button("Clear", size="sm")
|
| 282 |
-
status_txt = gr.Textbox(
|
| 283 |
-
label="Router Status",
|
| 284 |
-
value=get_router_status(),
|
| 285 |
-
interactive=False,
|
| 286 |
-
scale=2
|
| 287 |
-
)
|
| 288 |
-
|
| 289 |
-
with gr.Column(scale=1):
|
| 290 |
-
gr.Markdown("""
|
| 291 |
-
### Quick Commands
|
| 292 |
-
|
| 293 |
-
**MTL Examples:**
|
| 294 |
-
```
|
| 295 |
-
(mult [2] [3])
|
| 296 |
-
(or [17] [19])
|
| 297 |
-
(relate [17] [19])
|
| 298 |
-
```
|
| 299 |
-
|
| 300 |
-
**Swarm Delegation:**
|
| 301 |
-
```
|
| 302 |
-
SWARM: analyze project
|
| 303 |
-
```
|
| 304 |
-
|
| 305 |
-
**Special Triggers:**
|
| 306 |
-
- YouTube URLs → Video Atomizer
|
| 307 |
-
- Web URLs → Web Atomizer
|
| 308 |
-
- `mcp:` → MCP Agent
|
| 309 |
-
""")
|
| 310 |
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
)
|
| 315 |
-
send_btn.click(chat_with_router, [msg, chatbot], chatbot).then(
|
| 316 |
-
lambda: "", None, msg
|
| 317 |
-
)
|
| 318 |
-
clear_btn.click(lambda: [], None, chatbot)
|
| 319 |
|
| 320 |
-
#
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
with gr.Column(scale=1):
|
| 332 |
-
gr.Markdown("""
|
| 333 |
-
### Concentric Topology
|
| 334 |
-
|
| 335 |
-
<div class="topology-info">
|
| 336 |
-
|
| 337 |
-
**Structure:**
|
| 338 |
-
- Rings = Decades (Mod 10)
|
| 339 |
-
- Lanes = Prime residues
|
| 340 |
-
|
| 341 |
-
**Prime Lanes:**
|
| 342 |
-
- 🔵 **1** - ends in 1
|
| 343 |
-
- 🟣 **3** - ends in 3
|
| 344 |
-
- 🟡 **7** - ends in 7
|
| 345 |
-
- 🟢 **9** - ends in 9
|
| 346 |
-
|
| 347 |
-
**Key Insight:**
|
| 348 |
-
All primes > 5 must end in 1, 3, 7, or 9.
|
| 349 |
-
|
| 350 |
-
Large dots = **Primes**
|
| 351 |
-
Small dots = **Composites**
|
| 352 |
-
|
| 353 |
-
</div>
|
| 354 |
-
""")
|
| 355 |
-
|
| 356 |
-
refresh_btn = gr.Button("Refresh Topology")
|
| 357 |
-
refresh_btn.click(
|
| 358 |
-
lambda: create_concentric_topology(),
|
| 359 |
-
outputs=topology_plot
|
| 360 |
-
)
|
| 361 |
|
| 362 |
-
#
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
with gr.Column(scale=2):
|
| 368 |
-
mtl_input = gr.Textbox(
|
| 369 |
-
label="MTL Code",
|
| 370 |
-
placeholder="(mult [2] [3])",
|
| 371 |
-
value="(mult [2] [3])",
|
| 372 |
-
lines=3
|
| 373 |
-
)
|
| 374 |
-
mtl_run = gr.Button("Execute", variant="primary")
|
| 375 |
-
mtl_output = gr.Textbox(label="Result", lines=2)
|
| 376 |
-
|
| 377 |
-
gr.Examples(
|
| 378 |
-
examples=[
|
| 379 |
-
["(mult [2] [3])"],
|
| 380 |
-
["(or [2] [3])"],
|
| 381 |
-
["(and [6] [10])"],
|
| 382 |
-
["(relate [17] [19])"],
|
| 383 |
-
["(not [6] [6] [42])"],
|
| 384 |
-
],
|
| 385 |
-
inputs=mtl_input
|
| 386 |
-
)
|
| 387 |
-
|
| 388 |
-
with gr.Column(scale=1):
|
| 389 |
-
gr.Markdown("""
|
| 390 |
-
### MTL Reference
|
| 391 |
-
|
| 392 |
-
| Operator | Function |
|
| 393 |
-
|:---------|:---------|
|
| 394 |
-
| `mult` | Multiply |
|
| 395 |
-
| `or` | LCM |
|
| 396 |
-
| `and` | GCD |
|
| 397 |
-
| `not` | Steering |
|
| 398 |
-
| `relate` | Synapse |
|
| 399 |
-
|
| 400 |
-
**Genesis Primes:**
|
| 401 |
-
- [2] MECHANISM
|
| 402 |
-
- [3] RESULT
|
| 403 |
-
- [7] PERSIST
|
| 404 |
-
- [13] RELATE
|
| 405 |
-
- [17] IMAGE
|
| 406 |
-
- [19] TEXT
|
| 407 |
-
""")
|
| 408 |
|
| 409 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 410 |
|
| 411 |
-
|
| 412 |
-
gr.HTML("""
|
| 413 |
-
<div style="text-align: center; padding: 1rem 0; color: #4b5563; font-size: 0.8rem;">
|
| 414 |
-
LOGOS v1.0 • Computing = Routing • Arithmetic is Architecture
|
| 415 |
-
</div>
|
| 416 |
-
""")
|
| 417 |
|
| 418 |
-
# LAUNCH
|
| 419 |
if __name__ == "__main__":
|
| 420 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
| 1 |
"""
|
| 2 |
+
LOGOS v1.0 - Hugging Face Space
|
| 3 |
+
Primary: Chat (casual language)
|
| 4 |
+
Secondary: Mod-10 Tension Web
|
|
|
|
|
|
|
| 5 |
"""
|
| 6 |
|
| 7 |
import gradio as gr
|
|
|
|
| 15 |
import subprocess
|
| 16 |
import requests
|
| 17 |
|
|
|
|
| 18 |
current_dir = os.path.dirname(os.path.abspath(__file__))
|
| 19 |
if current_dir not in sys.path:
|
| 20 |
sys.path.insert(0, current_dir)
|
| 21 |
|
| 22 |
+
# --- LOGOS CORE ---
|
| 23 |
MTL_AVAILABLE = False
|
| 24 |
try:
|
| 25 |
from logos.mtl.interpreter import MTLInterpreter
|
| 26 |
MTL_AVAILABLE = True
|
| 27 |
+
except ImportError:
|
| 28 |
+
pass
|
|
|
|
| 29 |
|
|
|
|
| 30 |
ROUTER_URL = "http://localhost:5000"
|
| 31 |
|
| 32 |
def start_neural_router():
|
|
|
|
| 34 |
subprocess.Popen(
|
| 35 |
[sys.executable, "-m", "logos.server"],
|
| 36 |
env={**os.environ, "PYTHONPATH": current_dir},
|
| 37 |
+
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL
|
|
|
|
| 38 |
)
|
| 39 |
+
except:
|
| 40 |
+
pass
|
|
|
|
| 41 |
|
| 42 |
threading.Thread(target=start_neural_router, daemon=True).start()
|
| 43 |
|
| 44 |
# =============================================================================
|
| 45 |
+
# CHAT - Casual Language Interface
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
# =============================================================================
|
| 47 |
+
def chat_handler(message, history):
|
| 48 |
+
"""Handle casual language input."""
|
| 49 |
if not message.strip():
|
| 50 |
return history
|
| 51 |
|
|
|
|
| 52 |
history = history + [[message, None]]
|
| 53 |
+
msg = message.lower().strip()
|
| 54 |
|
| 55 |
try:
|
| 56 |
+
# Try router first
|
| 57 |
+
payload = {"messages": [{"role": "user", "content": message}], "model": "logos-matroska-router"}
|
|
|
|
|
|
|
|
|
|
| 58 |
resp = requests.post(f"{ROUTER_URL}/v1/chat/completions", json=payload, timeout=60)
|
|
|
|
| 59 |
if resp.status_code == 200:
|
| 60 |
+
bot = resp.json()['choices'][0]['message']['content']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
else:
|
| 62 |
+
bot = "Router unavailable. Start: python -m logos.server"
|
| 63 |
+
except:
|
| 64 |
+
bot = "Connect to Neural Router on port 5000"
|
| 65 |
|
| 66 |
+
history[-1][1] = bot
|
| 67 |
return history
|
| 68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
# =============================================================================
|
| 70 |
+
# TENSION WEB VISUALIZATION - Mod 10 Radial Network
|
| 71 |
# =============================================================================
|
| 72 |
+
def create_tension_web():
|
| 73 |
"""
|
| 74 |
+
Mod-10 Tension Web - Radial network with connections.
|
| 75 |
+
Each mod-10 lane (1,3,7,9) is a spoke.
|
| 76 |
+
Nodes connected by factor relationships.
|
| 77 |
"""
|
| 78 |
fig = go.Figure()
|
| 79 |
|
| 80 |
+
# Genesis primes on the spokes
|
| 81 |
+
genesis = {
|
| 82 |
+
2: (0, "MECHANISM", "#ffffff"), # Center
|
| 83 |
+
3: (72, "RESULT", "#00ffea"), # Cyan spoke
|
| 84 |
+
5: (144, "CHOICE", "#9d4edd"), # Purple spoke
|
| 85 |
+
7: (216, "PERSIST", "#ff0055"), # Red spoke
|
| 86 |
+
11: (288, "WHY", "#ffff00"), # Yellow spoke
|
| 87 |
+
13: (36, "RELATE", "#ff00ff"), # Magenta
|
| 88 |
+
17: (108, "IMAGE", "#00ff00"), # Green
|
| 89 |
+
19: (180, "TEXT", "#00aaff"), # Blue
|
| 90 |
+
23: (252, "AUDIO", "#ff8800"), # Orange
|
| 91 |
+
29: (324, "SIGNAL", "#ff0088"), # Pink
|
| 92 |
}
|
| 93 |
|
| 94 |
+
# Draw connection lines (factors)
|
| 95 |
+
connection_traces = []
|
| 96 |
+
for p1, (a1, n1, c1) in genesis.items():
|
| 97 |
+
for p2, (a2, n2, c2) in genesis.items():
|
| 98 |
+
if p1 < p2:
|
| 99 |
+
# Composite = p1 * p2
|
| 100 |
+
composite = p1 * p2
|
| 101 |
+
# Draw faint connection line
|
| 102 |
+
r1, r2 = math.log10(p1 + 1) * 0.8, math.log10(p2 + 1) * 0.8
|
| 103 |
+
fig.add_trace(go.Scatterpolar(
|
| 104 |
+
r=[r1, r2],
|
| 105 |
+
theta=[a1, a2],
|
| 106 |
+
mode='lines',
|
| 107 |
+
line=dict(color='rgba(100,100,150,0.15)', width=1),
|
| 108 |
+
showlegend=False,
|
| 109 |
+
hoverinfo='skip'
|
| 110 |
+
))
|
| 111 |
|
| 112 |
+
# Draw prime nodes on spokes
|
| 113 |
+
for prime, (angle, name, color) in genesis.items():
|
| 114 |
+
if prime == 2:
|
| 115 |
+
r = 0.1 # Center
|
| 116 |
+
size = 40
|
| 117 |
+
else:
|
| 118 |
+
r = math.log10(prime) * 0.8
|
| 119 |
+
size = 25
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
|
| 121 |
fig.add_trace(go.Scatterpolar(
|
| 122 |
+
r=[r],
|
| 123 |
+
theta=[angle],
|
| 124 |
+
mode='markers+text',
|
| 125 |
+
marker=dict(color=color, size=size, line=dict(color='white', width=2)),
|
| 126 |
+
text=[str(prime)],
|
| 127 |
+
textposition='middle center',
|
| 128 |
+
textfont=dict(color='black' if prime == 2 else 'white', size=10, family='Arial Black'),
|
| 129 |
+
name=name,
|
| 130 |
+
hovertext=f"[{prime}] {name}",
|
| 131 |
+
hoverinfo='text'
|
| 132 |
))
|
| 133 |
|
| 134 |
+
# Draw mod-10 lanes as subtle radial lines
|
| 135 |
+
for angle in [0, 36, 72, 108, 144, 180, 216, 252, 288, 324]:
|
|
|
|
| 136 |
fig.add_trace(go.Scatterpolar(
|
| 137 |
+
r=[0, 1.8],
|
| 138 |
+
theta=[angle, angle],
|
| 139 |
mode='lines',
|
| 140 |
+
line=dict(color='rgba(255,255,255,0.08)', width=1),
|
| 141 |
+
showlegend=False,
|
| 142 |
+
hoverinfo='skip'
|
| 143 |
+
))
|
| 144 |
+
|
| 145 |
+
# Draw concentric rings (decades)
|
| 146 |
+
for r_val in [0.3, 0.7, 1.1, 1.5]:
|
| 147 |
+
theta_ring = list(range(0, 361, 5))
|
| 148 |
+
fig.add_trace(go.Scatterpolar(
|
| 149 |
+
r=[r_val] * len(theta_ring),
|
| 150 |
+
theta=theta_ring,
|
| 151 |
+
mode='lines',
|
| 152 |
+
line=dict(color='rgba(255,255,255,0.1)', width=1),
|
| 153 |
showlegend=False,
|
| 154 |
hoverinfo='skip'
|
| 155 |
))
|
| 156 |
|
| 157 |
fig.update_layout(
|
| 158 |
+
paper_bgcolor='#0a0e17',
|
| 159 |
+
plot_bgcolor='#0a0e17',
|
| 160 |
+
showlegend=False,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
polar=dict(
|
| 162 |
+
radialaxis=dict(visible=False, range=[0, 1.8]),
|
| 163 |
+
angularaxis=dict(visible=False),
|
| 164 |
+
bgcolor='#0a0e17'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
),
|
| 166 |
+
margin=dict(l=20, r=20, t=50, b=20),
|
| 167 |
+
height=500,
|
| 168 |
title=dict(
|
| 169 |
+
text="MOD-10 TENSION WEB",
|
| 170 |
+
font=dict(color='#00ffea', size=14),
|
| 171 |
x=0.5
|
| 172 |
)
|
| 173 |
)
|
| 174 |
return fig
|
| 175 |
|
| 176 |
# =============================================================================
|
| 177 |
+
# CSS
|
| 178 |
# =============================================================================
|
| 179 |
+
CSS = """
|
| 180 |
+
.gradio-container { background: #0a0e17 !important; }
|
| 181 |
+
.chat-box { border: 1px solid rgba(0,255,234,0.3); border-radius: 12px; }
|
| 182 |
+
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
|
| 184 |
# =============================================================================
|
| 185 |
+
# APP
|
| 186 |
# =============================================================================
|
| 187 |
+
with gr.Blocks(css=CSS, title="LOGOS", theme=gr.themes.Base()) as demo:
|
| 188 |
|
|
|
|
| 189 |
gr.HTML("""
|
| 190 |
+
<div style="text-align:center; padding:1rem;">
|
| 191 |
+
<h1 style="color:#00ffea; margin:0;">LOGOS</h1>
|
| 192 |
+
<p style="color:#666; font-size:0.9rem;">Logarithmic Ordering Generation Operating Software</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
</div>
|
| 194 |
""")
|
| 195 |
|
|
|
|
| 196 |
with gr.Tabs():
|
| 197 |
|
| 198 |
+
# TAB 1: CHAT
|
| 199 |
+
with gr.TabItem("Chat"):
|
| 200 |
+
chatbot = gr.Chatbot(height=400)
|
| 201 |
+
msg = gr.Textbox(placeholder="Ask me anything...", label="Message")
|
| 202 |
with gr.Row():
|
| 203 |
+
send = gr.Button("Send", variant="primary")
|
| 204 |
+
clear = gr.Button("Clear")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
|
| 206 |
+
msg.submit(chat_handler, [msg, chatbot], chatbot).then(lambda: "", None, msg)
|
| 207 |
+
send.click(chat_handler, [msg, chatbot], chatbot).then(lambda: "", None, msg)
|
| 208 |
+
clear.click(lambda: [], None, chatbot)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
|
| 210 |
+
# TAB 2: TENSION WEB
|
| 211 |
+
with gr.TabItem("Topology"):
|
| 212 |
+
gr.Plot(value=create_tension_web())
|
| 213 |
+
gr.Markdown("""
|
| 214 |
+
**Tension Web Structure:**
|
| 215 |
+
- Center: [2] MECHANISM
|
| 216 |
+
- Spokes: Genesis Primes (3,5,7,11,13,17,19,23,29)
|
| 217 |
+
- Connections: Factor relationships
|
| 218 |
+
- Rings: Log-scale decades
|
| 219 |
+
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 220 |
|
| 221 |
+
# TAB 3: MTL
|
| 222 |
+
with gr.TabItem("MTL"):
|
| 223 |
+
mtl_in = gr.Textbox(label="Code", value="(mult [2] [3])")
|
| 224 |
+
mtl_run = gr.Button("Run")
|
| 225 |
+
mtl_out = gr.Textbox(label="Result")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
|
| 227 |
+
def run_mtl(code):
|
| 228 |
+
if not MTL_AVAILABLE: return "MTL unavailable"
|
| 229 |
+
try:
|
| 230 |
+
return str(MTLInterpreter().execute(code))
|
| 231 |
+
except Exception as e:
|
| 232 |
+
return str(e)
|
| 233 |
+
|
| 234 |
+
mtl_run.click(run_mtl, mtl_in, mtl_out)
|
| 235 |
|
| 236 |
+
gr.HTML("<div style='text-align:center;color:#444;font-size:0.8rem;padding:1rem;'>LOGOS v1.0</div>")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 237 |
|
|
|
|
| 238 |
if __name__ == "__main__":
|
| 239 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|
logos/docs/builder_operations.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# MTL Builder Operations
|
| 2 |
+
## Wittgenstein's Language Game Applied to LOGOS
|
| 3 |
+
|
| 4 |
+
Wittgenstein's "builder's language" (from Philosophical Investigations §2) consists of:
|
| 5 |
+
- **Slab!** (request object)
|
| 6 |
+
- **Block!** (request object)
|
| 7 |
+
- **Beam!** (request object)
|
| 8 |
+
- **Column!** (request object)
|
| 9 |
+
|
| 10 |
+
The builder calls, the assistant brings. This is **pure action through naming**.
|
| 11 |
+
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
## MTL Mapping
|
| 15 |
+
|
| 16 |
+
| Builder Language | MTL Operation | Effect |
|
| 17 |
+
|:-----------------|:--------------|:-------|
|
| 18 |
+
| "Slab!" | `(hold 'slab [6])` | Store value 6 under 'slab |
|
| 19 |
+
| "Block!" | `(grab 'slab)` | Retrieve stored value |
|
| 20 |
+
| "Beam those!" | `(connect [A] [B])` | Combine A × B |
|
| 21 |
+
| "That slab!" | `(route [6] [42])` | Move value to domain |
|
| 22 |
+
|
| 23 |
+
---
|
| 24 |
+
|
| 25 |
+
## HOLD - The Register
|
| 26 |
+
|
| 27 |
+
```lisp
|
| 28 |
+
(hold 'x [6]) ; Store 6 as 'x
|
| 29 |
+
(hold 'y [7]) ; Store 7 as 'y
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
HOLD creates a **named register**. The value persists in `memory`.
|
| 33 |
+
|
| 34 |
+
---
|
| 35 |
+
|
| 36 |
+
## GRAB - The Retrieval
|
| 37 |
+
|
| 38 |
+
```lisp
|
| 39 |
+
(grab 'x) ; Returns 6
|
| 40 |
+
```
|
| 41 |
+
|
| 42 |
+
GRAB retrieves from the register. In builder terms: "Give me that slab!"
|
| 43 |
+
|
| 44 |
+
---
|
| 45 |
+
|
| 46 |
+
## CASCADE Operations
|
| 47 |
+
|
| 48 |
+
### Example 1: Store then Retrieve
|
| 49 |
+
```lisp
|
| 50 |
+
(hold 'a [2]) ; a = 2
|
| 51 |
+
(hold 'b [3]) ; b = 3
|
| 52 |
+
(mult (grab 'a) (grab 'b)) ; 2 × 3 = 6
|
| 53 |
+
```
|
| 54 |
+
|
| 55 |
+
### Example 2: Chain Connections
|
| 56 |
+
```lisp
|
| 57 |
+
(hold 'image [17])
|
| 58 |
+
(hold 'text [19])
|
| 59 |
+
(hold 'relation (connect (grab 'image) (grab 'text)))
|
| 60 |
+
; relation = 17 × 19 = 323
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
### Example 3: Builder Workflow
|
| 64 |
+
```lisp
|
| 65 |
+
; "Hold the slab, hold the beam, connect them"
|
| 66 |
+
(hold 'slab [5])
|
| 67 |
+
(hold 'beam [7])
|
| 68 |
+
(hold 'structure (mult (grab 'slab) (grab 'beam)))
|
| 69 |
+
; structure = 35
|
| 70 |
+
|
| 71 |
+
; "Now persist the structure"
|
| 72 |
+
(mult (grab 'structure) [7]) ; 35 × 7 = 245 (with PERSIST flag)
|
| 73 |
+
```
|
| 74 |
+
|
| 75 |
+
---
|
| 76 |
+
|
| 77 |
+
## Domain Operations
|
| 78 |
+
|
| 79 |
+
HOLD/GRAB work within the **active domain**:
|
| 80 |
+
|
| 81 |
+
```lisp
|
| 82 |
+
(domain [1700]) ; Enter VISUAL domain
|
| 83 |
+
(hold 'frame [17]) ; Store in VISUAL context
|
| 84 |
+
(domain [1900]) ; Switch to TEXT domain
|
| 85 |
+
(hold 'word [19]) ; Store in TEXT context
|
| 86 |
+
```
|
| 87 |
+
|
| 88 |
+
---
|
| 89 |
+
|
| 90 |
+
## The Builder Axiom
|
| 91 |
+
|
| 92 |
+
> **Calling a value IS moving it.**
|
| 93 |
+
|
| 94 |
+
In Wittgenstein's game, "Slab!" doesn't describe a slab—it **commands one to appear**.
|
| 95 |
+
In MTL, `(grab 'x)` doesn't describe x—it **retrieves x to the current context**.
|
| 96 |
+
|
| 97 |
+
The act of naming is the act of manifesting.
|
| 98 |
+
|
| 99 |
+
---
|
| 100 |
+
|
| 101 |
+
## Cascade Patterns
|
| 102 |
+
|
| 103 |
+
| Pattern | Operations | Result |
|
| 104 |
+
|:--------|:-----------|:-------|
|
| 105 |
+
| Store-Compute-Store | hold→op→hold | Accumulator |
|
| 106 |
+
| Gather-Combine | grab,grab→connect | Composition |
|
| 107 |
+
| Build-Persist | hold→mult [7] | Permanent record |
|
| 108 |
+
| Route-Chain | route→route | Pipeline |
|
| 109 |
+
|