o
    ß­jË"  ã                   @  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   úZ/var/www/html/CropPilot/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 )zãCalls 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   ü-üý"ýüüü ü