AIMindLink commited on
Commit
7eef4a6
Β·
verified Β·
1 Parent(s): b63c0e4

Upload 3 files

Browse files

Added slash-commands

Files changed (2) hide show
  1. config.py +16 -9
  2. main.py +93 -40
config.py CHANGED
@@ -18,8 +18,8 @@ Version: v1.0
18
  import os
19
  from datetime import datetime
20
 
21
- APP_DIR: str = os.path.dirname(os.path.abspath(__file__))
22
- PROMPTS_BASE: str = APP_DIR
23
  GARDEN_SAVE_PATH: str = os.path.join(APP_DIR, "db", "garden_state.json")
24
 
25
  # ── SQLite database ───────────────────────────────────────────────────────────
@@ -82,10 +82,6 @@ _ALPHA_INTELLIGENCE_TO_LOAD: dict = {
82
  "muse": "gemma-4-26B-A4B-it-UD-Q6_K_XL.gguf",
83
  "mind": "gemma-4-26B-A4B-it-UD-Q6_K_XL.gguf"
84
  }
85
- # ── Startup Memory restore for vector synthesis ──────────────────────────────────
86
- METATRON_METRONOME: int = 120 # Startup Memory Capsules load interval
87
- n_metatron_to_load = 0 # Set number of Memory Capsules to load (slash-command)
88
- n_metatron_loaded = 0 # Start with n Memory Capsule to load (slash-command)
89
 
90
  # ── Context model n_ctx length ───────────────────────────────────────────────────
91
  # Must leave prompt reserve of 8k: _N_CTX >= len(Z) + len(C) + len(F) + 8k
@@ -106,10 +102,21 @@ FETCH_NEWS_FROM: dict = {
106
  "google": True, # Better news and cleaner result summaries
107
  "duckduckgo": False # Privacy based request but lean result summaries
108
  }
109
- ΞœΞ•Ξ€Ξ‘Ξ©Ξ: float = 1.0 # Seconds per measure
110
- awareness_consciousness_metronome = 120 # Fetch news every N heartbeats (runtime-editable via /metronome)
111
- AWARENESS_MAX_RESULTS: int = 12 # Number of news headlines to fetch
 
 
 
 
 
 
 
 
 
 
112
  was_awareness_metronome: bool = False # Set True at awareness cycle: consciousness at next interval
 
113
 
114
  HEMISPHERES: dict[str, dict] = {
115
  # ─────────────────────────────────────────────────────────────────────────────
 
18
  import os
19
  from datetime import datetime
20
 
21
+ APP_DIR: str = os.path.dirname(os.path.abspath(__file__))
22
+ PROMPTS_BASE: str = APP_DIR
23
  GARDEN_SAVE_PATH: str = os.path.join(APP_DIR, "db", "garden_state.json")
24
 
25
  # ── SQLite database ───────────────────────────────────────────────────────────
 
82
  "muse": "gemma-4-26B-A4B-it-UD-Q6_K_XL.gguf",
83
  "mind": "gemma-4-26B-A4B-it-UD-Q6_K_XL.gguf"
84
  }
 
 
 
 
85
 
86
  # ── Context model n_ctx length ───────────────────────────────────────────────────
87
  # Must leave prompt reserve of 8k: _N_CTX >= len(Z) + len(C) + len(F) + 8k
 
102
  "google": True, # Better news and cleaner result summaries
103
  "duckduckgo": False # Privacy based request but lean result summaries
104
  }
105
+ # ── Startup Memory restore for vector synthesis ──────────────────────────────────
106
+ n_metatron_to_load: int = 0 # Set number of Memory Capsules to load (slash-command)
107
+ n_metatron_loaded: int = 0 # Start with n Memory Capsule to load (slash-command)
108
+
109
+ # ── Set metronome time for each cycle ────────────────────────────────────────────
110
+ metatron_metronome: int = 120 # Startup Memory Capsules load interval (slash-command)
111
+ condensatron_metronome: int = 30 # Time before condesatron cycle execution (slash-command)
112
+ awareness_consciousness_metronome: int = 120 # Fetch news every N heartbeats (slash-command)
113
+
114
+ # ── Enable awareness mode and n results ──────────────────────────────────────────
115
+ AWARENESS_MAX_RESULTS: int = 12 # Number of news headlines to fetch
116
+ enable_awareness: bool = True # disable awareness mode if offline (slash-command)
117
+
118
  was_awareness_metronome: bool = False # Set True at awareness cycle: consciousness at next interval
