
    dh
                     b    S r SSKJrJrJr  SSKJr  SSKJr  SSK	J
r
  SSKJr   " S S\
5      rg	)
zWrapper around Dria Retriever.    )AnyListOptional)CallbackManagerForRetrieverRun)Document)BaseRetriever)DriaAPIWrapperc                      ^  \ rS rSr% Sr\\S'   SS\S\\   S\	4U 4S jjjr
  SS	\S
\S\S\S\4
S jjrS\SS4S jrS\S\S\\   4S jrSrU =r$ )DriaRetriever   z*`Dria` retriever using the DriaAPIWrapper.api_wrapperNapi_keycontract_idkwargsc                 <   > [        XS9n[        TU ]  " SSU0UD6  g)z
Initialize the DriaRetriever with a DriaAPIWrapper instance.

Args:
    api_key: The API key for Dria.
    contract_id: The contract ID of the knowledge base to interact with.
)r   r   r   N )r	   super__init__)selfr   r   r   r   	__class__s        a/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/retrievers/dria_index.pyr   DriaRetriever.__init__   s$     %WN;[;F;    namedescriptioncategory	embeddingreturnc                 >    U R                   R                  XX45      nU$ )a7  Create a new knowledge base in Dria.

Args:
    name: The name of the knowledge base.
    description: The description of the knowledge base.
    category: The category of the knowledge base.
    embedding: The embedding model to use for the knowledge base.


Returns:
    The ID of the created knowledge base.
)r   create_knowledge_base)r   r   r   r   r   responses         r   r    #DriaRetriever.create_knowledge_base   s&    & ##99x
 r   textsc                 v    U Vs/ sH  o"S   US   S.PM     nnU R                   R                  U5        gs  snf )zAdd texts to the Dria knowledge base.

Args:
    texts: An iterable of texts and metadatas to add to the knowledge base.

Returns:
    List of IDs representing the added texts.
textmetadata)r%   r&   N)r   insert_data)r   r#   r%   datas       r   	add_textsDriaRetriever.add_texts4   sB     RWWQVf4
3CDQVW$$T* Xs   6queryrun_managerc          	          U R                   R                  U5      nU Vs/ sH  n[        US   US   US   S.S9PM     nnU$ s  snf )zRetrieve relevant documents from Dria based on a query.

Args:
    query: The query string to search for in the knowledge base.
    run_manager: Callback manager for the retriever run.

Returns:
    A list of Documents containing the search results.
r&   idscore)r.   r/   )page_contentr&   )r   searchr   )r   r+   r,   resultsresultdocss         r   _get_relevant_documents%DriaRetriever._get_relevant_documentsC   si     ""))%0 "

 "	 #J/ &tvgG " 	 
 
s   Ar   )N)Unspecifiedjina)__name__
__module____qualname____firstlineno____doc__r	   __annotations__strr   r   r   r    r   r)   r   r   r5   __static_attributes____classcell__)r   s   @r   r   r      s    4	< 	<(3- 	<RU 	< 	< &  	
  
0++ 
+*H	h r   r   N)r=   typingr   r   r   langchain_core.callbacksr   langchain_core.documentsr   langchain_core.retrieversr   langchain_community.utilitiesr	   r   r   r   r   <module>rG      s(    $ & & C - 3 8KM Kr   