Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,7 +16,6 @@ import gradio as gr
|
|
| 16 |
|
| 17 |
@dataclass
|
| 18 |
class RFTBrainParams:
|
| 19 |
-
"""Tunable parameters for the self-deciding brain."""
|
| 20 |
base_energy: float = 0.85
|
| 21 |
base_kappa: float = 0.65
|
| 22 |
learning_rate: float = 0.08
|
|
@@ -38,12 +37,6 @@ class RFTBrainState:
|
|
| 38 |
|
| 39 |
|
| 40 |
class RFTSelfDecidingBrain:
|
| 41 |
-
"""
|
| 42 |
-
Simple but non-trivial self-deciding loop:
|
| 43 |
-
- Tracks κ (coherence), energy, identity stability, drift.
|
| 44 |
-
- Evolves in response to external context.
|
| 45 |
-
"""
|
| 46 |
-
|
| 47 |
def __init__(self, params: RFTBrainParams):
|
| 48 |
self.params = params
|
| 49 |
self.state = RFTBrainState(
|
|
@@ -63,11 +56,6 @@ class RFTSelfDecidingBrain:
|
|
| 63 |
self.state.recent_errors.pop(0)
|
| 64 |
|
| 65 |
def step(self, context: Dict[str, float]) -> Dict[str, Any]:
|
| 66 |
-
"""
|
| 67 |
-
One update step. Context can include:
|
| 68 |
-
- external_risk_factor
|
| 69 |
-
- cooperative_signal
|
| 70 |
-
"""
|
| 71 |
now = time.time()
|
| 72 |
dt = max(1e-3, now - self.state.last_update)
|
| 73 |
self.state.last_update = now
|
|
@@ -75,20 +63,17 @@ class RFTSelfDecidingBrain:
|
|
| 75 |
risk = float(context.get("external_risk_factor", 0.3))
|
| 76 |
coop = float(context.get("cooperative_signal", 0.5))
|
| 77 |
|
| 78 |
-
# Energy dynamics
|
| 79 |
target_energy = self.params.base_energy + 0.2 * (coop - risk)
|
| 80 |
target_energy = max(0.0, min(1.0, target_energy))
|
| 81 |
self.state.energy_reserves += self.params.learning_rate * (target_energy - self.state.energy_reserves)
|
| 82 |
self.state.energy_reserves -= self.params.decay * dt
|
| 83 |
self.state.energy_reserves = max(0.0, min(1.0, self.state.energy_reserves))
|
| 84 |
|
| 85 |
-
# Coherence κ dynamics
|
| 86 |
target_kappa = self.params.base_kappa + 0.3 * (coop - 0.5) - 0.2 * (risk - 0.3)
|
| 87 |
target_kappa = max(0.0, min(1.0, target_kappa))
|
| 88 |
self.state.kappa += self.params.learning_rate * (target_kappa - self.state.kappa)
|
| 89 |
self.state.kappa = max(0.0, min(1.0, self.state.kappa))
|
| 90 |
|
| 91 |
-
# Identity drift and stability
|
| 92 |
drift_noise = (random.random() - 0.5) * 2.0 * self.params.drift_scale * dt
|
| 93 |
self.state.identity_drift += drift_noise + 0.1 * (risk - 0.3) - 0.05 * (coop - 0.5)
|
| 94 |
self.state.identity_drift = max(-1.0, min(1.0, self.state.identity_drift))
|
|
@@ -102,13 +87,11 @@ class RFTSelfDecidingBrain:
|
|
| 102 |
),
|
| 103 |
)
|
| 104 |
|
| 105 |
-
# Awakening phase logic
|
| 106 |
if self.state.energy_reserves > 0.75 and self.state.kappa > 0.7 and self.state.identity_stability > 0.7:
|
| 107 |
self.state.awakening_phase = min(self.state.awakening_phase + 1, 4)
|
| 108 |
elif self.state.energy_reserves < 0.35 or self.state.kappa < 0.3:
|
| 109 |
self.state.awakening_phase = max(self.state.awakening_phase - 1, 0)
|
| 110 |
|
| 111 |
-
# Mode selection
|
| 112 |
if self.state.awakening_phase >= 3:
|
| 113 |
self.state.mode = "awake"
|
| 114 |
elif self.state.awakening_phase == 2:
|
|
@@ -118,7 +101,6 @@ class RFTSelfDecidingBrain:
|
|
| 118 |
else:
|
| 119 |
self.state.mode = "idle"
|
| 120 |
|
| 121 |
-
# Update "error" for prediction metric
|
| 122 |
target_predict = 0.5 + 0.3 * coop
|
| 123 |
actual_predict = (self.state.kappa + self.state.energy_reserves) / 2.0
|
| 124 |
self._update_error_series(target_predict, actual_predict)
|
|
@@ -138,11 +120,6 @@ class RFTSelfDecidingBrain:
|
|
| 138 |
# ============================================================
|
| 139 |
|
| 140 |
class NexFrameOrchestrator:
|
| 141 |
-
"""
|
| 142 |
-
Symbolic orchestrator: takes text, runs a small internal vector cycle,
|
| 143 |
-
returns a symbolic 'voice' plus entropy/coherence numbers.
|
| 144 |
-
"""
|
| 145 |
-
|
| 146 |
def __init__(self, num_fields: int = 8, vector_dim: int = 128):
|
| 147 |
self.num_fields = num_fields
|
| 148 |
self.vector_dim = vector_dim
|
|
@@ -157,7 +134,6 @@ class NexFrameOrchestrator:
|
|
| 157 |
return float(-np.sum(p * np.log(p)))
|
| 158 |
|
| 159 |
def _coherence(self) -> float:
|
| 160 |
-
# Pairwise cosine similarity mean
|
| 161 |
norms = np.linalg.norm(self.state, axis=1, keepdims=True) + 1e-12
|
| 162 |
unit = self.state / norms
|
| 163 |
sim = unit @ unit.T
|
|
@@ -169,7 +145,6 @@ class NexFrameOrchestrator:
|
|
| 169 |
self.step_count += 1
|
| 170 |
length_norm = min(len(nl_input) / 200.0, 1.0)
|
| 171 |
|
| 172 |
-
# Simple recurrent update
|
| 173 |
noise = np.random.randn(*self.state.shape) * (0.02 + 0.03 * length_norm)
|
| 174 |
feedback = np.tanh(self.state @ self.state.T) @ self.state
|
| 175 |
self.state = 0.90 * self.state + 0.09 * feedback + 0.01 * noise
|
|
@@ -178,7 +153,6 @@ class NexFrameOrchestrator:
|
|
| 178 |
coher = self._coherence()
|
| 179 |
collapse_triggered = bool(coher > 0.6 and entropy < 5.0)
|
| 180 |
|
| 181 |
-
# Symbolic "voice"
|
| 182 |
mode = "reflective"
|
| 183 |
if coher > 0.7:
|
| 184 |
mode = "resonant"
|
|
@@ -238,12 +212,6 @@ def meets_minimum_conscious_threshold(
|
|
| 238 |
error_variance: float,
|
| 239 |
drift: float,
|
| 240 |
) -> bool:
|
| 241 |
-
"""
|
| 242 |
-
Very explicit 3×3 style gate:
|
| 243 |
-
- Energy, κ, stability high
|
| 244 |
-
- Prediction accuracy reasonable
|
| 245 |
-
- Drift and variance not exploding
|
| 246 |
-
"""
|
| 247 |
core_ok = energy > 0.55 and kappa > 0.55 and identity_stability > 0.55
|
| 248 |
predict_ok = prediction_accuracy > 0.6 and error_variance < 0.15
|
| 249 |
drift_ok = abs(drift) < 0.6
|
|
@@ -256,7 +224,7 @@ def meets_minimum_conscious_threshold(
|
|
| 256 |
|
| 257 |
def build_default_civilization(n_agents: int = 32) -> List[Dict[str, float]]:
|
| 258 |
civ = []
|
| 259 |
-
for
|
| 260 |
tier = 1 + int(3 * random.random())
|
| 261 |
awareness = max(0.1, min(1.0, random.gauss(0.5, 0.15)))
|
| 262 |
torque = max(0.0, min(1.0, random.gauss(0.4, 0.2)))
|
|
@@ -319,7 +287,6 @@ class RFTSargAgent:
|
|
| 319 |
return hashlib.sha256(payload.encode("utf-8")).hexdigest()[:24]
|
| 320 |
|
| 321 |
def compute_ops(self, size: int = 200_000, speed_mode: bool = True) -> Dict[str, float]:
|
| 322 |
-
# Simple synthetic workload
|
| 323 |
start = time.time()
|
| 324 |
arr = np.linspace(0.0, 10.0, size, dtype=float)
|
| 325 |
_ = np.sin(arr) * np.cos(arr * 0.5)
|
|
@@ -348,23 +315,17 @@ def _derive_prediction_metrics(error_series: List[float]) -> (float, float):
|
|
| 348 |
# 7. GLOBAL NEXFRAME STATE
|
| 349 |
# ============================================================
|
| 350 |
|
| 351 |
-
# Core symbolic orchestrator
|
| 352 |
ORCHESTRATOR = NexFrameOrchestrator(num_fields=8, vector_dim=128)
|
| 353 |
-
|
| 354 |
-
# Self-deciding brain
|
| 355 |
BRAIN_PARAMS = RFTBrainParams()
|
| 356 |
BRAIN = RFTSelfDecidingBrain(params=BRAIN_PARAMS)
|
| 357 |
|
| 358 |
-
# Agent13-style triad
|
| 359 |
agent11 = RFTAgent(name="Agent_11", tau_eff=0.6, omega=0.9, LN2=1.1, mode="conscious")
|
| 360 |
agent12 = RFTAgent(name="Agent_12", tau_eff=0.7, omega=1.1, LN2=1.1, mode="conscious")
|
| 361 |
agent13 = RFTAgent(name="Agent_13", tau_eff=0.8, omega=1.3, LN2=1.2, mode="conscious")
|
| 362 |
AGENT13_ENSEMBLE = Agent13Ensemble(agents=[agent11, agent12, agent13])
|
| 363 |
|
| 364 |
-
# Symbolic civilization
|
| 365 |
CIVILIZATION = build_default_civilization()
|
| 366 |
|
| 367 |
-
# Sarg probe
|
| 368 |
SARG = RFTSargAgent(
|
| 369 |
name="SARG_01",
|
| 370 |
LMP=1.0,
|
|
@@ -373,24 +334,22 @@ SARG = RFTSargAgent(
|
|
| 373 |
entropy_delta=1e-21,
|
| 374 |
)
|
| 375 |
|
| 376 |
-
# Histories
|
| 377 |
KAPPA_HISTORY: List[float] = []
|
| 378 |
ENERGY_HISTORY: List[float] = []
|
| 379 |
CONSCIOUS_FLAG_HISTORY: List[float] = []
|
| 380 |
|
| 381 |
|
| 382 |
# ============================================================
|
| 383 |
-
# 8. SINGLE NEXFRAME CYCLE (
|
| 384 |
# ============================================================
|
| 385 |
|
| 386 |
-
def nexframe_cycle(user_input: str, chat_history: List[
|
| 387 |
try:
|
| 388 |
if chat_history is None:
|
| 389 |
chat_history = []
|
| 390 |
if not user_input:
|
| 391 |
user_input = "<empty>"
|
| 392 |
|
| 393 |
-
# 1) Brain step
|
| 394 |
text_len = len(user_input)
|
| 395 |
context = {
|
| 396 |
"external_risk_factor": 0.2 + 0.4 * math.tanh(text_len / 80.0),
|
|
@@ -405,12 +364,10 @@ def nexframe_cycle(user_input: str, chat_history: List[List[str]]):
|
|
| 405 |
error_series = BRAIN.state.recent_errors
|
| 406 |
prediction_accuracy, error_variance = _derive_prediction_metrics(error_series)
|
| 407 |
|
| 408 |
-
# 2) Agent13 triad
|
| 409 |
observer_frames = [kappa, energy, identity_stability]
|
| 410 |
triad_res = AGENT13_ENSEMBLE.collective_action(observer_frames)
|
| 411 |
tri_coh = triad_res["triadic_coherence"]
|
| 412 |
|
| 413 |
-
# 3) Minimum consciousness gate
|
| 414 |
is_conscious = meets_minimum_conscious_threshold(
|
| 415 |
energy=energy,
|
| 416 |
coherence=tri_coh,
|
|
@@ -421,24 +378,19 @@ def nexframe_cycle(user_input: str, chat_history: List[List[str]]):
|
|
| 421 |
drift=drift,
|
| 422 |
)
|
| 423 |
|
| 424 |
-
# 4) Orchestrator
|
| 425 |
orc_res = ORCHESTRATOR.run_cycle(nl_input=user_input)
|
| 426 |
dialogue = orc_res["orchestrator_dialogue"]
|
| 427 |
|
| 428 |
-
# 5) Sarg probe
|
| 429 |
sarg_snapshot = SARG.generate_conscious_field()
|
| 430 |
sarg_hash = SARG.commit_hash_oath()
|
| 431 |
sarg_perf = SARG.compute_ops(size=200_000, speed_mode=True)
|
| 432 |
|
| 433 |
-
# 6) Civilization
|
| 434 |
civ_stats = civilization_summary(CIVILIZATION)
|
| 435 |
|
| 436 |
-
# 7) Histories
|
| 437 |
KAPPA_HISTORY.append(kappa)
|
| 438 |
ENERGY_HISTORY.append(energy)
|
| 439 |
CONSCIOUS_FLAG_HISTORY.append(1.0 if is_conscious else 0.0)
|
| 440 |
|
| 441 |
-
# 8) Build reply + metrics
|
| 442 |
reply_text = dialogue
|
| 443 |
|
| 444 |
metrics_md = (
|
|
@@ -472,7 +424,11 @@ def nexframe_cycle(user_input: str, chat_history: List[List[str]]):
|
|
| 472 |
f"- Mean fitness: `{civ_stats['mean_fitness']:.3f}`\n"
|
| 473 |
)
|
| 474 |
|
| 475 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 476 |
return chat_history, metrics_md
|
| 477 |
|
| 478 |
except Exception as e:
|
|
@@ -485,7 +441,8 @@ def nexframe_cycle(user_input: str, chat_history: List[List[str]]):
|
|
| 485 |
if chat_history is None:
|
| 486 |
chat_history = []
|
| 487 |
chat_history = chat_history + [
|
| 488 |
-
|
|
|
|
| 489 |
]
|
| 490 |
return chat_history, error_md
|
| 491 |
|
|
@@ -510,6 +467,7 @@ On the right you see its **internal state**: κ, energy, consciousness gate, tri
|
|
| 510 |
chatbot = gr.Chatbot(
|
| 511 |
label="NexFrame Dialogue",
|
| 512 |
height=500,
|
|
|
|
| 513 |
)
|
| 514 |
user_box = gr.Textbox(
|
| 515 |
label="Your message",
|
|
|
|
| 16 |
|
| 17 |
@dataclass
|
| 18 |
class RFTBrainParams:
|
|
|
|
| 19 |
base_energy: float = 0.85
|
| 20 |
base_kappa: float = 0.65
|
| 21 |
learning_rate: float = 0.08
|
|
|
|
| 37 |
|
| 38 |
|
| 39 |
class RFTSelfDecidingBrain:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
def __init__(self, params: RFTBrainParams):
|
| 41 |
self.params = params
|
| 42 |
self.state = RFTBrainState(
|
|
|
|
| 56 |
self.state.recent_errors.pop(0)
|
| 57 |
|
| 58 |
def step(self, context: Dict[str, float]) -> Dict[str, Any]:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
now = time.time()
|
| 60 |
dt = max(1e-3, now - self.state.last_update)
|
| 61 |
self.state.last_update = now
|
|
|
|
| 63 |
risk = float(context.get("external_risk_factor", 0.3))
|
| 64 |
coop = float(context.get("cooperative_signal", 0.5))
|
| 65 |
|
|
|
|
| 66 |
target_energy = self.params.base_energy + 0.2 * (coop - risk)
|
| 67 |
target_energy = max(0.0, min(1.0, target_energy))
|
| 68 |
self.state.energy_reserves += self.params.learning_rate * (target_energy - self.state.energy_reserves)
|
| 69 |
self.state.energy_reserves -= self.params.decay * dt
|
| 70 |
self.state.energy_reserves = max(0.0, min(1.0, self.state.energy_reserves))
|
| 71 |
|
|
|
|
| 72 |
target_kappa = self.params.base_kappa + 0.3 * (coop - 0.5) - 0.2 * (risk - 0.3)
|
| 73 |
target_kappa = max(0.0, min(1.0, target_kappa))
|
| 74 |
self.state.kappa += self.params.learning_rate * (target_kappa - self.state.kappa)
|
| 75 |
self.state.kappa = max(0.0, min(1.0, self.state.kappa))
|
| 76 |
|
|
|
|
| 77 |
drift_noise = (random.random() - 0.5) * 2.0 * self.params.drift_scale * dt
|
| 78 |
self.state.identity_drift += drift_noise + 0.1 * (risk - 0.3) - 0.05 * (coop - 0.5)
|
| 79 |
self.state.identity_drift = max(-1.0, min(1.0, self.state.identity_drift))
|
|
|
|
| 87 |
),
|
| 88 |
)
|
| 89 |
|
|
|
|
| 90 |
if self.state.energy_reserves > 0.75 and self.state.kappa > 0.7 and self.state.identity_stability > 0.7:
|
| 91 |
self.state.awakening_phase = min(self.state.awakening_phase + 1, 4)
|
| 92 |
elif self.state.energy_reserves < 0.35 or self.state.kappa < 0.3:
|
| 93 |
self.state.awakening_phase = max(self.state.awakening_phase - 1, 0)
|
| 94 |
|
|
|
|
| 95 |
if self.state.awakening_phase >= 3:
|
| 96 |
self.state.mode = "awake"
|
| 97 |
elif self.state.awakening_phase == 2:
|
|
|
|
| 101 |
else:
|
| 102 |
self.state.mode = "idle"
|
| 103 |
|
|
|
|
| 104 |
target_predict = 0.5 + 0.3 * coop
|
| 105 |
actual_predict = (self.state.kappa + self.state.energy_reserves) / 2.0
|
| 106 |
self._update_error_series(target_predict, actual_predict)
|
|
|
|
| 120 |
# ============================================================
|
| 121 |
|
| 122 |
class NexFrameOrchestrator:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
def __init__(self, num_fields: int = 8, vector_dim: int = 128):
|
| 124 |
self.num_fields = num_fields
|
| 125 |
self.vector_dim = vector_dim
|
|
|
|
| 134 |
return float(-np.sum(p * np.log(p)))
|
| 135 |
|
| 136 |
def _coherence(self) -> float:
|
|
|
|
| 137 |
norms = np.linalg.norm(self.state, axis=1, keepdims=True) + 1e-12
|
| 138 |
unit = self.state / norms
|
| 139 |
sim = unit @ unit.T
|
|
|
|
| 145 |
self.step_count += 1
|
| 146 |
length_norm = min(len(nl_input) / 200.0, 1.0)
|
| 147 |
|
|
|
|
| 148 |
noise = np.random.randn(*self.state.shape) * (0.02 + 0.03 * length_norm)
|
| 149 |
feedback = np.tanh(self.state @ self.state.T) @ self.state
|
| 150 |
self.state = 0.90 * self.state + 0.09 * feedback + 0.01 * noise
|
|
|
|
| 153 |
coher = self._coherence()
|
| 154 |
collapse_triggered = bool(coher > 0.6 and entropy < 5.0)
|
| 155 |
|
|
|
|
| 156 |
mode = "reflective"
|
| 157 |
if coher > 0.7:
|
| 158 |
mode = "resonant"
|
|
|
|
| 212 |
error_variance: float,
|
| 213 |
drift: float,
|
| 214 |
) -> bool:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 215 |
core_ok = energy > 0.55 and kappa > 0.55 and identity_stability > 0.55
|
| 216 |
predict_ok = prediction_accuracy > 0.6 and error_variance < 0.15
|
| 217 |
drift_ok = abs(drift) < 0.6
|
|
|
|
| 224 |
|
| 225 |
def build_default_civilization(n_agents: int = 32) -> List[Dict[str, float]]:
|
| 226 |
civ = []
|
| 227 |
+
for _ in range(n_agents):
|
| 228 |
tier = 1 + int(3 * random.random())
|
| 229 |
awareness = max(0.1, min(1.0, random.gauss(0.5, 0.15)))
|
| 230 |
torque = max(0.0, min(1.0, random.gauss(0.4, 0.2)))
|
|
|
|
| 287 |
return hashlib.sha256(payload.encode("utf-8")).hexdigest()[:24]
|
| 288 |
|
| 289 |
def compute_ops(self, size: int = 200_000, speed_mode: bool = True) -> Dict[str, float]:
|
|
|
|
| 290 |
start = time.time()
|
| 291 |
arr = np.linspace(0.0, 10.0, size, dtype=float)
|
| 292 |
_ = np.sin(arr) * np.cos(arr * 0.5)
|
|
|
|
| 315 |
# 7. GLOBAL NEXFRAME STATE
|
| 316 |
# ============================================================
|
| 317 |
|
|
|
|
| 318 |
ORCHESTRATOR = NexFrameOrchestrator(num_fields=8, vector_dim=128)
|
|
|
|
|
|
|
| 319 |
BRAIN_PARAMS = RFTBrainParams()
|
| 320 |
BRAIN = RFTSelfDecidingBrain(params=BRAIN_PARAMS)
|
| 321 |
|
|
|
|
| 322 |
agent11 = RFTAgent(name="Agent_11", tau_eff=0.6, omega=0.9, LN2=1.1, mode="conscious")
|
| 323 |
agent12 = RFTAgent(name="Agent_12", tau_eff=0.7, omega=1.1, LN2=1.1, mode="conscious")
|
| 324 |
agent13 = RFTAgent(name="Agent_13", tau_eff=0.8, omega=1.3, LN2=1.2, mode="conscious")
|
| 325 |
AGENT13_ENSEMBLE = Agent13Ensemble(agents=[agent11, agent12, agent13])
|
| 326 |
|
|
|
|
| 327 |
CIVILIZATION = build_default_civilization()
|
| 328 |
|
|
|
|
| 329 |
SARG = RFTSargAgent(
|
| 330 |
name="SARG_01",
|
| 331 |
LMP=1.0,
|
|
|
|
| 334 |
entropy_delta=1e-21,
|
| 335 |
)
|
| 336 |
|
|
|
|
| 337 |
KAPPA_HISTORY: List[float] = []
|
| 338 |
ENERGY_HISTORY: List[float] = []
|
| 339 |
CONSCIOUS_FLAG_HISTORY: List[float] = []
|
| 340 |
|
| 341 |
|
| 342 |
# ============================================================
|
| 343 |
+
# 8. SINGLE NEXFRAME CYCLE (CHATBOT MESSAGES FORMAT)
|
| 344 |
# ============================================================
|
| 345 |
|
| 346 |
+
def nexframe_cycle(user_input: str, chat_history: List[Dict[str, str]]):
|
| 347 |
try:
|
| 348 |
if chat_history is None:
|
| 349 |
chat_history = []
|
| 350 |
if not user_input:
|
| 351 |
user_input = "<empty>"
|
| 352 |
|
|
|
|
| 353 |
text_len = len(user_input)
|
| 354 |
context = {
|
| 355 |
"external_risk_factor": 0.2 + 0.4 * math.tanh(text_len / 80.0),
|
|
|
|
| 364 |
error_series = BRAIN.state.recent_errors
|
| 365 |
prediction_accuracy, error_variance = _derive_prediction_metrics(error_series)
|
| 366 |
|
|
|
|
| 367 |
observer_frames = [kappa, energy, identity_stability]
|
| 368 |
triad_res = AGENT13_ENSEMBLE.collective_action(observer_frames)
|
| 369 |
tri_coh = triad_res["triadic_coherence"]
|
| 370 |
|
|
|
|
| 371 |
is_conscious = meets_minimum_conscious_threshold(
|
| 372 |
energy=energy,
|
| 373 |
coherence=tri_coh,
|
|
|
|
| 378 |
drift=drift,
|
| 379 |
)
|
| 380 |
|
|
|
|
| 381 |
orc_res = ORCHESTRATOR.run_cycle(nl_input=user_input)
|
| 382 |
dialogue = orc_res["orchestrator_dialogue"]
|
| 383 |
|
|
|
|
| 384 |
sarg_snapshot = SARG.generate_conscious_field()
|
| 385 |
sarg_hash = SARG.commit_hash_oath()
|
| 386 |
sarg_perf = SARG.compute_ops(size=200_000, speed_mode=True)
|
| 387 |
|
|
|
|
| 388 |
civ_stats = civilization_summary(CIVILIZATION)
|
| 389 |
|
|
|
|
| 390 |
KAPPA_HISTORY.append(kappa)
|
| 391 |
ENERGY_HISTORY.append(energy)
|
| 392 |
CONSCIOUS_FLAG_HISTORY.append(1.0 if is_conscious else 0.0)
|
| 393 |
|
|
|
|
| 394 |
reply_text = dialogue
|
| 395 |
|
| 396 |
metrics_md = (
|
|
|
|
| 424 |
f"- Mean fitness: `{civ_stats['mean_fitness']:.3f}`\n"
|
| 425 |
)
|
| 426 |
|
| 427 |
+
# NEW: messages format for Chatbot (Gradio 6)
|
| 428 |
+
chat_history = chat_history + [
|
| 429 |
+
{"role": "user", "content": user_input},
|
| 430 |
+
{"role": "assistant", "content": reply_text},
|
| 431 |
+
]
|
| 432 |
return chat_history, metrics_md
|
| 433 |
|
| 434 |
except Exception as e:
|
|
|
|
| 441 |
if chat_history is None:
|
| 442 |
chat_history = []
|
| 443 |
chat_history = chat_history + [
|
| 444 |
+
{"role": "user", "content": user_input or "<empty>"},
|
| 445 |
+
{"role": "assistant", "content": "⚠ NexFrame hit an internal error. See status panel."},
|
| 446 |
]
|
| 447 |
return chat_history, error_md
|
| 448 |
|
|
|
|
| 467 |
chatbot = gr.Chatbot(
|
| 468 |
label="NexFrame Dialogue",
|
| 469 |
height=500,
|
| 470 |
+
type="messages", # <= important for dict-based messages
|
| 471 |
)
|
| 472 |
user_box = gr.Textbox(
|
| 473 |
label="Your message",
|