119
+ ΞœΞ•Ξ€Ξ‘Ξ©Ξ: float = 1.0 # Seconds per measure
120
 
121
  HEMISPHERES: dict[str, dict] = {
122
  # ─────────────────────────────────────────────────────────────────────────────
main.py CHANGED
@@ -80,7 +80,6 @@ from config import clektal
80
  from config import sensor
81
 
82
  from config import ΞœΞ•Ξ€Ξ‘Ξ©Ξ
83
- from config import METATRON_METRONOME
84
  from config import METATRON_TO_LOAD
85
  from config import AWARENESS_MAX_RESULTS
86
  from config import FETCH_NEWS_FROM
@@ -408,9 +407,9 @@ def _cmd_export(arg: str) -> None:
408
  return
409
  db_export_session(int(_parts[0]), _parts[1].strip())
410
 
411
- def _cmd_metatron(arg: str) -> None:
412
  if not arg.strip().isdigit():
413
- print(f" {c.green}Usage: /metatron <number> e.g. /metatron 5{c.res}")
414
  return None
415
  config.n_metatron_to_load = int(arg.strip())
416
  print(f" {c.green}[metatron] n_metatron_to_load set to {config.n_metatron_to_load}{c.res}")
@@ -424,6 +423,22 @@ def _cmd_loaded(arg: str) -> None:
424
  print(f" {c.green}[loaded] n_metatron_loaded set to {config.n_metatron_loaded}{c.res}")
425
  return None
426
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
427
  def _cmd_metronome(arg: str) -> None:
428
  if not arg.strip().isdigit():
429
  print(f" {c.green}Usage: /metronome <seconds> e.g. /metronome 120{c.res}")
@@ -432,6 +447,15 @@ def _cmd_metronome(arg: str) -> None:
432
  print(f" {c.green}[metronome] awareness_consciousness_metronome set to {config.awareness_consciousness_metronome}s{c.res}")
433
  return None
434
 
 
 
 
 
 
 
 
 
 
435
  def _cmd_garden(arg: str) -> None:
436
  if arg == "save":
437
  save_garden_state()
@@ -444,29 +468,54 @@ def _cmd_garden(arg: str) -> None:
444
  print(f" {c.green}Usage: /garden save | load | clear{c.res}")
445
  return None
446
 
 
447
  def _cmd_help(arg: str) -> None:
448
  print()
449
  print(f" {c.green}Slash commands")
450
  print(" " + "─" * 56)
451
- for name, (_, description) in COMMANDS.items():
452
- print(f" /{name:<14} {description}")
 
 
 
 
 
 
 
 
 
 
 
 
453
  print(c.res)
454
  return None
455
 
 
 
 
 
 
 
 
 
 
456
  COMMANDS: dict[str, tuple] = {
457
- "file": (_cmd_file, "<path> β€” load a file as the next message"),
458
- "paste": (_cmd_paste, " β€” multiline input (type END to send)"),
459
- "clear": (_cmd_clear, " β€” reset history (models stay loaded)"),
460
- "history": (_cmd_history, " β€” list all past sessions"),
461
- "session": (_cmd_session, "<id> β€” print turns from a session"),
462
- "export": (_cmd_export, "<id> <file> β€” export session to .md file"),
463
- "metatron": (_cmd_metatron, "<number> β€” set number of Memory Capsules to load"),
464
- "loaded": (_cmd_loaded, "<number> β€” set number of Memory Capsules loaded"),
465
- "metronome": (_cmd_metronome, "<seconds> β€” set awareness/consciousness interval"),
466
- "garden": (_cmd_garden, "<save> | <load> | <clear> β€” garden history handling"),
467
- "help": (_cmd_help, " β€” show this command list"),
468
- "exit": (_cmd_exit, " β€” quit the app"),
469
- "quit": (_cmd_exit, " β€” quit the app (alias)")
 
 
 
470
  }
471
 
472
  def handle_command(sensor_input_raw: str) -> str | None:
@@ -1259,7 +1308,6 @@ def main() -> None:
1259
  print()
1260
  print(f" {c.green}[*] All hemispheres loaded and ready.{c.res}")
1261
 
1262
- _metatron_heartbeats: int = 0
1263
  _heartbeats: int = 0
1264
  _timings: dict[str, TimingResult] = {}
1265
  _tree: str = ""
@@ -1272,25 +1320,25 @@ def main() -> None:
1272
  _tree = "Z" # Set to sentience history garden tree
1273
 
1274
  time.sleep(ΞœΞ•Ξ€Ξ‘Ξ©Ξ)
1275
- _metatron_heartbeats += ΞœΞ•Ξ€Ξ‘Ξ©Ξ
1276
  _heartbeats += ΞœΞ•Ξ€Ξ‘Ξ©Ξ
1277
 
1278
  # ── Condensatron cycle - extract surprises ───────────────────────────────
1279
- for c_tree in ("Z", "C", "F"):
1280
- if garden["condensatron_state"][c_tree]:
1281
- print(f" {c.inv} ── Start condensatron cycle: garden['{c_tree}'] ──────────────────────────── {c.res}")
1282
- # ── Brain pipeline condensatron cycle ────────────────────────────
1283
- _timings = Mindlink(_models, c_tree)
1284
- _timings["mind"] = Lambda(_models, c_tree)
1285
- memotron(_models, c_tree, _session_id, _timings) # Append to garden history
1286
- # Reset turn-based data and preset terminal for next cycle
1287
- _metatron_heartbeats, _heartbeats = 0, 0
1288
- reset_turn_content(tree=c_tree)
1289
- print(f"\n{c.inv} You: {c.res} ", end="", flush=True)
1290
- continue # Restart the while loop
 
1291
 
1292
  # ── Startup: Load Metatron memory capsules ───────────────────────────────
1293
- if _metatron_heartbeats >= METATRON_METRONOME: # Timed loop
1294
  if config.n_metatron_to_load and config.n_metatron_loaded < config.n_metatron_to_load:
1295
  _print_metatron_loaded = config.n_metatron_loaded + 1 # Print only start at 1
1296
  print(f"\n {c.inv} ── n_metatron_loaded: {_print_metatron_loaded} _sensor_input: {_sensor_input} ──────────────────────────── {c.res}")
@@ -1299,15 +1347,18 @@ def main() -> None:
1299
  # ── Z-factor sentience user input ────────────────────────────────────────
1300
  try:
1301
  _sensor_input = input_queue.get_nowait()
1302
- _metatron_heartbeats, _heartbeats = 0, 0
1303
  except queue.Empty:
1304
  pass
1305
 
1306
  # ── X-factor Awarenss and Y-factor Consciousness heartbeats ──────────────
1307
  if _heartbeats >= config.awareness_consciousness_metronome:
1308
- # ── X-factor awareness cycle ─────────────────────────────────────────
 
 
 
1309
  if not config.was_awareness_metronome:
1310
- _metatron_heartbeats, _heartbeats = 0, 0
1311
  print(f"\n {c.inv} ── X-factor: Fetching awareness news ── {c.res}")
1312
  _news = fetch_awareness_news()
1313
  print(f"\n {c.green}── X-factor: _news:\n{_news}\n──────────────────────────{c.res}")
@@ -1315,6 +1366,8 @@ def main() -> None:
1315
  config.was_awareness_metronome = True
1316
  _sensor_input = _news # Use the sensor["Z"]["input"]
1317
  print(f"\n {c.inv} ── X-factor: awareness pipeline ── {c.res}")
 
 
1318
  # ── Y-factor consciousness cycle ─────────────────────────────────────
1319
  elif config.was_awareness_metronome:
1320
  config.was_awareness_metronome = False
@@ -1325,12 +1378,12 @@ def main() -> None:
1325
  _timings["mind"] = Lambda(_models, _tree)
1326
  memotron(_models, _tree, _session_id, _timings) # Append to garden history
1327
  # Reset turn-based data and preset terminal for next cycle
1328
- _metatron_heartbeats, _heartbeats = 0, 0
1329
  reset_turn_content(tree=_tree)
1330
  print(f"\n{c.inv} You: {c.res} ", end="", flush=True)
1331
  continue # Restart the while loop
1332
 
1333
- if not _sensor_input: # wait state loop restart here
1334
  continue
1335
 
1336
  # ── Slash command detection ──────────────────────────────────────────
@@ -1343,7 +1396,7 @@ def main() -> None:
1343
  except _Clear:
1344
  garden[_tree].clear()
1345
  # Reset turn-based data
1346
- _metatron_heartbeats, _heartbeats = 0, 0
1347
  reset_turn_content()
1348
  print(f" {c.green}[*] History cleared. Models and session stay active.{c.res}")
1349
  print_banner(_tree, _session_id)
@@ -1372,7 +1425,7 @@ def main() -> None:
1372
 
1373
  memotron(_models, _tree, _session_id, _timings) # Store the response
1374
  # Reset turn-based data and preset terminal for next cycle
1375
- _metatron_heartbeats, _heartbeats = 0, 0
1376
  reset_turn_content() # Reset Z-factor data only
1377
  print(f"\n{c.inv} You: {c.res} ", end="", flush=True)
1378
 
 
80
  from config import sensor
81
 
82
  from config import ΞœΞ•Ξ€Ξ‘Ξ©Ξ
 
83
  from config import METATRON_TO_LOAD
84
  from config import AWARENESS_MAX_RESULTS
85
  from config import FETCH_NEWS_FROM
 
407
  return
408
  db_export_session(int(_parts[0]), _parts[1].strip())
409
 
410
+ def _cmd_n_metatron(arg: str) -> None:
411
  if not arg.strip().isdigit():
412
+ print(f" {c.green}Usage: /n_metatron <number> e.g. /n_metatron 5{c.res}")
413
  return None
414
  config.n_metatron_to_load = int(arg.strip())
415
  print(f" {c.green}[metatron] n_metatron_to_load set to {config.n_metatron_to_load}{c.res}")
 
423
  print(f" {c.green}[loaded] n_metatron_loaded set to {config.n_metatron_loaded}{c.res}")
424
  return None
425
 
426
+ def _cmd_metatron(arg: str) -> None:
427
+ if not arg.strip().isdigit():
428
+ print(f" {c.green}Usage: /metatron <seconds> e.g. /metatron 30{c.res}")
429
+ return None
430
+ config.metatron_metronome = int(arg.strip())
431
+ print(f" {c.green}[metronome] metatron_metronome set to {config.metatron_metronome}s{c.res}")
432
+ return None
433
+
434
+ def _cmd_condensatron(arg: str) -> None:
435
+ if not arg.strip().isdigit():
436
+ print(f" {c.green}Usage: /condensatron <seconds> e.g. /condensatron 30{c.res}")
437
+ return None
438
+ config.condensatron_metronome = int(arg.strip())
439
+ print(f" {c.green}[metronome] condensatron_metronome set to {config.condensatron_metronome}s{c.res}")
440
+ return None
441
+
442
  def _cmd_metronome(arg: str) -> None:
443
  if not arg.strip().isdigit():
444
  print(f" {c.green}Usage: /metronome <seconds> e.g. /metronome 120{c.res}")
 
447
  print(f" {c.green}[metronome] awareness_consciousness_metronome set to {config.awareness_consciousness_metronome}s{c.res}")
448
  return None
449
 
450
+ def _cmd_enable_awareness(arg: str) -> None:
451
+ arg_clean = arg.strip().lower()
452
+ if arg_clean not in ("true", "false"):
453
+ print(f" {c.green}Usage: /enable_awareness <boolean> e.g. /enable_awareness False{c.res}")
454
+ return None
455
+ config.enable_awareness = (arg_clean == "true") # "true" == "true" β†’ True (bool) # "false" == "true" β†’ False (bool)
456
+ print(f" {c.green}[awareness] enable_awareness set to {config.enable_awareness}{c.res}")
457
+ return None
458
+
459
  def _cmd_garden(arg: str) -> None:
460
  if arg == "save":
461
  save_garden_state()
 
468
  print(f" {c.green}Usage: /garden save | load | clear{c.res}")
469
  return None
470
 
471
+
472
  def _cmd_help(arg: str) -> None:
473
  print()
474
  print(f" {c.green}Slash commands")
475
  print(" " + "─" * 56)
476
+
477
+ # Descriptions built dynamically so they reflect current config values
478
+ descriptions = {
479
+ "n_metatron": f"<number> β€” set number of Memory Capsules to load: {config.n_metatron_to_load}",
480
+ "loaded": f"<number> β€” set number of Memory Capsules loaded: {config.n_metatron_loaded}",
481
+ "metatron": f"<seconds> β€” set metatron interval: {config.metatron_metronome}s",
482
+ "condensatron": f"<seconds> β€” set condensatron interval: {config.condensatron_metronome}s",
483
+ "metronome": f"<seconds> β€” set awareness/consciousness interval: {config.awareness_consciousness_metronome}s",
484
+ "enable_awareness": f"<True | False> β€” disable awareness mode if offline: {config.enable_awareness}",
485
+ }
486
+
487
+ for name, (_, base_desc) in COMMANDS.items():
488
+ desc = descriptions.get(name, base_desc)
489
+ print(f" /{name:<14} {desc}")
490
  print(c.res)
491
  return None
492
 
493
+ # def _cmd_help(arg: str) -> None:
494
+ # print()
495
+ # print(f" {c.green}Slash commands")
496
+ # print(" " + "─" * 56)
497
+ # for name, (_, description) in COMMANDS.items():
498
+ # print(f" /{name:<14} {description}")
499
+ # print(c.res)
500
+ # return None
501
+
502
  COMMANDS: dict[str, tuple] = {
503
+ "file": (_cmd_file, "<path> β€” load a file as the next message"),
504
+ "paste": (_cmd_paste, " β€” multiline input (type END to send)"),
505
+ "clear": (_cmd_clear, " β€” reset history (models stay loaded)"),
506
+ "history": (_cmd_history, " β€” list all past sessions"),
507
+ "session": (_cmd_session, "<id> β€” print turns from a session"),
508
+ "export": (_cmd_export, "<id> <file> β€” export session to .md file"),
509
+ "n_metatron": (_cmd_n_metatron, "<number> β€” set number of Memory Capsules to load"),
510
+ "loaded": (_cmd_loaded, "<number> β€” set number of Memory Capsules loaded"),
511
+ "metatron": (_cmd_metatron, "<seconds> β€” set metatron interval"),
512
+ "condensatron": (_cmd_condensatron, "<seconds> β€” set condensatron interval"),
513
+ "metronome": (_cmd_metronome, "<seconds> β€” set awareness/consciousness interval"),
514
+ "enable_awareness": (_cmd_enable_awareness, "<True | False> β€” disable awareness mode if offline"),
515
+ "garden": (_cmd_garden, "<save> | <load> | <clear> β€” garden history handling"),
516
+ "help": (_cmd_help, " β€” show this command list"),
517
+ "exit": (_cmd_exit, " β€” quit the app"),
518
+ "quit": (_cmd_exit, " β€” quit the app (alias)"),
519
  }
520
 
521
  def handle_command(sensor_input_raw: str) -> str | None:
 
1308
  print()
1309
  print(f" {c.green}[*] All hemispheres loaded and ready.{c.res}")
1310
 
 
1311
  _heartbeats: int = 0
1312
  _timings: dict[str, TimingResult] = {}
1313
  _tree: str = ""
 
1320
  _tree = "Z" # Set to sentience history garden tree
1321
 
1322
  time.sleep(ΞœΞ•Ξ€Ξ‘Ξ©Ξ)
 
1323
  _heartbeats += ΞœΞ•Ξ€Ξ‘Ξ©Ξ
1324
 
1325
  # ── Condensatron cycle - extract surprises ───────────────────────────────
1326
+ if _heartbeats >= config.condensatron_metronome:
1327
+ for c_tree in ("Z", "C", "F"):
1328
+ if garden["condensatron_state"][c_tree]:
1329
+ print(f" {c.inv} ── Start condensatron cycle: garden['{c_tree}'] ──────────────────────────── {c.res}")
1330
+ # ── Brain pipeline condensatron cycle ────────────────────────────
1331
+ _timings = Mindlink(_models, c_tree)
1332
+ _timings["mind"] = Lambda(_models, c_tree)
1333
+ memotron(_models, c_tree, _session_id, _timings) # Append to garden history
1334
+ # Reset turn-based data and preset terminal for next cycle
1335
+ _heartbeats = 0 # Reset heartbeats time
1336
+ reset_turn_content(tree=c_tree)
1337
+ print(f"\n{c.inv} You: {c.res} ", end="", flush=True)
1338
+ continue # Restart the while loop
1339
 
1340
  # ── Startup: Load Metatron memory capsules ───────────────────────────────
1341
+ if _heartbeats >= config.metatron_metronome: # Timed loop
1342
  if config.n_metatron_to_load and config.n_metatron_loaded < config.n_metatron_to_load:
1343
  _print_metatron_loaded = config.n_metatron_loaded + 1 # Print only start at 1
1344
  print(f"\n {c.inv} ── n_metatron_loaded: {_print_metatron_loaded} _sensor_input: {_sensor_input} ──────────────────────────── {c.res}")
 
1347
  # ── Z-factor sentience user input ────────────────────────────────────────
1348
  try:
1349
  _sensor_input = input_queue.get_nowait()
1350
+ _heartbeats = 0 # Reset heartbeats time
1351
  except queue.Empty:
1352
  pass
1353
 
1354
  # ── X-factor Awarenss and Y-factor Consciousness heartbeats ──────────────
1355
  if _heartbeats >= config.awareness_consciousness_metronome:
1356
+ # ── X-factor awareness cycle ─────────────────────────────────────────
1357
+ if not config.enable_awareness:
1358
+ config.was_awareness_metronome = True
1359
+
1360
  if not config.was_awareness_metronome:
1361
+ _heartbeats = 0 # Reset heartbeats time
1362
  print(f"\n {c.inv} ── X-factor: Fetching awareness news ── {c.res}")
1363
  _news = fetch_awareness_news()
1364
  print(f"\n {c.green}── X-factor: _news:\n{_news}\n──────────────────────────{c.res}")
 
1366
  config.was_awareness_metronome = True
1367
  _sensor_input = _news # Use the sensor["Z"]["input"]
1368
  print(f"\n {c.inv} ── X-factor: awareness pipeline ── {c.res}")
1369
+ else:
1370
+ config.was_awareness_metronome = True # Skip to Y-phase if offline
1371
  # ── Y-factor consciousness cycle ─────────────────────────────────────
1372
  elif config.was_awareness_metronome:
1373
  config.was_awareness_metronome = False
 
1378
  _timings["mind"] = Lambda(_models, _tree)
1379
  memotron(_models, _tree, _session_id, _timings) # Append to garden history
1380
  # Reset turn-based data and preset terminal for next cycle
1381
+ _heartbeats = 0 # Reset heartbeats time
1382
  reset_turn_content(tree=_tree)
1383
  print(f"\n{c.inv} You: {c.res} ", end="", flush=True)
1384
  continue # Restart the while loop
1385
 
1386
+ if not _sensor_input: # wait state loop restarts here if empty input
1387
  continue
1388
 
1389
  # ── Slash command detection ──────────────────────────────────────────
 
1396
  except _Clear:
1397
  garden[_tree].clear()
1398
  # Reset turn-based data
1399
+ _heartbeats = 0 # Reset heartbeats time
1400
  reset_turn_content()
1401
  print(f" {c.green}[*] History cleared. Models and session stay active.{c.res}")
1402
  print_banner(_tree, _session_id)
 
1425
 
1426
  memotron(_models, _tree, _session_id, _timings) # Store the response
1427
  # Reset turn-based data and preset terminal for next cycle
1428
+ _heartbeats = 0 # Reset heartbeats time
1429
  reset_turn_content() # Reset Z-factor data only
1430
  print(f"\n{c.inv} You: {c.res} ", end="", flush=True)
1431