
    h'                    f    d Z ddlmZ ddlmZmZmZmZ ddlm	Z	 ddl
mZ ddlmZ  G d de      Zy	)
z$Wrapper around Embedchain Retriever.    )annotations)AnyIterableListOptional)CallbackManagerForRetrieverRun)Document)BaseRetrieverc                  V    e Zd ZU dZded<   	 edd	d       Z	 	 	 	 d
dZ	 	 	 	 	 	 ddZy)EmbedchainRetrieverz`Embedchain` retriever.r   clientNc                X    ddl m} |r|j                  |      }n |       } | |      S )a%  
        Create a EmbedchainRetriever from a YAML configuration file.

        Args:
            yaml_path: Path to the YAML configuration file. If not provided,
                       a default configuration is used.

        Returns:
            An instance of EmbedchainRetriever.

        r   )Pipeline)	yaml_path)r   )
embedchainr   from_config)clsr   r   r   s       h/var/www/html/aiagenthome/venv/lib/python3.12/site-packages/langchain_community/retrievers/embedchain.pycreatezEmbedchainRetriever.create   s1     	( ))I)>FZF&!!    c                p    g }|D ].  }| j                   j                  |      }|j                  |       0 |S )zRun more texts through the embeddings and add to the retriever.

        Args:
            texts: Iterable of strings/URLs to add to the retriever.

        Returns:
            List of ids from adding the texts into the retriever.
        )r   addappend)selftextsidstext_ids        r   	add_textszEmbedchainRetriever.add_texts(   s7     D++//$'CJJsO  
r   c          	         | j                   j                  |      }g }|D ]0  }|j                  t        |d   |d   d   |d   d   d             2 |S )Ncontextmetadataurldoc_id)sourcedocument_id)page_contentr"   )r   searchr   r	   )r   queryrun_managerresdocsrs         r   _get_relevant_documentsz+EmbedchainRetriever._get_relevant_documents:   sf     kk  'AKK!"9"#J-"6'(}X'>  r   )N)r   zOptional[str]returnr   )r   zIterable[str]r/   z	List[str])r)   strr*   r   r/   zList[Document])	__name__
__module____qualname____doc____annotations__classmethodr   r   r.    r   r   r   r      sS    !K" "* 
$*H	r   r   N)r4   
__future__r   typingr   r   r   r   langchain_core.callbacksr   langchain_core.documentsr	   langchain_core.retrieversr
   r   r7   r   r   <module>r=      s&    * " 0 0 C - 3>- >r   