o
    j6h"                     @  s  d dl mZ d dlmZmZmZ d dlm  mZ	 d dl
mZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ 				d-d.ddZ				d-d/ddZ		d0d1ddZ		d0d2ddZ			d3d4d d!Z			d3d5d"d#Zdddd$d6d(d)Zdddd$d7d+d,ZdS )8    )annotations)AsyncIterableIterableOptionalN)protos)get_default_retriever_client)"get_default_retriever_async_client)helper_types)idecode_time)retriever_typesname
str | Nonedisplay_nameclient!glm.RetrieverServiceClient | Nonerequest_options&helper_types.RequestOptionsType | Nonereturnretriever_types.Corpusc                 C  s   |du ri }|du rt  }| du rtj|d}nt| r(tjd|  |d}nttjjt| | dtj	|d}|j
|fi |}t||}t|d t|d tjd	i |}|S )
a  Calls the API to create a new `Corpus` by specifying either a corpus resource name as an ID or a display name, and returns the created `Corpus`.

    Args:
        name: The corpus resource name (ID). The name must be alphanumeric and fewer
            than 40 characters.
        display_name: The human readable display name. The display name must be fewer
            than 128 characters. All characters, including alphanumeric, spaces, and
            dashes are supported.
        request_options: Options for the request.

    Return:
        `retriever_types.Corpus` object with specified name or display name.

    Raises:
        ValueError: When the name is not specified or formatted incorrectly.
    Nr   corpora/r   r   lengthr   corpuscreate_timeupdate_time )r   r   Corpusr   
valid_name
ValueErrorNAME_ERROR_MSGformatlenCreateCorpusRequestcreate_corpustypeto_dictr
   r   r   r   r   r   requestresponser   r   l/var/www/html/chefvision.cloud.itp360.com/venv/lib/python3.10/site-packages/google/generativeai/retriever.pyr&      s    


r&   &glm.RetrieverServiceAsyncClient | Nonec                   s   |du ri }|du rt  }| du rtj|d}nt| r)tjd|  |d}nttjjt| | dtj	|d}|j
|fi |I dH }t||}t|d t|d tjd	i |}|S )
z7This is the async version of `retriever.create_corpus`.Nr   r   r   r   r   r   r   r   )r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r
   r)   r   r   r,   create_corpus_asyncJ   s"   


r.   strc                 C  s~   |du ri }|du rt  }d| vrd|  } tj| d}|j|fi |}t||}t|d t|d tjdi |}|S )zCalls the API to fetch a `Corpus` by name and returns the `Corpus`.

    Args:
        name: The `Corpus` name.
        request_options: Options for the request.

    Return:
        a `retriever_types.Corpus` of interest.
    N/r   r   r   r   r   )	r   r   GetCorpusRequest
get_corpusr'   r(   r
   r   r   r   r   r   r*   r+   r   r   r,   r3   g   s   

r3   c                   s   |du ri }|du rt  }d| vrd|  } tj| d}|j|fi |I dH }t||}t|d t|d tjdi |}|S )z4This is the async version of `retriever.get_corpus`.Nr0   r   r1   r   r   r   )	r   r   r2   r3   r'   r(   r
   r   r   r4   r   r   r,   get_corpus_async   s   

r5   Fforceboolc                 C  sN   |du ri }|du rt  }d| vrd|  } tj| |d}|j|fi | dS )ab  Calls the API to remove a `Corpus` from the service, optionally deleting associated `Document`s and objects if the `force` parameter is set to true.

    Args:
        name: The `Corpus` name.
        force: If set to true, any `Document`s and objects related to this `Corpus` will also be deleted.
        request_options: Options for the request.

    Nr0   r   r   r6   )r   r   DeleteCorpusRequestdelete_corpusr   r6   r   r   r*   r   r   r,   r:      s   r:   c                   sV   |du ri }|du rt  }d| vrd|  } tj| |d}|j|fi |I dH  dS )z7This is the async version of `retriever.delete_corpus`.Nr0   r   r8   )r   r   r9   r:   r;   r   r   r,   delete_corpus_async   s   r<   )	page_sizer   r   r=   Optional[int] Iterable[retriever_types.Corpus]c                 c  sx    |du ri }|du rt  }tj| d}|j|fi |D ]}t||}t|d t|d tjdi |V  qdS )aY  Calls the API to list all `Corpora` in the service and returns a list of paginated `Corpora`.

    Args:
        page_size: Maximum number of `Corpora` to request.
        page_token: A page token, received from a previous ListCorpora call.
        request_options: Options for the request.

    Return:
        Paginated list of `Corpora`.
    Nr=   r   r   r   )	r   r   ListCorporaRequestlist_corporar'   r(   r
   r   r   r=   r   r   r*   r   r   r   r,   rB      s   

rB   %AsyncIterable[retriever_types.Corpus]c                 C s   |du ri }|du rt  }tj| d}|j|fi |I dH 2 z 3 dH W }t||}t|d t|d tjdi |V  q 6 dS )z6This is the async version of `retriever.list_corpora`.Nr@   r   r   r   )	r   r   rA   rB   r'   r(   r
   r   r   rC   r   r   r,   list_corpora_async   s   $

rE   )NNNN)
r   r   r   r   r   r   r   r   r   r   )
r   r   r   r   r   r-   r   r   r   r   )NN)r   r/   r   r   r   r   r   r   )r   r/   r   r-   r   r   r   r   )FNN)r   r/   r6   r7   r   r   r   r   )r   r/   r6   r7   r   r-   r   r   )r=   r>   r   r   r   r   r   r?   )r=   r>   r   r   r   r   r   rD   )
__future__r   typingr   r   r   google.ai.generativelanguageaigenerativelanguageglmgoogle.generativeair   google.generativeai.clientr   r   google.generativeai.typesr	   %google.generativeai.types.model_typesr
   r   r&   r.   r3   r5   r:   r<   rB   rE   r   r   r   r,   <module>   sR   -" 