a
    bg'                     @  s`   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 deZd	S )
z$Wrapper around Embedchain Retriever.    )annotations)AnyIterableListOptional)CallbackManagerForRetrieverRun)Document)BaseRetrieverc                   @  sR   e Zd ZU dZded< eddd dddZd	d
dddZddddddZdS )EmbedchainRetrieverz`Embedchain` retriever.r   clientNzOptional[str])	yaml_pathreturnc                 C  s.   ddl m} |r|j|d}n| }| |d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)r   )r   )Z
embedchainr   from_config)clsr   r   r    r   w/var/www/html/cobodadashboardai.evdpl.com/venv/lib/python3.9/site-packages/langchain_community/retrievers/embedchain.pycreate   s
    zEmbedchainRetriever.createzIterable[str]z	List[str])textsr   c                 C  s(   g }|D ]}| j |}|| q|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)selfr   ZidstextZ_idr   r   r   	add_texts(   s
    zEmbedchainRetriever.add_textsstrr   zList[Document])queryrun_managerr   c                C  sJ   | j |}g }|D ]0}|t|d |d d |d d dd q|S )NcontextmetadataurlZdoc_id)sourceZdocument_id)Zpage_contentr   )r   searchr   r   )r   r   r   resdocsrr   r   r   _get_relevant_documents:   s    

	z+EmbedchainRetriever._get_relevant_documents)N)	__name__
__module____qualname____doc____annotations__classmethodr   r   r%   r   r   r   r   r
      s   
r
   N)r)   
__future__r   typingr   r   r   r   Zlangchain_core.callbacksr   Zlangchain_core.documentsr   Zlangchain_core.retrieversr	   r
   r   r   r   r   <module>   s   