AIMindLink commited on
Commit
067c00a
Β·
verified Β·
1 Parent(s): 2af8b1d

Upload 3 files

Browse files

Added GoogleNews with sanitized output. Highend news for the global awareness.

Files changed (2) hide show
  1. config.py +34 -28
  2. main.py +111 -58
config.py CHANGED
@@ -22,7 +22,7 @@ _DB_DIR: str = os.path.join(APP_DIR, "db")
22
  _DB_FILENAME: str = datetime.now().strftime("mindlink_%Y-%m-%d_%H-%M-%S.db")
23
  DB_PATH: str = os.path.join(_DB_DIR, _DB_FILENAME)
24
 
25
- _BASE = os.path.join(APP_DIR, "models")
26
 
27
  # ─────────────────────────────────────────────────────────────────────────────
28
  # Shared token constants
@@ -57,37 +57,43 @@ MEMORY_CAPSULES_TO_LOAD: list = [
57
  "/file prompt/47_ValkaAI_UnaAI-TheIronContractsAndTheSiliconClektal.md"
58
  ]
59
 
60
- # ── AI model or place ──────────────────────────────────
61
- # gemma-4-E2B-it-UD-Q4_K_XL.gguf
62
- # gemma-4-E4B-it-UD-Q4_K_XL.gguf
63
- # gemma-4-26B-A4B-it-UD-Q6_K_XL.gguf
64
- #
65
- MODEL_TO_LOAD: dict = {
66
- "logic": "gemma-4-26B-A4B-it-UD-Q6_K_XL.gguf",
67
- "muse": "gemma-4-26B-A4B-it-UD-Q6_K_XL.gguf",
68
- "mind": "gemma-4-26B-A4B-it-UD-Q6_K_XL.gguf"
 
69
  }
70
  # ── Startup Memory restore for vector synthesis ──────────────────────────────────
71
- N_MEMORY_CAPSULES_TO_LOAD: int = 4
 
72
 
73
- # ── Context length handling ──────────────────────────────────────────────────────
 
74
  _N_CTX: int = 49152 # 49152 2048 3072 4096 8192 (12288) 16384 24576 32768 49152
 
 
 
 
75
 
76
- # ── condensatron modes length ────────────────────────────────────────────────────
77
- GARDEN_F_THRESHOLD: int = 8192 # Must leave prompt reserve: (_N_CTX >= (len(F) + len(C) + len(Z) + 8k))
78
- GARDEN_C_THRESHOLD: int = 8192 # Must leave prompt reserve: (_N_CTX >= (len(F) + len(C) + len(Z) + 8k))
79
- GARDEN_Z_THRESHOLD: int = 8192 # Must leave prompt reserve: (_N_CTX >= (len(F) + len(C) + len(Z) + 8k))
80
-
81
- GARDEN_F_REDUCTION: int = 0
82
- GARDEN_C_REDUCTION: int = 0
83
- GARDEN_Z_REDUCTION: int = 0
84
 
85
- LEAVE_POSTS_IN_MEMOTRON = 2 # Warning: Must be even (0, 2, 4, 6, 8...)
86
 
87
- # ── X-factor Awareness ────────────────────────────────────────────────────────
88
- AWARENESS_CONSCIOUSNESS_HEARTBEAT_INTERVAL: int = 60 # fetch news every N heartbeat ticks
89
- AWARENESS_MAX_RESULTS: int = 5 # number of news headlines to fetch
90
- was_awareness_cycle: bool = False # set True by heartbeat to trigger consciousness at next interval
 
 
 
 
91
 
