Spaces:
Runtime error
Runtime error
GitHub Copilot commited on
Commit ·
f3ae05d
1
Parent(s): 9d91c12
Protocol 35-44: Unified App v2.0
Browse files- .env.template +42 -7
- .gitignore +14 -0
- app.py +220 -0
- logos_project +1 -0
.env.template
CHANGED
|
@@ -1,19 +1,54 @@
|
|
| 1 |
-
#
|
| 2 |
-
#
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
-
#
|
| 5 |
# Get from: https://huggingface.co/settings/tokens
|
| 6 |
HF_TOKEN=
|
| 7 |
|
| 8 |
-
# NVIDIA API Key (for NeMo Agent Toolkit / Nemotron models)
|
| 9 |
# Get from: https://build.nvidia.com/
|
| 10 |
NVIDIA_API_KEY=
|
| 11 |
|
| 12 |
-
#
|
| 13 |
-
HF_SPACE_ID=
|
| 14 |
|
| 15 |
-
# LOGOS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
LOGOS_DEBUG=0
|
| 17 |
|
| 18 |
# Number of parallel workers for DSP operations
|
| 19 |
NUM_WORKERS=16
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ============================================
|
| 2 |
+
# LOGOS Environment Configuration
|
| 3 |
+
# ============================================
|
| 4 |
+
# Copy this file to .env and fill in your values
|
| 5 |
+
# Models are configured in logos/config.json
|
| 6 |
|
| 7 |
+
# --- API KEYS (Optional) ---
|
| 8 |
# Get from: https://huggingface.co/settings/tokens
|
| 9 |
HF_TOKEN=
|
| 10 |
|
|
|
|
| 11 |
# Get from: https://build.nvidia.com/
|
| 12 |
NVIDIA_API_KEY=
|
| 13 |
|
| 14 |
+
# --- DEPLOYMENT (Optional) ---
|
| 15 |
+
HF_SPACE_ID=
|
| 16 |
|
| 17 |
+
# --- LOGOS OVERRIDES ---
|
| 18 |
+
# These override config.json values
|
| 19 |
+
|
| 20 |
+
# LLM Server Endpoint (LM Studio, Ollama, vLLM, etc.)
|
| 21 |
+
# Default: http://localhost:1234/v1
|
| 22 |
+
LOGOS_LLM_ENDPOINT=
|
| 23 |
+
|
| 24 |
+
# LOGOS Server Port
|
| 25 |
+
# Default: 5000
|
| 26 |
+
LOGOS_SERVER_PORT=
|
| 27 |
+
|
| 28 |
+
# Default Model ID (overrides config.json default_model)
|
| 29 |
+
# Example: "llama-3.1-8b" or "mistral-7b" or whatever your server provides
|
| 30 |
+
LOGOS_DEFAULT_MODEL=
|
| 31 |
+
|
| 32 |
+
# Debug Mode (1 for verbose logging)
|
| 33 |
LOGOS_DEBUG=0
|
| 34 |
|
| 35 |
# Number of parallel workers for DSP operations
|
| 36 |
NUM_WORKERS=16
|
| 37 |
+
|
| 38 |
+
# ============================================
|
| 39 |
+
# MODEL CONFIGURATION
|
| 40 |
+
# ============================================
|
| 41 |
+
# Models are configured in logos/config.json
|
| 42 |
+
#
|
| 43 |
+
# Quick Setup:
|
| 44 |
+
# 1. Start your LLM server (LM Studio, Ollama, etc.)
|
| 45 |
+
# 2. Edit logos/config.json
|
| 46 |
+
# 3. Set "default_model" to your model's ID
|
| 47 |
+
# 4. Run: python -m logos.config (to verify)
|
| 48 |
+
#
|
| 49 |
+
# Example config.json:
|
| 50 |
+
# {
|
| 51 |
+
# "llm_endpoint": "http://localhost:1234/v1",
|
| 52 |
+
# "default_model": "llama-3.1-8b",
|
| 53 |
+
# "force_single_model": true
|
| 54 |
+
# }
|
.gitignore
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
__pycache__/
|
| 2 |
+
*.pyc
|
| 3 |
+
.env
|
| 4 |
+
logos_data/
|
| 5 |
+
logos_data_backup_protocol43/
|
| 6 |
+
.venv/
|
| 7 |
+
logos/resources/root_words.json
|
| 8 |
+
demo_output*.txt
|
| 9 |
+
target/
|
| 10 |
+
polaron/target/
|
| 11 |
+
*.exe
|
| 12 |
+
*.pdb
|
| 13 |
+
*.rlib
|
| 14 |
+
*.rmeta
|
app.py
CHANGED
|
@@ -66,6 +66,7 @@ def chat_handler(message, history):
|
|
| 66 |
history[-1][1] = bot
|
| 67 |
return history
|
| 68 |
|
|
|
|
| 69 |
# =============================================================================
|
| 70 |
# TENSION WEB VISUALIZATION - Mod 10 Radial Network
|
| 71 |
# =============================================================================
|
|
@@ -78,6 +79,145 @@ def create_tension_web():
|
|
| 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
|
|
@@ -200,7 +340,87 @@ with gr.Blocks(css=CSS, title="LOGOS", theme=gr.themes.Base()) as demo:
|
|
| 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)
|
|
|
|
| 66 |
history[-1][1] = bot
|
| 67 |
return history
|
| 68 |
|
| 69 |
+
<<<<<<< HEAD
|
| 70 |
# =============================================================================
|
| 71 |
# TENSION WEB VISUALIZATION - Mod 10 Radial Network
|
| 72 |
# =============================================================================
|
|
|
|
| 79 |
fig = go.Figure()
|
| 80 |
|
| 81 |
# Genesis primes on the spokes
|
| 82 |
+
=======
|
| 83 |
+
def run_mtl_demo() -> str:
|
| 84 |
+
"""Run a demonstration of MTL capabilities."""
|
| 85 |
+
if not MTL_AVAILABLE:
|
| 86 |
+
return "MTL not available"
|
| 87 |
+
|
| 88 |
+
try:
|
| 89 |
+
mtl = MTLInterpreter()
|
| 90 |
+
output = []
|
| 91 |
+
|
| 92 |
+
output.append("=== LOGOS MTL DEMONSTRATION ===\n")
|
| 93 |
+
|
| 94 |
+
# Basic arithmetic
|
| 95 |
+
output.append("[1] Tensor Multiplication")
|
| 96 |
+
r = mtl.execute('(mult [2] [3])')
|
| 97 |
+
output.append(f" (mult [2] [3]) = {r} (MECHANISM x RESULT = FLIP)")
|
| 98 |
+
|
| 99 |
+
# Logic gates
|
| 100 |
+
output.append("\n[2] Logic Gates")
|
| 101 |
+
r = mtl.execute('(or [2] [3])')
|
| 102 |
+
output.append(f" (or [2] [3]) = {r} (LCM - Superposition)")
|
| 103 |
+
r = mtl.execute('(and [6] [10])')
|
| 104 |
+
output.append(f" (and [6] [10]) = {r} (GCD - Intersection)")
|
| 105 |
+
|
| 106 |
+
# Factorial
|
| 107 |
+
output.append("\n[3] Recursive Function (Factorial)")
|
| 108 |
+
mtl.execute('(defun factorial (n) (if (lt? n 2) 1 (mult n (factorial (sub n 1)))))')
|
| 109 |
+
r = mtl.execute('(factorial 5)')
|
| 110 |
+
output.append(f" (factorial 5) = {r}")
|
| 111 |
+
|
| 112 |
+
# Synapse
|
| 113 |
+
output.append("\n[4] Knowledge Graph (Synapse)")
|
| 114 |
+
r = mtl.execute('(relate [17] [19])')
|
| 115 |
+
output.append(f" (relate [17] [19]) = {r} (IMAGE x TEXT x RELATE)")
|
| 116 |
+
|
| 117 |
+
output.append("\n=== TURING COMPLETENESS VERIFIED ===")
|
| 118 |
+
|
| 119 |
+
return "\n".join(output)
|
| 120 |
+
except Exception as e:
|
| 121 |
+
return f"Demo Error: {str(e)}"
|
| 122 |
+
|
| 123 |
+
# --- PHYSICS VISUALIZERS ---
|
| 124 |
+
def get_prime_topology(max_n=500):
|
| 125 |
+
"""
|
| 126 |
+
LOGOS Concentric Log Polar Cone Topology.
|
| 127 |
+
- Each ring = mod 10 (decade layer)
|
| 128 |
+
- Special lanes: mod 1, 3, 7, 9 (prime-generating residues)
|
| 129 |
+
"""
|
| 130 |
+
import math
|
| 131 |
+
fig = go.Figure()
|
| 132 |
+
|
| 133 |
+
# Generate numbers and categorize by mod 10
|
| 134 |
+
all_nums = list(range(1, max_n))
|
| 135 |
+
|
| 136 |
+
# Color by mod 10 residue class
|
| 137 |
+
residue_colors = {
|
| 138 |
+
1: '#00ffea', # Cyan - Prime lane
|
| 139 |
+
3: '#ff00ff', # Magenta - Prime lane
|
| 140 |
+
7: '#ffff00', # Yellow - Prime lane
|
| 141 |
+
9: '#00ff00', # Green - Prime lane
|
| 142 |
+
0: '#333333', # Gray - Even decade
|
| 143 |
+
2: '#333333', 4: '#333333', 5: '#333333',
|
| 144 |
+
6: '#333333', 8: '#333333'
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
# Build traces for each residue class
|
| 148 |
+
for residue in [1, 3, 7, 9]: # Prime-generating lanes only
|
| 149 |
+
nums_in_class = [n for n in all_nums if n % 10 == residue]
|
| 150 |
+
|
| 151 |
+
# Log polar coordinates
|
| 152 |
+
# r = log10(n) gives concentric rings per decade
|
| 153 |
+
# theta = (n mod 10) * 36 degrees + offset for spread
|
| 154 |
+
r = [math.log10(n) if n > 0 else 0 for n in nums_in_class]
|
| 155 |
+
theta = [(n % 100) * 3.6 for n in nums_in_class] # Spread within decade
|
| 156 |
+
|
| 157 |
+
# Mark primes
|
| 158 |
+
is_prime = [sympy.isprime(n) for n in nums_in_class]
|
| 159 |
+
sizes = [12 if p else 4 for p in is_prime]
|
| 160 |
+
colors = [residue_colors[residue] if p else '#555555' for p in is_prime]
|
| 161 |
+
|
| 162 |
+
fig.add_trace(go.Scatterpolar(
|
| 163 |
+
r=r,
|
| 164 |
+
theta=theta,
|
| 165 |
+
mode='markers',
|
| 166 |
+
marker=dict(
|
| 167 |
+
color=colors,
|
| 168 |
+
size=sizes,
|
| 169 |
+
line=dict(color='white', width=0.3),
|
| 170 |
+
opacity=0.8
|
| 171 |
+
),
|
| 172 |
+
text=[f"{n} (mod10={residue})" for n in nums_in_class],
|
| 173 |
+
hoverinfo='text',
|
| 174 |
+
name=f'Mod {residue}'
|
| 175 |
+
))
|
| 176 |
+
|
| 177 |
+
# Add ring labels for decades
|
| 178 |
+
for decade in [10, 100]:
|
| 179 |
+
r_ring = math.log10(decade)
|
| 180 |
+
theta_ring = list(range(0, 360, 10))
|
| 181 |
+
fig.add_trace(go.Scatterpolar(
|
| 182 |
+
r=[r_ring] * len(theta_ring),
|
| 183 |
+
theta=theta_ring,
|
| 184 |
+
mode='lines',
|
| 185 |
+
line=dict(color='rgba(255,255,255,0.2)', width=1, dash='dot'),
|
| 186 |
+
showlegend=False
|
| 187 |
+
))
|
| 188 |
+
|
| 189 |
+
fig.update_layout(
|
| 190 |
+
template="plotly_dark",
|
| 191 |
+
paper_bgcolor='rgba(0,0,0,0)',
|
| 192 |
+
plot_bgcolor='rgba(0,0,0,0)',
|
| 193 |
+
showlegend=True,
|
| 194 |
+
legend=dict(font=dict(color='white')),
|
| 195 |
+
polar=dict(
|
| 196 |
+
radialaxis=dict(
|
| 197 |
+
visible=True,
|
| 198 |
+
range=[0, 3],
|
| 199 |
+
ticktext=['1', '10', '100', '1000'],
|
| 200 |
+
tickvals=[0, 1, 2, 3],
|
| 201 |
+
gridcolor='rgba(255,255,255,0.1)'
|
| 202 |
+
),
|
| 203 |
+
angularaxis=dict(
|
| 204 |
+
visible=True,
|
| 205 |
+
gridcolor='rgba(255,255,255,0.1)'
|
| 206 |
+
),
|
| 207 |
+
bgcolor='rgba(11,15,25,0.9)'
|
| 208 |
+
),
|
| 209 |
+
margin=dict(l=40, r=40, t=40, b=40),
|
| 210 |
+
height=550,
|
| 211 |
+
title=dict(
|
| 212 |
+
text="LOGOS Log Polar Cone (Mod 10 Rings)",
|
| 213 |
+
font=dict(color='white')
|
| 214 |
+
)
|
| 215 |
+
)
|
| 216 |
+
return fig
|
| 217 |
+
|
| 218 |
+
def get_genesis_block_visual():
|
| 219 |
+
"""Visualize the Genesis Block primes."""
|
| 220 |
+
>>>>>>> 512b27f (Fix: LOGOS Log Polar Cone Topology (mod 10 rings, 1/3/7/9 lanes))
|
| 221 |
genesis = {
|
| 222 |
2: (0, "MECHANISM", "#ffffff"), # Center
|
| 223 |
3: (72, "RESULT", "#00ffea"), # Cyan spoke
|
|
|
|
| 340 |
chatbot = gr.Chatbot(height=400)
|
| 341 |
msg = gr.Textbox(placeholder="Ask me anything...", label="Message")
|
| 342 |
with gr.Row():
|
| 343 |
+
<<<<<<< HEAD
|
| 344 |
send = gr.Button("Send", variant="primary")
|
| 345 |
+
=======
|
| 346 |
+
with gr.Column(scale=2):
|
| 347 |
+
mtl_input = gr.Textbox(
|
| 348 |
+
label="MTL Code",
|
| 349 |
+
placeholder="(mult [2] [3])",
|
| 350 |
+
lines=3
|
| 351 |
+
)
|
| 352 |
+
mtl_examples = gr.Examples(
|
| 353 |
+
examples=[
|
| 354 |
+
["(mult [2] [3])"],
|
| 355 |
+
["(or [17] [19])"],
|
| 356 |
+
["(and [6] [10])"],
|
| 357 |
+
["(relate [17] [19])"],
|
| 358 |
+
["(fractran [[5 2] [5 3]] 72)"],
|
| 359 |
+
],
|
| 360 |
+
inputs=mtl_input
|
| 361 |
+
)
|
| 362 |
+
mtl_run = gr.Button("Execute MTL", variant="primary")
|
| 363 |
+
with gr.Column(scale=1):
|
| 364 |
+
mtl_output = gr.Textbox(label="Result", lines=3)
|
| 365 |
+
mtl_demo_btn = gr.Button("Run Full Demo")
|
| 366 |
+
mtl_demo_output = gr.Textbox(label="Demo Output", lines=15)
|
| 367 |
+
|
| 368 |
+
mtl_run.click(execute_mtl, inputs=mtl_input, outputs=mtl_output)
|
| 369 |
+
mtl_demo_btn.click(run_mtl_demo, outputs=mtl_demo_output)
|
| 370 |
+
|
| 371 |
+
# TAB B: GENESIS BLOCK
|
| 372 |
+
with gr.Tab("Genesis Block"):
|
| 373 |
+
with gr.Row():
|
| 374 |
+
with gr.Column(scale=2):
|
| 375 |
+
genesis_plot = gr.Plot(value=get_genesis_block_visual(), label="Prime Axioms")
|
| 376 |
+
with gr.Column(scale=1):
|
| 377 |
+
gr.Markdown("""
|
| 378 |
+
### The Root Manifold
|
| 379 |
+
|
| 380 |
+
| Prime | Concept |
|
| 381 |
+
|-------|---------|
|
| 382 |
+
| [2] | MECHANISM |
|
| 383 |
+
| [3] | RESULT |
|
| 384 |
+
| [5] | CHOICE |
|
| 385 |
+
| [7] | PERSIST |
|
| 386 |
+
| [11] | WHY |
|
| 387 |
+
| [13] | RELATE |
|
| 388 |
+
| [17] | IMAGE |
|
| 389 |
+
| [19] | TEXT |
|
| 390 |
+
| [23] | AUDIO |
|
| 391 |
+
| [29] | SIGNAL |
|
| 392 |
+
|
| 393 |
+
*Every concept is a Prime. Every file is a Number.*
|
| 394 |
+
""")
|
| 395 |
+
|
| 396 |
+
# TAB C: PRIME TOPOLOGY
|
| 397 |
+
with gr.Tab("Prime Topology"):
|
| 398 |
+
with gr.Row():
|
| 399 |
+
with gr.Column():
|
| 400 |
+
prime_plot = gr.Plot(value=get_prime_topology(), label="Log Polar Cone")
|
| 401 |
+
with gr.Column():
|
| 402 |
+
gr.Markdown("""
|
| 403 |
+
### LOGOS Log Polar Cone Topology
|
| 404 |
+
|
| 405 |
+
**Concentric rings = Mod 10 decades**
|
| 406 |
+
|
| 407 |
+
**Prime Lanes (Mod 10 residues):**
|
| 408 |
+
- **Cyan (1)**: Numbers ending in 1
|
| 409 |
+
- **Magenta (3)**: Numbers ending in 3
|
| 410 |
+
- **Yellow (7)**: Numbers ending in 7
|
| 411 |
+
- **Green (9)**: Numbers ending in 9
|
| 412 |
+
|
| 413 |
+
Large dots = **Primes** (only end in 1,3,7,9)
|
| 414 |
+
|
| 415 |
+
*Arithmetic is Architecture.*
|
| 416 |
+
""")
|
| 417 |
+
|
| 418 |
+
# TAB D: RECURSIVE REASONING
|
| 419 |
+
with gr.Tab("Chat"):
|
| 420 |
+
with gr.Column(elem_classes=["chat-container"]):
|
| 421 |
+
chatbot = gr.Chatbot(label="LOGOS Router")
|
| 422 |
+
msg = gr.Textbox(label="Message", placeholder="Ask LOGOS...")
|
| 423 |
+
>>>>>>> 512b27f (Fix: LOGOS Log Polar Cone Topology (mod 10 rings, 1/3/7/9 lanes))
|
| 424 |
clear = gr.Button("Clear")
|
| 425 |
|
| 426 |
msg.submit(chat_handler, [msg, chatbot], chatbot).then(lambda: "", None, msg)
|
logos_project
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
Subproject commit 75b641f8e63f4fc840b4dd5b63ec2e4113f163a7
|