""" 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()