
    nh                     2   d dl Z d dlZd dlZd dlZd dlmZ e j                  j                  e j                  j                  e
      d      Ze j                  j                  e j                  j                  e
      d      Z ed      ZdefdZd
dedefd	Zy)    N)SentenceTransformerzfaiss.indexzfaiss_meta.pklzall-MiniLM-L6-v2queryc                 v    t         j                  | g      }t        j                  |      j	                  d      S )Nfloat32)modelencodenparrayastype)r   	embeddings     0/var/www/html/axiom-chatbot/chatbot/retriever.pyembed_queryr      s,    eW%I88I%%i00    top_kc                    t        j                  t              }t        t        d      5 }t        j                  |      }d d d        t        |       }|j                  ||      \  }}|d   D cg c]  }|   	 c}S # 1 sw Y   ?xY wc c}w )Nrbr   )	faiss
read_index
INDEX_PATHopen	META_PATHpickleloadr   search)	r   r   indexfchunks	query_vecDIis	            r   retriever"      s{    Z(E	i	  !Q E"I<<	5)DAq t$!F1I$$	    %s   A>/B
>B)   )osr   numpyr	   r   sentence_transformersr   pathjoindirname__file__r   r   r   strr   intr"    r   r   <module>r.      s    	    5WW\\"''//(3]C
GGLL24DE	./1s 1%C % %r   