
    g                         d dl mZmZ d dlmZmZmZ d dlZ ej        e	          Z
 e            Ze                    d          defd            ZdS )    )	APIRouterHTTPException)text_processor
vectorizervector_storeNz/searchqueryc                   K   	 t          j                    st          dd          t          j        |           }|st          dd          t          j        |d         g          d         }t                              d           t          j	        |          }|sddiS d|iS # t          $ rO}t                              d	t          |                      t          d
d	t          |                     d }~ww xY w)Ni  z4FAISS index not initialized. Upload some data first.zEmpty query after processingr   z'Query embedding generated successfully.messagezNo matching records foundresultszSearch failed: i  )r   is_index_initializedr   r   process_queryr   create_embeddingsloggerinfosearch_index	Exceptionerrorstr)r   query_chunksquery_embeddingr   es        6E:\project-album-python\Demo Project\Routers\search.pysearch_imager      s     =022 	]%[\\\ &3E:: 	E%CDDD %6Q7HII!L>??? +O<< 	<:;;7## = = =/s1vv//000C!;3q66!;!;<<<=s   BB& "B& &
C?0A
C::C?)fastapir   r   Utils.dependenciesr   r   r   logging	getLogger__name__r   routerpostr   r        r   <module>r#      s    , , , , , , , , G G G G G G G G G G 		8	$	$	Y=c = = = = = =r"   