Ë
    µŒjÍ  ã                  ó~   — 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y
)é    )Úannotations)ÚTYPE_CHECKINGÚIteratorÚListÚOptional)ÚDocument)Ú
BaseLoader)ÚBlob)Ú!AzureAIDocumentIntelligenceParser)ÚTokenCredentialc                  óf   — e Zd ZdZ	 	 	 	 	 	 	 ddddœ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Z	 	 dd„Zy)	Ú!AzureAIDocumentIntelligenceLoaderz,Load a PDF with Azure Document Intelligence.N)Úanalysis_featuresÚazure_credentialc	          	     ó¢   — |€|€	|€J d«       ‚|€	|
€J d«       ‚|�	|
�J d«       ‚|| _         || _        || _        t        ||||||	|
¬«      | _        y)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.)Úapi_endpointÚapi_keyÚapi_versionÚ	api_modelÚmoder   r   )Ú	file_pathÚurl_pathÚbytes_sourcer   Úparser)Úselfr   r   r   r   r   r   r   r   r   r   s              ú/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/langchain_community/document_loaders/doc_intelligence.pyÚ__init__z*AzureAIDocumentIntelligenceLoader.__init__   s›   € ðJ Ð! XÐ%9¸\Ð=Uð	BàAó	BØUð Ð"Ð&6Ð&Bð 	
ØBó	
ÐBð ˆÐ"2Ð":ð 	
ØIó	
Ð:ð #ˆŒØ ˆŒØ(ˆÔä7Ø%ØØ#ØØØ/Ø-ô
ˆ�ó    c              #  ó²  K  — | j                   �Ct        j                  | j                   «      }| j                  j	                  |«      E d{  –—†  y| j
                  �.| j                  j                  | j
                  «      E d{  –—†  y| j                  �.| j                  j                  | j                  «      E d{  –—†  yt        d«      ‚7 Œ„7 ŒL7 Œ­w)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ˆDØ—{‘{×(Ñ(¨Ó.×.Ñ.Ø�]‰]Ð&Ø—{‘{×,Ñ,¨T¯]©]Ó;×;Ñ;Ø×ÑÐ*Ø—{‘{×.Ñ.¨t×/@Ñ/@ÓA×AÑAäÐ7Ó8Ð8ð /øà;øàAús6   ‚A
CÁCÁ9CÂCÂ9CÃ CÃCÃCÃC)NNNNNzprebuilt-layoutÚmarkdown)r   Ústrr   úOptional[str]r   r)   r   r)   r   zOptional[bytes]r   r)   r   r(   r   r(   r   zOptional[List[str]]r   zOptional['TokenCredential']ÚreturnÚNone)r*   zIterator[Document])Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r&   © r   r   r   r      sµ   „ Ù6ð
 "&Ø#'Ø"&Ø(,Ø%)Ø*Øð\
ð 26Ø8<ñ\
àð\
ð ð\
ð !ð	\
ð
  ð\
ð &ð\
ð #ð\
ð ð\
ð ð\
ð /ð\
ð 6ð\
ð 
ó\
ð|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   r0   r   r   Ú<module>r8      s2   ðÝ "ç :Ó :å -å @Ý Bõñ Ý6ôm9¨
õ m9r   