
    rh"                    z   d dl mZ d dlmZmZmZ d dlmc 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
Z	 	 	 	 d	 	 	 	 	 	 	 	 	 ddZ	 	 d	 	 	 	 	 	 	 ddZ	 	 d	 	 	 	 	 	 	 ddZ	 	 	 d	 	 	 	 	 	 	 ddZ	 	 	 d	 	 	 	 	 	 	 ddZdddd	 	 	 	 	 	 	 ddZdddd	 	 	 	 	 	 	 ddZy)    )annotations)AsyncIterableIterableOptionalN)protos)get_default_retriever_client)"get_default_retriever_async_client)helper_types)idecode_time)retriever_typesc                   |i }|
t               }| t        j                  |      }nct        j                  |       rt        j                  d|  |      }n3t        t        j                  j                  t        |       |             t        j                  |      } |j                  |fi |}t        |      j                  |      }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.
    display_namecorpora/namer   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   clientrequest_optionsr   requestresponses          p/var/www/html/ai-insurance-compliance-backend/venv/lib/python3.12/site-packages/google/generativeai/retriever.pyr!   r!      s    , ~-/|L9		#	#D	)htf$5LQ77>>c$iVZ>[\\((7G#v##G??HH~%%h/H=)=)%%11HO    c                  K   |i }|
t               }| t        j                  |      }nct        j                  |       rt        j                  d|  |      }n3t        t        j                  j                  t        |       |             t        j                  |      } |j                  |fi | d{   }t        |      j                  |      }t        |d       t        |d       t        j                  d	i |}|S 7 Mw)
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$   s          r)   create_corpus_asyncr,   J   s      ~35|L9		#	#D	)htf$5LQ77>>c$iVZ>[\\((7G)V))'E_EEHH~%%h/H=)=)%%11HO Fs   B9D;D	<ADc                   |i }|
t               }d| vrd| z   } t        j                  |       } |j                  |fi |}t	        |      j                  |      }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.
    /r   r   r   r   r   )	r   r   GetCorpusRequest
get_corpusr"   r#   r   r   r   r   r%   r&   r'   r(   s        r)   r1   r1   g   s     ~-/
$D %%40G v  <O<HH~%%h/H=)=)%%11HOr*   c                4  K   |i }|
t               }d| vrd| z   } t        j                  |       } |j                  |fi | d{   }t	        |      j                  |      }t        |d       t        |d       t        j                  di |}|S 7 Mw)z4This is the async version of `retriever.get_corpus`.Nr.   r   r/   r   r   r   )	r	   r   r0   r1   r"   r#   r   r   r   r2   s        r)   get_corpus_asyncr4      s      ~35
$D %%40G&V&&wB/BBHH~%%h/H=)=)%%11HO Cs   ABB	ABc                    |i }|
t               }d| vrd| z   } t        j                  | |      } |j                  |fi | y)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.

    Nr.   r   r   force)r   r   DeleteCorpusRequestdelete_corpusr   r7   r%   r&   r'   s        r)   r9   r9      sT     ~-/
$D ((d%@GF4O4r*   c                   K   |i }|
t               }d| vrd| z   } t        j                  | |      } |j                  |fi | d{    y7 w)z7This is the async version of `retriever.delete_corpus`.Nr.   r   r6   )r	   r   r8   r9   r:   s        r)   delete_corpus_asyncr<      s^      ~35
$D ((d%@G
&

w
:/
:::s   AA	A
A)	page_sizer%   r&   c              #    K   |i }|
t               }t        j                  |       } |j                  |fi |D ]K  }t	        |      j                  |      }t        |d       t        |d       t        j                  di | M yw)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   s        r)   rA   rA      s       ~-/'')<G%&%%gAA /f%%f-V]+V]+$$.v..	/s   B	Bc               @  K   |i }|
t               }t        j                  |       } |j                  |fi | d{   2 3 d{   }t	        |      j                  |      }t        |d       t        |d       t        j                  di | T7 X7 Q6 yw)z6This is the async version of `retriever.list_corpora`.Nr?   r   r   r   )	r	   r   r@   rA   r"   r#   r   r   r   rB   s        r)   list_corpora_asyncrD      s      ~35'')<G1f11'M_MM / /ff%%f-V]+V]+$$.v..	 N /Ms5   =BB BBB	BABBB)NNNN)
r   
str | Noner   rE   r%   !glm.RetrieverServiceClient | Noner&   &helper_types.RequestOptionsType | Nonereturnretriever_types.Corpus)
r   rE   r   rE   r%   &glm.RetrieverServiceAsyncClient | Noner&   rG   rH   rI   )NN)r   strr%   rF   r&   rG   rH   rI   )r   rK   r%   rJ   r&   rG   rH   rI   )FNN)r   rK   r7   boolr%   rF   r&   rG   )r   rK   r7   rL   r%   rJ   r&   rG   )r=   Optional[int]r%   rF   r&   rG   rH   z Iterable[retriever_types.Corpus])r=   rM   r%   rF   r&   rG   rH   z%AsyncIterable[retriever_types.Corpus])
__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,   r1   r4   r9   r<   rA   rD   r   r*   r)   <module>rX      s   # 5 4 * * & C I 2 > 5 #04>B	)
)) .) <	)
 )Z #59>B	
 3 <	
 > 15>B
- < 	D 6:>B
2 < 	6 04>B	5
55 .5 <	5: 59>B	;
;; 3; <	;,  $04>B	// ./ <	/
 &/@  $04>B	// ./ <	/
 +/r*   