
    >h
                        S r SSKrSSKJr  \R                  R                  S\" \" \5      R                  R                  S-  5      5        SSK	J	r	   " S S5      r
\S:X  a  SS	KJr  SS
KJr  \R                  R                  S\" \" \5      R                  5      5        SSKJr  \" S5        \" 5       r\" \5      r\" 5       r\
" \\5      r\R/                  5         \" S5        gg)z8
Self-Reflection Loop - Eden questions her own thinking
    N)Pathautonomy)datetimec                   6    \ rS rSrS	S jrS rS rS rS rSr	g)
SelfReflectionLoop
   Nc                 *    Xl         X l        / U l        g )N)metacausalreflections)selfmeta_learnercausal_models      E/home/james-whalen/eden-agi-project/core/reasoning/self_reflection.py__init__SelfReflectionLoop.__init__   s     	"    c                    / nU R                   (       a  U R                   R                  (       a  U R                   R                  R                  R                  SS5      n[	        U R                   R                  R                  R                  S0 5      5      nUS:  a.  X2-  nUS:  a  UR                  S5        U$ UR                  S5        U$ )Ntotal_experiencesr   successful_patternsg      ?z"Good pattern extraction efficiencyz"Should focus on pattern extraction)r
   learning	knowledgegetlenappend)r   r   	total_exppatternspattern_rates        r   reflect_on_performance)SelfReflectionLoop.reflect_on_performance   s    99++		**44889LaPI499--77;;<QSUVWH1}'3#%&&'KL   &&'KLr   c                     / nU R                   (       a4  [        U R                   R                  5      S:  a  UR                  S5        U$ )N   zAm I oversimplifying causality?)r   r   causal_linksr   )r   	questionss     r   question_assumptions'SelfReflectionLoop.question_assumptions   s:    	;;4;;++,q0  !BCr   c                 F   / nU R                   (       a  U R                   R                  (       ar  [        5       nU R                   R                  R                   H$  nUR	                  UR                  SS5      5        M&     [        U5      S:  a  UR                  S5        U$ )N	task_typegeneral   zLimited task diversity)r
   r   setexperiencesaddr   r   r   )r   
blindspots
task_typesexps       r   identify_blindspots&SelfReflectionLoop.identify_blindspots$   ss    
99++Jyy))55sww{I>? 6:"!!":;r   c                    [        S5        [        S5        [        S5        U R                  5       nU R                  5       nU R                  5       n[        S5        U H  n[        SU 35        M     [        S5        U H  n[        SU 35        M     [        S5        U H  n[        SU 35        M     [        S5        XUS.$ )	NzG
======================================================================u   🔄 SELF-REFLECTION LOOPzF======================================================================u   
💭 Performance:z   - u   
❓ Questions:u   
🔍 Blindspots:)r   r$   r.   )printr   r%   r1   )r   r   r$   r.   rqbs          r   continuous_reflect%SelfReflectionLoop.continuous_reflect.   s    m)*f113--/	--/
#$AE!+  	 !AE!+  	"#AE!+  	m*R\]]r   )r   r
   r   )NN)
__name__
__module____qualname____firstlineno__r   r   r%   r1   r8   __static_attributes__ r   r   r   r   
   s    
^r   r   __main__)MetaLearner)LearningLoop)CausalModelzSELF-REFLECTION TESTu    
✅ SELF-REFLECTION OPERATIONAL)__doc__syspathlibr   pathinsertstr__file__parentr   r   r:   r   rA   learning_loopsrB   r   rC   r4   r   r
   r   
reflectionr8   r?   r   r   <module>rN      s      3tH~,,33j@A B :^ :^x z(+HHOOAs4>0012(	
 !~Hx D]F#D&1J!!#	
-. r   