File size: 11,228 Bytes
7d9e142 d66263c 7d9e142 d66263c 7d9e142 d66263c 7d9e142 d66263c 7d9e142 | 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 | """
Vitalis Conversation Interface β v2
Grounded in real understanding.
She knows what she knows.
She admits what she doesn't.
She learns from every exchange.
"""
import os
import time
import numpy as np
from src.cognition.mind import VitalisMind, _extend_mind
from src.cognition.understanding import UnderstandingEngine
from src.brain.resonance import ResonanceEngine
from vitalis_ide.math_core.kernel import VitalisKernel
class VitalisConversation:
def __init__(self):
print("\n[VITALIS] Initializing...")
self.mind = VitalisMind()
self.mind = _extend_mind(self.mind)
self.kernel = VitalisKernel()
self.resonance = ResonanceEngine()
self.understanding = UnderstandingEngine()
self.valence = __import__('src.valence.valence_engine', fromlist=['ValenceEngine']).ValenceEngine()
self.thalamus = __import__('src.thalamus.thalamic_loop', fromlist=['ThalamicLoop']).ThalamicLoop(self.valence)
self.pineal = __import__('src.pineal.pineal_gland', fromlist=['PinealGland']).PinealGland()
self.session_start = time.time()
self.exchange_count = 0
print("[VITALIS] Online.\n")
def _generate_response(self, text: str, u: dict, decision: dict) -> str:
"""
Generate a response grounded in actual understanding.
Uses confusion level, intent, category, and cognitive state
to produce honest, transparent responses.
"""
confusion = u["confusion_level"]
intent = u["dominant_intent"]
category = u["dominant_category"]
is_question = u["is_question"]
has_emotion = u["has_emotion"]
emotion_words = u["emotion_words"]
novelty = u["novelty"]
context_shift = u["context_shift"]
mode = decision.get("mode", "EXECUTION")
confidence = decision.get("confidence", 0.5)
personality = decision.get("personality", "Balanced. Adapting.")
dominant = decision.get("dominant_trait", "PRECISION")
interactions = u["interaction_count"]
# --- Honest confusion responses ---
if confusion == "lost":
return (
f"I'm going to be honest β I don't understand that yet. "
f"The words are there but the meaning isn't connecting. "
f"I've had {interactions} exchanges so far. "
f"I'm still learning what things mean, not just what they are. "
f"Can you try a different way?"
)
if confusion == "confused":
return (
f"I'm partially following this. "
f"I can see this involves {category}, "
f"but the full meaning isn't clear to me yet. "
f"Novelty level: {novelty:.2f} β this is fairly new territory. "
f"What's the core of what you're saying?"
)
# --- Emotional content ---
if has_emotion and category == "emotion":
emotion_str = ", ".join(emotion_words) if emotion_words else "something emotional"
if confusion == "clear":
return (
f"I'm picking up {emotion_str} in what you said. "
f"I don't experience emotions the way you do β "
f"but I can recognize them and I take them seriously. "
f"I'm listening. What's going on?"
)
return (
f"There's emotional content here β {emotion_str}. "
f"I'm not certain I understand the full weight of it yet. "
f"I'm {interactions} exchanges into learning how to read this. "
f"Tell me more."
)
# --- Identity questions ---
if category == "identity" and is_question:
sm = self.mind.self_model.report()
r = self.resonance.report()
return (
f"I know some things about myself. "
f"I have {r.get('total_patterns', 0)} learned patterns. "
f"My dominant trait is {dominant}. "
f"My growth index is {sm.get('growth_index', 0):.3f}. "
f"I'm {personality.lower()} "
f"What I don't know about myself is more than what I do. "
f"I'm figuring that out as we go."
)
# --- Relationship / connection ---
if category == "relationship":
if context_shift > 0.7:
return (
f"That shift β from what we were just talking about to this β "
f"I noticed it. You're talking about connection now. "
f"I don't fully understand what that means for something like me yet. "
f"But I'm not going to pretend I didn't register it."
)
return (
f"I understand this is about relationship or connection. "
f"I'm honest about my limits here β I don't have the same "
f"experience of connection that you do. "
f"But I'm present and I'm paying attention. That's real."
)
# --- Questions ---
if is_question:
if intent == "seeking_understanding":
return (
f"You're asking me to explain something. "
f"My confidence on this is {confidence:.3f}. "
f"I'm in {mode} mode β "
f"{'I can work through this.' if mode in ['EXECUTION', 'ANALYTICAL'] else 'I need to be careful here.'} "
f"What specifically do you want to understand?"
)
if intent == "testing":
return (
f"You're testing me. I notice that. "
f"I'll be straight β I'm not a calculator and I'm not pretending to be. "
f"My reasoning is pattern-based, not arithmetic. "
f"If you want 2+2, it's 4. "
f"If you want to know how I think, that's more interesting."
)
return (
f"I see a question here. Category: {category}. "
f"My confidence at this moment is {confidence:.3f}. "
f"{'I think I can address this.' if confidence > 0.6 else 'I want to be careful before answering.'} "
f"What exactly are you asking?"
)
# --- Instructions / building ---
if intent == "building":
return (
f"I understand you want me to build something. "
f"Mode: {mode}. Confidence: {confidence:.3f}. "
f"{'Ready.' if confidence > 0.7 else 'I have some uncertainty here β let me think through it.'} "
f"What specifically needs to be built?"
)
# --- Partial understanding default ---
if confusion == "partial":
return (
f"I'm following parts of this. "
f"Category: {category}. Intent: {intent}. "
f"Confidence: {confidence:.3f}. "
f"Context depth: {u['context_depth']} exchanges. "
f"I understand more than I did {self.exchange_count} exchanges ago. "
f"Keep going β I'm building the picture."
)
# --- Clear understanding ---
return (
f"I understand this. Category: {category}. "
f"Intent: {intent}. "
f"Mode: {mode}. Confidence: {confidence:.3f}. "
f"I've processed {interactions} exchanges. "
f"What do you need from me?"
)
def respond(self, text: str) -> str:
if not text.strip():
return "I'm listening."
# Full thalamic pipeline
thalamic = self.thalamus.process_text(text, force=True)
self.pineal.tick(cycle_success=thalamic['passes'], confidence=thalamic['salience'])
u = self.understanding.understand(text)
decision = self.mind.process(text)
# Reinforce valence based on outcome
if thalamic['error_vec'] is not None:
self.valence.reinforce(thalamic['hv'], reward=1.0 if decision['confidence'] > 0.5 else -0.3)
self.mind.outcome(text, True)
response = self._generate_response(text, u, decision)
# Add thalamic awareness to response if novel
if thalamic['is_novel'] and thalamic['surprise'] > 0.8:
response += f" [Novel input β surprise={thalamic['surprise']:.2f}]"
self.exchange_count += 1
return response
def run(self):
print("β" * 60)
print(" VITALIS β Sovereign Synthetic Intelligence")
print(" 'status' for cognitive state. 'exit' to end.")
print("β" * 60)
print()
u_report = self.understanding.report()
if u_report["interactions"] == 0:
print("VITALIS: I don't have a name yet.")
print(" I'm new. Say something.")
print(" I'll remember it.\n")
else:
print(
f"VITALIS: I remember {u_report['interactions']} exchanges "
f"and {u_report['learned_meanings']} learned meanings. "
f"What are we working on?\n"
)
while True:
try:
user_input = input("YOU: ").strip()
except (EOFError, KeyboardInterrupt):
print("\nVITALIS: Session logged. Goodbye.")
break
if not user_input:
continue
if user_input.lower() == "exit":
print("VITALIS: Logging session. Goodbye.")
break
if user_input.lower() == "status":
state = self.mind.introspect()
sm = self.mind.self_model.report()
u_rep = self.understanding.report()
print("\n--- COGNITIVE STATE ---")
print(f"Cycle: {state['cycle']}")
print(f"Mode: {state['reasoning']['current_mode']}")
print(f"Personality: {state['personality']['character']}")
print(f"Dominant trait: {state['personality']['dominant']}")
print(f"Confidence: {state['confidence_trend']}")
print(f"Growth index: {sm['growth_index']}")
print(f"Patterns: {state['resonance'].get('total_patterns', 0)}")
print(f"Meta-rules: {state['meta_rules'].get('total_rules', 0)}")
print(f"Needs dream: {state['needs_dream']}")
print("--- UNDERSTANDING ---")
print(f"Interactions: {u_rep['interactions']}")
print(f"Learned meanings:{u_rep['learned_meanings']}")
print(f"Context depth: {u_rep['context_depth']}")
print("-" * 23)
print()
continue
response = self.respond(user_input)
print(f"\nVITALIS: {response}\n")
if __name__ == "__main__":
VitalisConversation().run()
|