§
    šŠtjÍ  ã                  ó†   — 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 d dlmZ erd dlmZ  G d„ d	e
¦  «        Zd
S )é    )Úannotations)ÚTYPE_CHECKINGÚIteratorÚListÚOptional)ÚDocument)Ú
BaseLoader)ÚBlob)Ú!AzureAIDocumentIntelligenceParser)ÚTokenCredentialc                  ó:   — e Zd ZdZ	 	 	 	 	 	 	 ddddœdd„Zdd„ZdS )Ú!AzureAIDocumentIntelligenceLoaderz,Load a PDF with Azure Document Intelligence.Núprebuilt-layoutÚmarkdown)Úanalysis_featuresÚazure_credentialÚapi_endpointÚstrÚapi_keyúOptional[str]Ú	file_pathÚurl_pathÚbytes_sourceúOptional[bytes]Úapi_versionÚ	api_modelÚmoder   úOptional[List[str]]r   úOptional['TokenCredential']ÚreturnÚNonec	          	     ó¾   — |€|€|€
J d¦   «         ‚|€|
€
J d¦   «         ‚|�|
�
J d¦   «         ‚|| _         || _        || _        t          ||||||	|
¬¦  «        | _        dS )a
  
        Initialize the object for file processing with Azure Document Intelligence
        (formerly Form Recognizer).

        This constructor initializes a AzureAIDocumentIntelligenceParser object to be
        used for parsing files using the Azure Document Intelligence API. The load
        method generates Documents whose content representations are determined by the
        mode parameter.

        Parameters:
        -----------
        api_endpoint: str
            The API endpoint to use for DocumentIntelligenceClient construction.
        api_key: str
            The API key to use for DocumentIntelligenceClient construction.
        file_path : Optional[str]
            The path to the file that needs to be loaded.
            Either file_path, url_path or bytes_source must be specified.
        url_path : Optional[str]
            The URL to the file that needs to be loaded.
            Either file_path, url_path or bytes_source must be specified.
        bytes_source : Optional[bytes]
            The bytes array of the file that needs to be loaded.
            Either file_path, url_path or bytes_source must be specified.
        api_version: Optional[str]
            The API version for DocumentIntelligenceClient. Setting None to use
            the default value from `azure-ai-documentintelligence` package.
        api_model: str
            Unique document model name. Default value is "prebuilt-layout".
            Note that overriding this default value may result in unsupported
            behavior.
        mode: Optional[str]
            The type of content representation of the generated Documents.
            Use either "single", "page", or "markdown". Default value is "markdown".
        analysis_features: Optional[List[str]]
            List of optional analysis features, each feature should be passed
            as a str that conforms to the enum `DocumentAnalysisFeature` in
            `azure-ai-documentintelligence` package. Default value is None.
        azure_credential: Optional[TokenCredential]
            The credentials to use for DocumentIntelligenceClient construction, when
            using credentials other than api_key (like AD).

        Examples:
        ---------
        >>> obj = AzureAIDocumentIntelligenceLoader(
        ...     file_path="path/to/file",
        ...     api_endpoint="https://endpoint.azure.com",
        ...     api_key="APIKEY",
        ...     api_version="2023-10-31-preview",
        ...     api_model="prebuilt-layout",
        ...     mode="markdown"
        ... )
        Nz4file_path, url_path or bytes_source must be providedz4Either api_key or azure_credential must be provided.z;Only one of api_key or azure_credential should be provided.)r   r   r   r   r   r   r   )r   r   r   r   Úparser)Úselfr   r   r   r   r   r   r   r   r   r   s              ús/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/langchain_community/document_loaders/doc_intelligence.pyÚ__init__z*AzureAIDocumentIntelligenceLoader.__init__   s¬   € ðJ Ð! XÐ%9¸\Ð=UÐ=UØAñ >VÔ=UÐUð Ð"Ð&6Ð&BÐ&BØBñ 'CÔ&BÐBð ˆÐ"2Ð":Ð":ØIñ #;Ô":Ð:ð #ˆŒØ ˆŒØ(ˆÔå7Ø%ØØ#ØØØ/Ø-ð
ñ 
ô 
ˆŒˆˆó    úIterator[Document]c              #  ó`  K  — | j         �;t          j        | j         ¦  «        }| j                             |¦  «        E d{V —† dS | j        �'| j                             | j        ¦  «        E d{V —† dS | j        �'| j                             | j        ¦  «        E d{V —† dS t          d¦  «        ‚)z Lazy load the document as pages.NzNo data source provided.)
r   r
   Ú	from_pathr#   Úparser   Ú	parse_urlr   Úparse_bytesÚ
ValueError)r$   Úblobs     r%   Ú	lazy_loadz+AzureAIDocumentIntelligenceLoader.lazy_loadr   sÐ   è è € ð Œ>Ð%Ý”> $¤.Ñ1Ô1ˆDØ”{×(Ò(¨Ñ.Ô.Ð.Ð.Ð.Ð.Ð.Ð.Ð.Ð.Ð.ØŒ]Ð&Ø”{×,Ò,¨T¬]Ñ;Ô;Ð;Ð;Ð;Ð;Ð;Ð;Ð;Ð;Ð;ØÔÐ*Ø”{×.Ò.¨tÔ/@ÑAÔAÐAÐAÐAÐAÐAÐAÐAÐAÐAåÐ7Ñ8Ô8Ð8r'   )NNNNNr   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(   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r&   r0   © r'   r%   r   r      sx   € € € € € Ø6Ð6ð
 "&Ø#'Ø"&Ø(,Ø%)Ø*Øð\
ð 26Ø8<ð\
ð \
ð \
ð \
ð \
ð \
ð|9ð 9ð 9ð 9ð 9ð 9r'   r   N)Ú
__future__r   Útypingr   r   r   r   Úlangchain_core.documentsr   Ú)langchain_community.document_loaders.baser	   Ú1langchain_community.document_loaders.blob_loadersr
   Ú,langchain_community.document_loaders.parsersr   Úazure.core.credentialsr   r   r5   r'   r%   ú<module>r=      sé   ðØ "Ð "Ð "Ð "Ð "Ð "à :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :à -Ð -Ð -Ð -Ð -Ð -à @Ð @Ð @Ð @Ð @Ð @Ø BÐ BÐ BÐ BÐ BÐ Bðð ð ð ð ð ð ð 7Ø6Ð6Ð6Ð6Ð6Ð6ðm9ð m9ð m9ð m9ð m9¨
ñ m9ô m9ð m9ð m9ð m9r'   