+
    *j  c                      R t ^ RIHt ^ RIt^ RIHu Ht ^ RI	t	^ RI
t^ RIt^ RIHt ^ RIHt ^ t ! R R4      t]! 4       t. ROt]P*                  R 4       tR tR	 tR
 tR tR# )uJ   Tests for runtime/conversation/retrieval.py — offline via stub embedder.)annotationsN)build_index)retrievec                  .    ] tR t^tRRRR/R R lltRtR# )_HashEmbeddershow_progress_barFnormalize_embeddingsc               (    V ^8  d   QhRRRRRRRR/# )   	sentencesz	list[str]r   boolr   returnz
np.ndarray )formats   "E/Users/jameslopez/projects/MentorCore/tests/runtime/test_retrieval.py__annotate___HashEmbedder.__annotate__   s2        	
 # 
    c               	    . pV F  p\         P                  ! VP                  4       4      P                  4       pV\        \        V4      ,          ^,           ,          R\         p\        P                  ! V\        P                  R7      P                  \        P                  4      R,
          pV'       d/   \        P                  P                  V4      p	V	^ 8  d	   W,          pVP                  V4       K  	  \        P                  ! V4      # )   N)dtypeg      `@)hashlibsha256encodedigestDIMlennp
frombufferuint8astypefloat32linalgnormappendstack)
selfr
   r   r   vecsshrawvecr"   s
   &&$$      r   r   _HashEmbedder.encode   s     Aqxxz*113As1v)*DS1C--2884;;BJJG%OC#yy~~c*!8KCKK  xx~r   r   N)__name__
__module____qualname____firstlineno__r   __static_attributes__r   r   r   r   r      s      #(	
 &+ r   r   c                J    V R ,          p\        R\        /V\        RR7       V# )indexsrcT)embedder	overwrite)r   PASSAGESFAKE)tmp_pathidxs   & r   	index_dirr:   -   s$    
W
C!3FJr   c                   \        R V ^\        R7      p\        V4      p^ q2V8  qD'       Eg   \        P                  ! RV3RW#34      RR\
        P                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MRRR\
        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      R\        P                  ! V4      /,          pRR	V/,          p\        \        P                  ! V4      4      hR
;p;rCRqq^ ,          qV9   q"'       gy   \        P                  ! RV3RWx34      R\        P                  ! V4      R\        P                  ! V4      /,          p	RRV	/,          p\        \        P                  ! V4      4      hR
;p;r(Rqq^ ,          qV9   q"'       gy   \        P                  ! RV3RWx34      R\        P                  ! V4      R\        P                  ! V4      /,          p	RRV	/,          p\        \        P                  ! V4      4      hR
;p;r(Rqq^ ,          qV9   q"'       gy   \        P                  ! RV3RWx34      R\        P                  ! V4      R\        P                  ! V4      /,          p	RRV	/,          p\        \        P                  ! V4      4      hR
;p;r(R
# )zmind and powertop_kr4   py0r   py1resultspy3py6assert %(py8)spy8Nchunk_idpy4assert %(py6)s	source_idtext)>)z/%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} > %(py6)s)in)z%(py1)s in %(py4)sr   r7   r   
@pytest_ar_call_reprcompare@py_builtinslocals_should_repr_global_name	_safereprAssertionError_format_explanation)
r:   r@   @py_assert2@py_assert5@py_assert4@py_format7@py_format9@py_assert0@py_assert3@py_format5s
   &         r   test_retrieve_returns_resultsr]   4   s   '!dKGw<!!<33ww<!#######:###:###########$!*$*$$$$$;$$$;$$$*$$$$$$$$QZZ66Zr   c                   \        R V R,          \        R7      p. q!V8H  q3'       g   \        P                  ! R	V3R
W34      RR\        P
                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;r2R# )anythingr2   )r4   r>   r@   rA   zassert %(py5)spy5N==)z%(py0)s == %(py3)s)
r   r7   rM   rN   rO   rP   rQ   rR   rS   rT   )r8   r@   rU   @py_assert1@py_format4@py_format6s   &     r   'test_retrieve_empty_index_returns_emptyrf   <   sr    z8g#5EGb=777br   c                   \        R V ^\        R7      p\        V4      p^q2V8*  qD'       Eg   \        P                  ! RV3RW#34      RR\
        P                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MRRR\
        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      R\        P                  ! V4      /,          pRR	V/,          p\        \        P                  ! V4      4      hR
;p;rCR
# )actionr<   r>   r   r?   r@   rA   rB   rC   rD   N)<=)z0%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} <= %(py6)srL   )r:   r@   rU   rV   rW   rX   rY   s   &      r   test_retrieve_top_k_respectedrj   A   s    x!dCGw<11<33ww<1r   c                d   \        R V ^\        R7      pV F  pVR,          pRqCV8H  qU'       gy   \        P                  ! R	V3R
W434      R\        P                  ! V4      R\        P                  ! V4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;p;rTK  	  R# )presentr<   rH   r3   r?   rF   rG   rB   Nra   )z%(py1)s == %(py4)s)r   r7   rM   rN   rR   rS   rT   )r:   r@   rrZ   r[   rU   r\   rX   s   &       r   "test_retrieve_result_has_source_idrn   F   sl    y)1tDG~&&&&&&&~&&&~&&&&&&&&&&& r   )z2You have power over your mind, not outside events.z)The impediment to action advances action.z Confine yourself to the present.)__doc__
__future__r   builtinsrO   _pytest.assertion.rewrite	assertionrewriterM   r   numpyr   pytestcompiler.stages.indexr   runtime.conversation.retrievalr   r   r   r7   r6   fixturer:   r]   rf   rj   rn   r   r   r   <module>rz      si    P "      - 3 *    

'r   