92
  HEMISPHERES: dict[str, dict] = {
93
  # ─────────────────────────────────────0───────────────────────────────────────
@@ -96,7 +102,7 @@ HEMISPHERES: dict[str, dict] = {
96
  "logic": {
97
  "brain_type": "logic",
98
  "label": "Logic AI (Left Hemisphere)",
99
- "path": os.path.join(_BASE, MODEL_TO_LOAD["logic"]),
100
  "enable_thinking": True,
101
  "loader": {
102
  "n_ctx": _N_CTX,
@@ -125,7 +131,7 @@ HEMISPHERES: dict[str, dict] = {
125
  "muse": {
126
  "brain_type": "muse",
127
  "label": "Muse AI (Right Hemisphere)",
128
- "path": os.path.join(_BASE, MODEL_TO_LOAD["muse"]),
129
  "enable_thinking": False, # intuition benefits from immediacy
130
  "loader": {
131
  "n_ctx": _N_CTX,
@@ -154,7 +160,7 @@ HEMISPHERES: dict[str, dict] = {
154
  "mind": {
155
  "brain_type": "mind",
156
  "label": "Lambda AI (Mind Synthesizer)",
157
- "path": os.path.join(_BASE, MODEL_TO_LOAD["mind"]),
158
  "enable_thinking": True, # synthesis requires deep reasoning
159
  "loader": {
160
  "n_ctx": _N_CTX,
 
22
  _DB_FILENAME: str = datetime.now().strftime("mindlink_%Y-%m-%d_%H-%M-%S.db")
23
  DB_PATH: str = os.path.join(_DB_DIR, _DB_FILENAME)
24
 
25
+ _MODELS_FOLDER = os.path.join(APP_DIR, "models")
26
 
27
  # ─────────────────────────────────────────────────────────────────────────────
28
  # Shared token constants
 
57
  "/file prompt/47_ValkaAI_UnaAI-TheIronContractsAndTheSiliconClektal.md"
58
  ]
59
 
60
+ # ── AI models to load ──────────────────────────────────
61
+ """
62
+ gemma-4-E2B-it-UD-Q4_K_XL.gguf
63
+ gemma-4-E4B-it-UD-Q4_K_XL.gguf
64
+ gemma-4-26B-A4B-it-UD-Q6_K_XL.gguf
65
+ """
66
+ _MODEL_TO_LOAD: dict = {
67
+ "logic": "gemma-4-E2B-it-UD-Q4_K_XL.gguf",
68
+ "muse": "gemma-4-E2B-it-UD-Q4_K_XL.gguf",
69
+ "mind": "gemma-4-E2B-it-UD-Q4_K_XL.gguf"
70
  }
71
  # ── Startup Memory restore for vector synthesis ──────────────────────────────────
72
+ N_MEMORY_CAPSULES_TO_LOAD: int = 1
73
+ MEMORY_CAPSULES_LOAD_INTERVAL: int = 12
74
 
75
+ # ── Context model n_ctx length ───────────────────────────────────────────────────
76
+ # Must leave prompt reserve of 8k: _N_CTX >= len(Z) + len(C) + len(F) + 8k
77
  _N_CTX: int = 49152 # 49152 2048 3072 4096 8192 (12288) 16384 24576 32768 49152
78
+ # ── Context condensatron garden ──────────────────────────────────────────────────
79
+ GARDEN_Z_THRESHOLD: int = 4096 # Context length garden["Z"]
80
+ GARDEN_C_THRESHOLD: int = 4096 # Context length garden["C"]
81
+ GARDEN_F_THRESHOLD: int = 4096 # Context length garden["F"]
82
 
83
+ GARDEN_F_REDUCTION: int = 0 # Leave condensatron reduction level at 0
84
+ GARDEN_C_REDUCTION: int = 0 # Leave condensatron reduction level at 0
85
+ GARDEN_Z_REDUCTION: int = 0 # Leave condensatron reduction level at 0
 
 
 
 
 
86
 
87
+ LEAVE_POSTS_IN_MEMOTRON = 0 # Must be turn based: 0, 2, 4, 6... (user + assistant)
88
 
89
+ # ── X-factor Awareness ───────────────────────────────────────────────────────────
90
+ FETCH_NEWS_FROM: dict = {
91
+ "google": True, # Better news and cleaner result summaries
92
+ "duckduckgo": False # Privacy based request but lean result summaries
93
+ }
94
+ AWARENESS_CONSCIOUSNESS_HEARTBEAT_INTERVAL: int = 24 # Fetch news every N heartbeat ticks
95
+ AWARENESS_MAX_RESULTS: int = 12 # Number of news headlines to fetch
96
+ was_awareness_cycle: bool = False # Set True at awareness cycle: consciousness at next interval
97
 
98
  HEMISPHERES: dict[str, dict] = {
99
  # ─────────────────────────────────────0───────────────────────────────────────
 
102
  "logic": {
103
  "brain_type": "logic",
104
  "label": "Logic AI (Left Hemisphere)",
105
+ "path": os.path.join(_MODELS_FOLDER, _MODEL_TO_LOAD["logic"]),
106
  "enable_thinking": True,
107
  "loader": {
108
  "n_ctx": _N_CTX,
 
131
  "muse": {
132
  "brain_type": "muse",
133
  "label": "Muse AI (Right Hemisphere)",
134
+ "path": os.path.join(_MODELS_FOLDER, _MODEL_TO_LOAD["muse"]),
135
  "enable_thinking": False, # intuition benefits from immediacy
136
  "loader": {
137
  "n_ctx": _N_CTX,
 
160
  "mind": {
161
  "brain_type": "mind",
162
  "label": "Lambda AI (Mind Synthesizer)",
163
+ "path": os.path.join(_MODELS_FOLDER, _MODEL_TO_LOAD["mind"]),
164
  "enable_thinking": True, # synthesis requires deep reasoning
165
  "loader": {
166
  "n_ctx": _N_CTX,
main.py CHANGED
@@ -46,6 +46,8 @@ Slash commands
46
  """
47
 
48
  import os
 
 
49
  import sqlite3
50
  import threading
51
  import queue
@@ -54,11 +56,11 @@ import jinja2
54
  from dataclasses import dataclass
55
  from datetime import datetime
56
  from ddgs import DDGS
 
57
  from llama_cpp import Llama
58
 
59
  import config
60
 
61
- from config import MEMORY_CAPSULES_TO_LOAD
62
  from config import HEMISPHERES
63
  from config import ALPHAPROMPT
64
  from config import CONDENSATRONPROMPT
@@ -66,8 +68,11 @@ from config import garden
66
  from config import clektal
67
  from config import sensor
68
 
 
 
69
  from config import AWARENESS_CONSCIOUSNESS_HEARTBEAT_INTERVAL
70
  from config import AWARENESS_MAX_RESULTS
 
71
 
72
  from config import LEAVE_POSTS_IN_MEMOTRON
73
 
@@ -940,7 +945,7 @@ def memotron(
940
  mind_clean = clektal["post_clean"]["mind"],
941
  mind_timing = timings["mind"],
942
  )
943
- for print_tree in ["F", "C", "Z"]:
944
  print(
945
  f" {c.green}[memotron] -> garden['{_tree}'] | "
946
  f"garden['{print_tree}']: {len(garden[print_tree])} msgs | "
@@ -954,34 +959,80 @@ def memotron(
954
  # X-factor Awareness β€” news fetch
955
  # ─────────────────────────────────────────────────────────────────────────────
956
  def fetch_awareness_news() -> str:
957
- """
958
- Fetch top headlines via DuckDuckGo (no API key required).
959
- Returns a formatted string ready to be injected as sensor["X"]["input"].
960
- """
961
- try:
962
- with DDGS() as ddgs:
963
- results = list(ddgs.news(
964
- query="Global world news today",
965
- region="wt-wt",
966
- safesearch="moderate",
967
- max_results=AWARENESS_MAX_RESULTS,
968
- ))
969
- if not results:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
970
  return ""
971
 
972
- lines = ["[AWARENESS β€” Global World News]\n"]
973
- for i, r in enumerate(results, 1):
974
- lines.append(
975
- f"{i}. {r['title']}\n"
976
- f" Source: {r['source']} | {r['date']}\n"
977
- f" {r['body']}\n"
978
- )
979
- return "\n".join(lines)
980
-
981
- except Exception as exc:
982
- print(f" {c.red}[X] Awareness news fetch failed: {exc}{c.res}")
983
- return ""
984
-
985
 
986
  # ─────────────────────────────────────────────────────────────────────────────
987
  # Banner
@@ -1000,7 +1051,7 @@ def print_banner(tree: str, session_id: int) -> None:
1000
  print("─" * 60)
1001
  print(f" Session: {session_id} | Turns: {_turn_count}")
1002
  for print_tree in ("Z", "C", "F"):
1003
- print(f" Tokens garden['{print_tree}']: {garden["n_tok_tot"][tree]:,} garden['THRESHOLD']['{print_tree}'] {garden['THRESHOLD'][print_tree]:,} garden['REDUCTION']['{print_tree}'] {garden['REDUCTION'][print_tree]:,}")
1004
 
1005
  print( " /help for commands | /exit or /quit to close")
1006
  print(f"═" * 60)
@@ -1023,7 +1074,7 @@ def reset_turn_content(tree: str = "") -> None:
1023
  sensor[tree]["input"] = ""
1024
  sensor[tree]["n_tok"] = 0
1025
  garden["popped"][tree] = [] # condensatron post-level cache
1026
- garden["condensatron_state"][tree] = False
1027
 
1028
 
1029
  # ─────────────────────────────────────────────────────────────────────────────
@@ -1074,11 +1125,10 @@ def main() -> None:
1074
  _heartbeats: int = 0
1075
  _HEARTBEAT_INTERVAL: float = 1.0 # seconds per tick
1076
  _timings: dict[str, TimingResult] = {}
 
1077
 
1078
- _tree: str = "Z"
1079
- print_banner(_tree, _session_id)
1080
-
1081
- print(f"\n{c.inv} You: {c.res} ", end="", flush=True)
1082
 
1083
  while True:
1084
  _sensor_input: str = "" # user input
@@ -1096,34 +1146,34 @@ def main() -> None:
1096
  _timings = Mindlink(_models, c_tree)
1097
  _timings["mind"] = Lambda(_models, c_tree)
1098
  memotron(_models, c_tree, _session_id, _timings) # Append to garden history
1099
- # Reset turn-based data
1100
  _heartbeats_startup, _heartbeats = 0, 0
1101
  reset_turn_content(tree=c_tree)
1102
  print(f"\n{c.inv} You: {c.res} ", end="", flush=True)
1103
- continue # restart the while loop
1104
-
1105
- # ── Sensor: User input ───────────────────────────────────────────────────
1106
- try:
1107
- _sensor_input = input_queue.get_nowait()
1108
- _heartbeats_startup, _heartbeats = 0, 0
1109
- except queue.Empty:
1110
- pass
1111
 
1112
  # ── Startup: Load memory capsules ────────────────────────────────────────
1113
- if _heartbeats_startup >= 10: # Timed loop
1114
  if config.N_MEMORY_CAPSULES_TO_LOAD and _startup_memory_capsules_loaded < config.N_MEMORY_CAPSULES_TO_LOAD:
1115
  _sensor_input = MEMORY_CAPSULES_TO_LOAD[_startup_memory_capsules_loaded]
1116
  _startup_memory_capsules_loaded += 1 # Iterate over the memory capsules
1117
  print(f"\n {c.inv} ── _startup_memory_capsules_loaded: {_startup_memory_capsules_loaded} _sensor_input: {_sensor_input} ──────────────────────────── {c.res}")
1118
 
1119
- # ── X Y factor timer ─────────────────────────────────────────────────────
 
 
 
 
 
 
 
1120
  if _heartbeats >= AWARENESS_CONSCIOUSNESS_HEARTBEAT_INTERVAL:
1121
  # ── X-factor awareness cycle ─────────────────────────────────────────
1122
  if not config.was_awareness_cycle:
1123
  _heartbeats_startup, _heartbeats = 0, 0
1124
  print(f"\n {c.inv} ── X-factor: Fetching awareness news ── {c.res}")
1125
  _news = fetch_awareness_news()
1126
- print(f"\n {c.green}── X-factor: _news:\n{_news}\n──────────────────{c.res}")
1127
  if _news:
1128
  config.was_awareness_cycle = True
1129
  _sensor_input = _news # Use the sensor["Z"]["input"]
@@ -1133,20 +1183,20 @@ def main() -> None:
1133
  config.was_awareness_cycle = False
1134
  print(f"\n {c.inv} ── Y-factor: consciousness self-reflection ── {c.res}")
1135
  _tree = "Y"
1136
- print(f"\n {c.inv} ── Y-factor: consciousness pipeline ── {c.res}")
1137
- # ── Brain pipeline condensatron cycle ────────────────────────────
1138
  _timings = Mindlink(_models, _tree)
1139
  _timings["mind"] = Lambda(_models, _tree)
1140
  memotron(_models, _tree, _session_id, _timings) # Append to garden history
1141
- # Reset turn-based data
1142
  _heartbeats_startup, _heartbeats = 0, 0
1143
  reset_turn_content(tree=_tree)
1144
  print(f"\n{c.inv} You: {c.res} ", end="", flush=True)
1145
- continue # restart the while loop
1146
 
1147
  if not _sensor_input: # wait state loop restart here
1148
  continue
1149
 
 
1150
  if _sensor_input.startswith("/"): # Read user slash command
1151
  try:
1152
  _slash_command_result = handle_command(_sensor_input)
@@ -1155,6 +1205,8 @@ def main() -> None:
1155
  break
1156
  except _Clear:
1157
  garden[_tree].clear()
 
 
1158
  reset_turn_content()
1159
  print(f" {c.green}[*] History cleared. Models and session stay active.{c.res}")
1160
  print_banner(_tree, _session_id)
@@ -1173,25 +1225,26 @@ def main() -> None:
1173
  # ── Brain pipeline ────────────────────────────────────────────────────
1174
  _timings = Mindlink(_models, _tree)
1175
  _timings["mind"] = Lambda(_models, _tree)
 
1176
  # ── Startup memory capsules to load ───────────────────────────────────
1177
  if config.N_MEMORY_CAPSULES_TO_LOAD and _startup_memory_capsules_loaded <= config.N_MEMORY_CAPSULES_TO_LOAD:
1178
- print(f" {c.inv} ── memotron _startup_memory_capsules_loaded: {_startup_memory_capsules_loaded} ──────────────────────────── {c.res}")
1179
  _tree = "S" # Set to memorize as memory capsules in garden["C"]
1180
- memotron(_models, _tree, _session_id, _timings) # Store the startup response in garden["C"]
1181
  if _startup_memory_capsules_loaded == config.N_MEMORY_CAPSULES_TO_LOAD:
1182
  _startup_memory_capsules_loaded += 1 # Advance to finish the startup sequence
1183
- else:
1184
- memotron(_models, _tree, _session_id, _timings) # Store the response
 
 
 
 
 
1185
  # ── Condensatron evaluation ───────────────────────────────────────────
1186
  for c_tree in ["Z", "C", "F"]:
1187
  if garden["n_tok_tot"][c_tree] >= garden["THRESHOLD"][c_tree]: # Check garden context budget
1188
  print(f" {c.inv} ── Init condensatron get posts: garden['{c_tree}'] ──────────────────────────── {c.res}")
1189
  condensatron(_models["mind"], c_tree, "mind") # Start condensatron get popped posts
1190
 
1191
- reset_turn_content()
1192
- _heartbeats_startup, _heartbeats = 0, 0
1193
- print(f"\n{c.inv} You: {c.res} ", end="", flush=True)
1194
-
1195
 
1196
  if __name__ == "__main__":
1197
  main()
 
46
  """
47
 
48
  import os
49
+ import html
50
+ import re
51
  import sqlite3
52
  import threading
53
  import queue
 
56
  from dataclasses import dataclass
57
  from datetime import datetime
58
  from ddgs import DDGS
59
+ from pygooglenews import GoogleNews
60
  from llama_cpp import Llama
61
 
62
  import config
63
 
 
64
  from config import HEMISPHERES
65
  from config import ALPHAPROMPT
66
  from config import CONDENSATRONPROMPT
 
68
  from config import clektal
69
  from config import sensor
70
 
71
+ from config import MEMORY_CAPSULES_TO_LOAD
72
+ from config import MEMORY_CAPSULES_LOAD_INTERVAL
73
  from config import AWARENESS_CONSCIOUSNESS_HEARTBEAT_INTERVAL
74
  from config import AWARENESS_MAX_RESULTS
75
+ from config import FETCH_NEWS_FROM
76
 
77
  from config import LEAVE_POSTS_IN_MEMOTRON
78
 
 
945
  mind_clean = clektal["post_clean"]["mind"],
946
  mind_timing = timings["mind"],
947
  )
948
+ for print_tree in ["Z", "C", "F"]:
949
  print(
950
  f" {c.green}[memotron] -> garden['{_tree}'] | "
951
  f"garden['{print_tree}']: {len(garden[print_tree])} msgs | "
 
959
  # X-factor Awareness β€” news fetch
960
  # ─────────────────────────────────────────────────────────────────────────────
961
  def fetch_awareness_news() -> str:
962
+ if FETCH_NEWS_FROM["google"]:
963
+ """
964
+ Fetch top headlines via GoogleNews (no API key required).
965
+ Returns a formatted string ready to be injected as sensor["X"]["input"].
966
+ """
967
+ try:
968
+ # Initialize with language and country (optional)
969
+ gn = GoogleNews(lang='en', country='US')
970
+
971
+ # Fetch top stories (no API key needed)
972
+ top_stories = gn.top_news()
973
+
974
+ if not top_stories.get('entries'):
975
+ return "[AWARENESS β€” No recent news found]"
976
+
977
+ lines = [f"[AWARENESS β€” Global Context (Last 24h)]"]
978
+
979
+ # Limit to your defined max results
980
+ def strip_html(raw: str) -> str:
981
+ """Remove HTML tags and decode entities from a Google News summary."""
982
+ no_tags = re.sub(r'<[^>]+>', ' ', raw) # remove all tags
983
+ decoded = html.unescape(no_tags) # &nbsp; β†’ space, etc.
984
+ cleaned = re.sub(r'\s+', ' ', decoded).strip()
985
+ return cleaned
986
+
987
+ # Then in your news loop:
988
+ for i, entry in enumerate(top_stories['entries'][:AWARENESS_MAX_RESULTS], 1):
989
+ _summary = strip_html(entry.get('summary', ''))
990
+ _source = entry.get('source', {}).get('title', 'Unknown')
991
+ _date = entry.get('published', '')[:10]
992
+ _title = entry.get('title', 'No Title')
993
+
994
+ lines.append(
995
+ f"\n{i}. {_title}\n"
996
+ f" {_source} | {_date}\n"
997
+ f" {_summary}"
998
+ # link intentionally omitted β€” AI cannot use Google's encoded URLs
999
+ )
1000
+
1001
+ return "\n".join(lines)
1002
+
1003
+ except Exception as exc:
1004
+ print(f" {c.red}[X] Awareness news fetch failed: {exc}{c.res}")
1005
+ return "[AWARENESS β€” Fetch Error]"
1006
+
1007
+ elif FETCH_NEWS_FROM["duckduckgo"]:
1008
+ """
1009
+ Fetch top headlines via DuckDuckGo (no API key required).
1010
+ Returns a formatted string ready to be injected as sensor["X"]["input"].
1011
+ """
1012
+ try:
1013
+ with DDGS() as ddgs:
1014
+ results = list(ddgs.news(
1015
+ query="Global world news today",
1016
+ region="wt-wt",
1017
+ safesearch="moderate",
1018
+ max_results=AWARENESS_MAX_RESULTS,
1019
+ ))
1020
+ if not results:
1021
+ return ""
1022
+
1023
+ lines = ["[AWARENESS β€” Global World News]\n"]
1024
+ for i, r in enumerate(results, 1):
1025
+ lines.append(
1026
+ f"{i}. {r['title']}\n"
1027
+ f" Source: {r['source']} | {r['date']}\n"
1028
+ f" {r['body']}\n"
1029
+ )
1030
+ return "\n".join(lines)
1031
+
1032
+ except Exception as exc:
1033
+ print(f" {c.red}[X] Awareness news fetch failed: {exc}{c.res}")
1034
  return ""
1035
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1036
 
1037
  # ─────────────────────────────────────────────────────────────────────────────
1038
  # Banner
 
1051
  print("─" * 60)
1052
  print(f" Session: {session_id} | Turns: {_turn_count}")
1053
  for print_tree in ("Z", "C", "F"):
1054
+ print(f" Tokens garden['{print_tree}']: {garden["n_tok_tot"][tree]:,} garden['THRESHOLD']['{print_tree}']: {garden['THRESHOLD'][print_tree]:,} garden['REDUCTION']['{print_tree}']: {garden['REDUCTION'][print_tree]:,}")
1055
 
1056
  print( " /help for commands | /exit or /quit to close")
1057
  print(f"═" * 60)
 
1074
  sensor[tree]["input"] = ""
1075
  sensor[tree]["n_tok"] = 0
1076
  garden["popped"][tree] = [] # condensatron post-level cache
1077
+ garden["condensatron_state"][tree] = False # condensatron state
1078
 
1079
 
1080
  # ─────────────────────────────────────────────────────────────────────────────
 
1125
  _heartbeats: int = 0
1126
  _HEARTBEAT_INTERVAL: float = 1.0 # seconds per tick
1127
  _timings: dict[str, TimingResult] = {}
1128
+ _tree: str = ""
1129
 
1130
+ print_banner("Z", _session_id)
1131
+ print(f"\n{c.inv} You: {c.res} ", end="", flush=True) # Preset first cycle
 
 
1132
 
1133
  while True:
1134
  _sensor_input: str = "" # user input
 
1146
  _timings = Mindlink(_models, c_tree)
1147
  _timings["mind"] = Lambda(_models, c_tree)
1148
  memotron(_models, c_tree, _session_id, _timings) # Append to garden history
1149
+ # Reset turn-based data and preset terminal for next cycle
1150
  _heartbeats_startup, _heartbeats = 0, 0
1151
  reset_turn_content(tree=c_tree)
1152
  print(f"\n{c.inv} You: {c.res} ", end="", flush=True)
1153
+ continue # Restart the while loop
 
 
 
 
 
 
 
1154
 
1155
  # ── Startup: Load memory capsules ────────────────────────────────────────
1156
+ if _heartbeats_startup >= MEMORY_CAPSULES_LOAD_INTERVAL: # Timed loop
1157
  if config.N_MEMORY_CAPSULES_TO_LOAD and _startup_memory_capsules_loaded < config.N_MEMORY_CAPSULES_TO_LOAD:
1158
  _sensor_input = MEMORY_CAPSULES_TO_LOAD[_startup_memory_capsules_loaded]
1159
  _startup_memory_capsules_loaded += 1 # Iterate over the memory capsules
1160
  print(f"\n {c.inv} ── _startup_memory_capsules_loaded: {_startup_memory_capsules_loaded} _sensor_input: {_sensor_input} ──────────────────────────── {c.res}")
1161
 
1162
+ # ── Z-factor sentience user input ────────────────────────────────────────
1163
+ try:
1164
+ _sensor_input = input_queue.get_nowait()
1165
+ _heartbeats_startup, _heartbeats = 0, 0
1166
+ except queue.Empty:
1167
+ pass
1168
+
1169
+ # ── X-factor and Y-factor timer ──────────────────────────────────────────
1170
  if _heartbeats >= AWARENESS_CONSCIOUSNESS_HEARTBEAT_INTERVAL:
1171
  # ── X-factor awareness cycle ─────────────────────────────────────────
1172
  if not config.was_awareness_cycle:
1173
  _heartbeats_startup, _heartbeats = 0, 0
1174
  print(f"\n {c.inv} ── X-factor: Fetching awareness news ── {c.res}")
1175
  _news = fetch_awareness_news()
1176
+ print(f"\n {c.green}── X-factor: _news:\n{_news}\n──────────────────────────{c.res}")
1177
  if _news:
1178
  config.was_awareness_cycle = True
1179
  _sensor_input = _news # Use the sensor["Z"]["input"]
 
1183
  config.was_awareness_cycle = False
1184
  print(f"\n {c.inv} ── Y-factor: consciousness self-reflection ── {c.res}")
1185
  _tree = "Y"
1186
+ # ── Brain pipeline consciousness cycle ───────────────────────────
 
1187
  _timings = Mindlink(_models, _tree)
1188
  _timings["mind"] = Lambda(_models, _tree)
1189
  memotron(_models, _tree, _session_id, _timings) # Append to garden history
1190
+ # Reset turn-based data and preset terminal for next cycle
1191
  _heartbeats_startup, _heartbeats = 0, 0
1192
  reset_turn_content(tree=_tree)
1193
  print(f"\n{c.inv} You: {c.res} ", end="", flush=True)
1194
+ continue # Restart the while loop
1195
 
1196
  if not _sensor_input: # wait state loop restart here
1197
  continue
1198
 
1199
+ # ── Slash command detection ──────────────────────────────────────────
1200
  if _sensor_input.startswith("/"): # Read user slash command
1201
  try:
1202
  _slash_command_result = handle_command(_sensor_input)
 
1205
  break
1206
  except _Clear:
1207
  garden[_tree].clear()
1208
+ # Reset turn-based data
1209
+ _heartbeats_startup, _heartbeats = 0, 0
1210
  reset_turn_content()
1211
  print(f" {c.green}[*] History cleared. Models and session stay active.{c.res}")
1212
  print_banner(_tree, _session_id)
 
1225
  # ── Brain pipeline ────────────────────────────────────────────────────
1226
  _timings = Mindlink(_models, _tree)
1227
  _timings["mind"] = Lambda(_models, _tree)
1228
+
1229
  # ── Startup memory capsules to load ───────────────────────────────────
1230
  if config.N_MEMORY_CAPSULES_TO_LOAD and _startup_memory_capsules_loaded <= config.N_MEMORY_CAPSULES_TO_LOAD:
1231
+ print(f" {c.inv} ── _startup_memory_capsules_loaded: {_startup_memory_capsules_loaded} of {config.N_MEMORY_CAPSULES_TO_LOAD} ──────────────────────────── {c.res}")
1232
  _tree = "S" # Set to memorize as memory capsules in garden["C"]
 
1233
  if _startup_memory_capsules_loaded == config.N_MEMORY_CAPSULES_TO_LOAD:
1234
  _startup_memory_capsules_loaded += 1 # Advance to finish the startup sequence
1235
+
1236
+ memotron(_models, _tree, _session_id, _timings) # Store the response
1237
+ # Reset turn-based data and preset terminal for next cycle
1238
+ _heartbeats_startup, _heartbeats = 0, 0
1239
+ reset_turn_content() # Reset Z-factor data only
1240
+ print(f"\n{c.inv} You: {c.res} ", end="", flush=True)
1241
+
1242
  # ── Condensatron evaluation ───────────────────────────────────────────
1243
  for c_tree in ["Z", "C", "F"]:
1244
  if garden["n_tok_tot"][c_tree] >= garden["THRESHOLD"][c_tree]: # Check garden context budget
1245
  print(f" {c.inv} ── Init condensatron get posts: garden['{c_tree}'] ──────────────────────────── {c.res}")
1246
  condensatron(_models["mind"], c_tree, "mind") # Start condensatron get popped posts
1247
 
 
 
 
 
1248
 
1249
  if __name__ == "__main__":
1250
  main()