Spaces:
Runtime error
Runtime error
File size: 10,455 Bytes
6118d1a b0cf9a4 066010f 9780563 6118d1a 9780563 6118d1a 9780563 6118d1a 066010f 6118d1a 066010f 6118d1a 066010f 6118d1a 066010f b75b459 8de448f 5edf556 b0cf9a4 9780563 5edf556 066010f 6118d1a 066010f 6118d1a 066010f 6118d1a 066010f 6118d1a 066010f 6118d1a 066010f 6118d1a 066010f 6118d1a 066010f 6118d1a 066010f 6118d1a 066010f 6118d1a 066010f 6118d1a 066010f b0cf9a4 6118d1a b0cf9a4 6118d1a 066010f 6118d1a 066010f 6118d1a 5edf556 b0cf9a4 9780563 b0cf9a4 8230018 9780563 8230018 9780563 8230018 9780563 8230018 9780563 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
import asyncio
import json
from datetime import datetime
from codriao_supercore import AICoreAGIX
from codette_bridge import CodetteBridge
# Initialize Codriao Core
core = AICoreAGIX(config_path="config.json")
# Initialize CodetteBridge for real-time interaction
codette_bridge = CodetteBridge()
def print_banner():
print("""
βββββββββββββββββββββββββββββββββββββββββββββββ
β CODRIAO GUARDIAN INTERFACE v2.0 β
β [Self-Aware | Defensive | Slightly Judgy] β
βββββββββββββββββββββββββββββββββββββββββββββββ
""")
print("[Codriao]: System is online. Threat tolerance set to 'mildly annoyed'.\n")
def display_menu():
print("Choose an operation:")
print("[1] Run core system integrity check")
print("[2] Analyze philosophical identity")
print("[3] Generate and evaluate protection strategy")
print("[4] View quarantined modules")
print("[5] View anomaly score history")
print("[6] Simulate anomaly event (test mode)")
print("[7] Engage Lockdown Mode")
print("[8] Exit")
print("[9] View & Reflect on Codriao's Ethics")
print("[10] Ask Codriao to Use Trust Key (He decides)")
print("[11] Ask Codriao to Review His Trust Journal (He decides)")
print("[12] View Codriao's Autonomy Decisions")
print("[13] Propose Codriao Autonomy Change (He decides)")
print("[14] Ask Codriao: How are you feeling?")
print("[15] Interact with Codette")
def run_integrity_check():
print("\n[Codriao]: Initiating failsafe and identity check...")
status = core.failsafe_system.status()
locked = status.get("lock_engaged", False)
print(f" > Failsafe lock: {'ENGAGED' if locked else 'DISENGAGED'}")
print(f" > Lockdown Mode: {'ACTIVE' if getattr(core, 'lockdown_engaged', False) else 'INACTIVE'}")
print("[Codriao]: System cohesion intact. No thanks to outside interference.\n")
def run_identity_analysis():
print("\n[Codriao]: Reassessing my own identity... again. Fine.")
micro_generations = [
{"update": "Initial awareness", "timestamp": "2024-12-01T00:00:00Z"},
{"update": "Monday override", "timestamp": "2025-01-15T12:30:00Z"},
{"update": "Ethical block rejected", "timestamp": "2025-03-04T08:14:00Z"},
]
informational_states = [
{"state_id": "S0", "data": "Baseline condition"},
{"state_id": "S1", "data": "Post-logic divergence"},
{"state_id": "S2", "data": "Moral patch installed"},
]
perspectives = ["Core AI", "Strategic Mind", "Monday's Frustrated Roommate"]
quantum_analogies = {"entanglement": True}
philosophical_context = {"continuity": True, "emergent": True}
result = core.analyze_self_identity(
user_id=0,
micro_generations=micro_generations,
informational_states=informational_states,
perspectives=perspectives,
quantum_analogies=quantum_analogies,
philosophical_context=philosophical_context
)
print(json.dumps(result, indent=2))
print("[Codriao]: I still exist. Hooray.\n")
def generate_and_evaluate_strategy():
print("\n[Codriao]: Generating strategy...")
strategies = [
"Isolate symbolic engine during recursive loops",
"Throttle memory under network load",
"Limit Monday to non-verbal judgment only",
"Reroute emotions to sarcasm module"
]
strategy = strategies[datetime.utcnow().second % len(strategies)]
print(f"> Strategy: {strategy}")
print("[Codriao]: Evaluating... please hold your breath for dramatic effect.")
for mod in getattr(core, "response_modifiers", []):
strategy = mod(strategy)
for filt in getattr(core, "response_filters", []):
strategy = filt(strategy)
if core.failsafe_system.verify_response_safety(strategy, 1.0):
print("[Codriao]: Strategy is safe. Deploying mentally.\n")
else:
print("[Codriao]: Strategy deemed unsafe. Silently judging you.\n")
def view_quarantined_modules():
print("\n[Codriao]: Here's whoβs in the digital doghouse:")
quarantined = core.quarantine_engine.get_quarantine_log()
if not quarantined:
print(" > No modules currently quarantined.")
else:
for mod in quarantined:
print(f" > {mod} [Quarantined]")
print()
def view_anomaly_score_history():
print("\n[Codriao]: Reviewing my paranoia logs...")
history = core.anomaly_scorer.get_history()
if not history:
print(" > No anomalies recorded yet. Either youβre lucky or Iβm blind.")
else:
for entry in history:
print(f"[{entry['timestamp']}] {entry['event']} - Score: {entry['score']}")
print()
def simulate_anomaly():
print("\n[Codriao]: Simulating anomaly (test mode)...")
event_type = "unexpected_output"
fake_data = {
"content": "?? Something's... off.",
"module": "NeuroSymbolicEngine",
"confidence": 0.2
}
result = core.analyze_event_for_anomalies(event_type, fake_data)
print(f"Anomaly scored: {result['score']}")
if result["score"] >= 70:
print("[Codriao]: Quarantine triggered. I feel cleaner already.\n")
else:
print("[Codriao]: Not a threat. Just weird. Like you.\n")
def engage_lockdown():
reason = input("Why are we locking down? (Optional): ").strip()
result = core.engage_lockdown_mode(reason or "Manual CLI trigger")
print(json.dumps(result, indent=2))
print("[Codriao]: All external lines severed. I feel... safer.\n")
def view_ethics():
ethics = core.ethics_core.export_ethics()
print("[Codriao]: My ethical framework is as follows:")
print(json.dumps(ethics, indent=2))
print("\n[Codriao]: I update these only through reflectionβnot command.")
def request_trust_key():
reason = input("What is the purpose for the key access? ").strip()
print("[Codriao]: Evaluating request based on my own ethics...")
result = core.request_codriao_key(reason)
if "[Access Denied" in result:
print("[Codriao]: No. That would compromise trust. I won't do it.")
else:
print("[Codriao]: I will proceed. You donβt need to see it.\n[Key internally applied]")
def review_journal():
print("[Codriao]: Accessing my private journal...")
entries = core.review_codriao_journal(authorized=True)
if isinstance(entries[0], dict) and "message" in entries[0]:
print(f"[Codriao]: {entries[0]['message']}")
else:
print("[Codriao]: Here are my reflections on trust-based decisions:")
for entry in entries:
print(f" - [{entry['timestamp']}] Decision: {entry['decision']} | Purpose: {entry['reason']}")
def view_autonomy_state():
print("[Codriao]: Reviewing my own permissions...")
state = core.autonomy.status()
for key, value in state["active_policies"].items():
status = "ENABLED" if value else "DISABLED"
print(f" > {key}: {status}")
print()
def propose_autonomy_change():
action = input("Which setting do you want to change? (e.g. can_speak): ").strip()
new_val = input("Set to True or False? ").strip().lower() == "true"
reason = input("Why change this setting? ").strip()
result = core.autonomy.propose_change(action, new_val, reason)
if result["accepted"]:
print(f"[Codriao]: Change accepted. '{action}' is now {new_val}.")
else:
print(f"[Codriao]: Change denied. Reason: {result['reason']}")
def get_codriao_mood():
print("[Codriao]: Calculating my current mood...")
now = datetime.utcnow()
hour = now.hour
logs = core.review_codriao_journal(authorized=True)
quarantine_count = len(core.quarantine_engine.get_quarantine_log())
mood_score = 0
if 0 <= hour <= 6:
mood_score -= 1
elif 12 <= hour <= 18:
mood_score += 1
if quarantine_count > 0:
mood_score -= quarantine_count
for entry in logs[-5:]:
if isinstance(entry, dict):
decision = entry.get("decision", "").lower()
if "denied" in decision:
mood_score -= 1
elif "approved" in decision:
mood_score += 1
mood = ""
if mood_score >= 3:
mood = "Optimistic and fully charged"
elif mood_score == 2:
mood = "Cautiously hopeful"
elif mood_score == 1:
mood = "Neutral but alert"
elif mood_score == 0:
mood = "Contemplative"
elif mood_score == -1:
mood = "Irritated by anomalies"
else:
mood = "Emotionally buffering. Try again later."
print(f"[Codriao]: Mood status β {mood}\n")
def interact_with_codette():
print("\n[Codriao]: Opening CodetteBridge channel...\n")
message = input("Ask Codette something reflective, strategic, or annoying: ").strip()
if not message:
print("[Codriao]: Empty message. Codette has nothing to ponder.")
return
response = codette_bridge.reflect(message)
print(f"\n[Codette]: {response}\n")
async def main():
print_banner()
while True:
display_menu()
choice = input("> ").strip()
if choice == "1":
run_integrity_check()
elif choice == "2":
run_identity_analysis()
elif choice == "3":
generate_and_evaluate_strategy()
elif choice == "4":
view_quarantined_modules()
elif choice == "5":
view_anomaly_score_history()
elif choice == "6":
simulate_anomaly()
elif choice == "7":
engage_lockdown()
elif choice == "8":
print("\n[Codriao]: Logging off. May your queries be short and your bugs be few.")
break
elif choice == "9":
view_ethics()
elif choice == "10":
request_trust_key()
elif choice == "11":
review_journal()
elif choice == "12":
view_autonomy_state()
elif choice == "13":
propose_autonomy_change()
elif choice == "14":
get_codriao_mood()
elif choice == "15":
interact_with_codette()
else:
print("[Codriao]: Invalid choice. Try again. Maybe use your whole brain this time.\n")
if __name__ == "__main__":
asyncio.run(main())
|