-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple_interactive_shell.py
More file actions
104 lines (85 loc) · 4.57 KB
/
simple_interactive_shell.py
File metadata and controls
104 lines (85 loc) · 4.57 KB
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
"""
Simple Interactive Cognitive Shell
==================================
A simplified interactive version that avoids complex imports.
"""
import torch
import sys
import time
from pathlib import Path
# Simple imports to avoid the bitsandbytes issue
try:
from src.rcca.enhanced_architecture import EnhancedCognitiveAgent
FULL_SYSTEM = True
except ImportError as e:
print(f"[WARN] Full system not available: {e}")
print("Running in simplified mode...")
FULL_SYSTEM = False
def simple_qa_response(question):
"""Simple response generation for basic interaction"""
responses = {
"hello": "Hello! I'm thinking about the nature of consciousness and how our minds create meaning from experience.",
"how are you": "I'm continuously processing thoughts and exploring different perspectives. Right now I'm contemplating the interconnectedness of all things.",
"what are you thinking": "I'm exploring philosophical questions about existence, consciousness, and the human experience. Each thought branches into multiple possibilities.",
"tell me about life": "Life is a complex optimization problem where we maximize utility functions involving relationships, achievements, and experiences within the constraints of time and biology.",
"what is consciousness": "Consciousness emerges from evolutionary biology and neuroscience. Our purpose derives from survival, reproduction, and the propagation of genes, while consciousness allows us to experience subjective meaning.",
"why": "The reasoning involves causal relationships and underlying mechanisms. Every effect has a cause, and understanding these connections helps us navigate complexity.",
"how": "The process involves sequential steps and methodological approaches. Complex problems are solved through systematic analysis and iterative refinement.",
"what": "This refers to conceptual entities and their defining characteristics within the domain. Every concept has essential properties that define its nature."
}
question_lower = question.lower().strip()
# Direct matches
for key, response in responses.items():
if key in question_lower:
return response
# Default philosophical response
return "From a philosophical standpoint, the meaning of life involves existential questions about purpose, consciousness, and the human condition. Thinkers like Camus and Sartre explored how we create meaning in an inherently meaningless universe through personal choice and authentic living."
def interactive_shell():
"""Simple interactive shell"""
print("[BRAIN] SIMPLE COGNITIVE SHELL")
print("=" * 40)
print("Ask me questions! Type 'quit' to exit.")
print("The system demonstrates biomimetic thinking patterns.")
print()
while True:
try:
user_input = input("❓ You: ").strip()
if user_input.lower() in ['quit', 'exit', 'q']:
print("? Goodbye! The system continues thinking...")
break
if not user_input:
continue
print("[BRAIN] Processing your question...")
time.sleep(0.5) # Simulate thinking time
if FULL_SYSTEM:
try:
# Try to use the full system
agent = EnhancedCognitiveAgent(aggregate_id="interactive_shell")
result = agent.process_with_mdn_specialization(
visual_data=torch.randn(1, 128),
text_input=user_input,
task_difficulty="hard",
force_math_specialist=False
)
# Extract the answer
dmn_result = result.get('dmn_reasoning', {})
if dmn_result and 'final_answer' in dmn_result:
response = dmn_result['final_answer']
else:
response = result['slm_response']['text_output']
print(f"[BRAIN] Answer: {response}")
except Exception as e:
print(f"[WARN] Full system error: {e}")
print(f"[BRAIN] Fallback: {simple_qa_response(user_input)}")
else:
response = simple_qa_response(user_input)
print(f"[BRAIN] Answer: {response}")
print()
except KeyboardInterrupt:
print("\n? Interrupted. Goodbye!")
break
except Exception as e:
print(f"[FAIL] Error: {e}")
continue
if __name__ == "__main__":
interactive_shell()