
    Ng3                     f    d dl 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  G d de          ZdS )	    )IteratorListOptional)Document)
BaseLoader)Blob)!AzureAIDocumentIntelligenceParserc                       e Zd ZdZ	 	 	 	 	 	 ddddededee         d	ee         d
ee         dee         dededeee                  ddfdZde	e
         fdZdS )!AzureAIDocumentIntelligenceLoaderz,Load a PDF with Azure Document Intelligence.Nprebuilt-layoutmarkdown)analysis_featuresapi_endpointapi_key	file_pathurl_pathbytes_sourceapi_version	api_modelmoder   returnc	                    |||
J d            || _         || _        || _        t          ||||||	          | _        dS )aO	  
        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.

        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 provided)r   r   r   r   r   r   )r   r   r   r	   parser)
selfr   r   r   r   r   r   r   r   r   s
             q/var/www/html/ai-engine/env/lib/python3.11/site-packages/langchain_community/document_loaders/doc_intelligence.py__init__z*AzureAIDocumentIntelligenceLoader.__init__   si    B !X%9\=U=UA >V=U=U" (7%#/
 
 
    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_load_   s       >%>$.11D{((...........]&{,,T];;;;;;;;;;;*{..t/@AAAAAAAAAAA7888r   )NNNNr   r   )__name__
__module____qualname____doc__strr   bytesr   r   r   r   r%    r   r   r   r      s       66 $("&(,%)*N
 26N
 N
 N
N
 N
 C=	N

 3-N
 uoN
 c]N
 N
 N
 $DI.N
 
N
 N
 N
 N
`9	(	9 9 9 9 9 9r   r   N)typingr   r   r   langchain_core.documentsr   )langchain_community.document_loaders.baser   1langchain_community.document_loaders.blob_loadersr   ,langchain_community.document_loaders.parsersr	   r   r,   r   r   <module>r2      s    + + + + + + + + + + - - - - - - @ @ @ @ @ @ B B B B B B     
_9 _9 _9 _9 _9
 _9 _9 _9 _9 _9r   