o
    qmi                     @   s   d dl Z d dlZd dlZd dlZddlmZ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
lmZ ddlmZmZ eejdZG dd dZG dd dZG dd dZG dd dZdS )    N   )AsyncClientWrapperSyncClientWrapper)RequestOptions)"DocDigitizationJobParametersParams)$DocDigitizationWebhookCallbackParams) DocDigitizationCreateJobResponse)$DocDigitizationDownloadFilesResponse) DocDigitizationJobStatusResponse)"DocDigitizationUploadFilesResponse   )"AsyncRawDocumentIntelligenceClientRawDocumentIntelligenceClient.c                
   @     e Zd ZdZddddddedeje deje fd	d
ZedefddZ	edeje fddZ
edeje fddZdeddfddZdefddZdefddZ		d#dedeje defddZdejejeejf  fddZd edefd!d"ZdS )$DocumentIntelligenceJobu   
    A convenience wrapper for managing document intelligence jobs.

    This class provides high-level methods for the complete document processing workflow:
    create job → upload file → start → wait → download output.
    Nlanguageoutput_formatclientDocumentIntelligenceClientjob_idr   r   c                C   "   || _ || _|| _|| _d | _d S N_client_job_id	_language_output_format_statusselfr   r   r   r    r!   Y/home/ubuntu/.local/lib/python3.10/site-packages/sarvamai/document_intelligence/client.py__init__-   
   
z DocumentIntelligenceJob.__init__returnc                 C      | j S z#The unique identifier for this job.r   r    r!   r!   r"   r   ;      zDocumentIntelligenceJob.job_idc                 C   r&   z%The language configured for this job.r   r)   r!   r!   r"   r   @   r*   z DocumentIntelligenceJob.languagec                 C   r&   z*The output format configured for this job.r   r)   r!   r!   r"   r   E   r*   z%DocumentIntelligenceJob.output_format	file_pathc                 C   s   t j|}| jj| j|gd}|jstd|j|}|s&td| |j	}t j
|d  }dddddd	}||d
}t|d}	|	 }
W d   n1 sUw   Y  tj||
|dddd}|  dS )
        Upload a file for processing.

        Parameters
        ----------
        file_path : str
            Path to the file to upload (PDF, PNG, JPG, or ZIP)
        r   filesNo upload URL returnedNo upload URL for file: r   application/pdf	image/png
image/jpegapplication/zipz.pdfz.pngz.jpgz.jpegz.zipapplication/octet-streamrbN	BlockBlobzContent-Typezx-ms-blob-type     r@contentheaderstimeout)ospathbasenamer   get_upload_linksr   upload_urls
ValueErrorgetfile_urlsplitextloweropenreadhttpxputraise_for_status)r    r/   filenameupload_responsefile_details
upload_urlextcontent_typescontent_typef	file_dataresponser!   r!   r"   upload_fileJ   s<   	
	z#DocumentIntelligenceJob.upload_filec                 C      | j | j| _| jS )
        Start processing the uploaded file.

        Returns
        -------
        DocDigitizationJobStatusResponse
            The job status after starting
        r   startr   r   r)   r!   r!   r"   r`   ~      	zDocumentIntelligenceJob.startc                 C   r]   )
        Get the current status of the job.

        Returns
        -------
        DocDigitizationJobStatusResponse
            The current job status
        r   
get_statusr   r   r)   r!   r!   r"   rd      ra   z"DocumentIntelligenceJob.get_status       @poll_intervalrB   c                 C   sd   t   }h d}	 |  }|j|v r|S |dur,t   | |kr,td| j d| dt | q	)  
        Poll the job status until it completes or fails.

        Parameters
        ----------
        poll_interval : float
            Seconds between status checks (default: 2.0)
        timeout : float, optional
            Maximum seconds to wait (default: None = wait forever)

        Returns
        -------
        DocDigitizationJobStatusResponse
            The final job status

        Raises
        ------
        TimeoutError
            If timeout is reached before job completes
           Failed	CompletedPartiallyCompletedTNJob  did not complete within  seconds)timerd   	job_stateTimeoutErrorr   sleep)r    rf   rB   
start_timeterminal_statesstatusr!   r!   r"   wait_until_complete   s   

z+DocumentIntelligenceJob.wait_until_completec                 C   sV   | j du r	|   | j r)| j jr)t| j jdkr)| j jd }|j|j|j|jdS dS )
        Get page-level metrics from the last status check.

        Returns
        -------
        dict or None
            Dictionary with total_pages, pages_processed, pages_succeeded, pages_failed
        Nr   total_pagespages_processedpages_succeededpages_failed)r   rd   job_detailslenry   rz   r{   r|   r    detailr!   r!   r"   get_page_metrics   s   
	z(DocumentIntelligenceJob.get_page_metricsoutput_pathc           	      C   s   | j | j}|jstdtt|j }|j| }|j}t	j
|dd}|  tj|}|r9tj|dd t|d}||j W d   |S 1 sPw   Y  |S )	  
        Download the processed output to a file.

        Parameters
        ----------
        output_path : str
            Path where the output file will be saved

        Returns
        -------
        str
            The path to the downloaded file
        No download URL availabler>   rB   Texist_okwbN)r   get_download_linksr   download_urlsrH   nextiterkeysrJ   rO   rI   rQ   rC   rD   dirnamemakedirsrM   writer@   )	r    r   download_responsefirst_filenamerT   download_urlr[   
output_dirrY   r!   r!   r"   download_output   s"   

z'DocumentIntelligenceJob.download_outputre   N__name__
__module____qualname____doc__strtypingOptionalr#   propertyr   r   r   r\   r
   r`   rd   floatrv   DictAnyr   r   r!   r!   r!   r"   r   %   sB    
4
 )r   c                   @   *  e Zd ZdefddZedefddZddd	d	d
dedede	j
e de	j
e def
ddZeed	dde	j
e de	j
e de	j
e defddZd	ddede	je de	j
e defddZd	ddede	j
e defddZd	ddede	j
e defddZd	ddede	j
e defdd Zd	S )!r   client_wrapperc                C      t |d| _d S N)r   )r   _raw_clientr    r   r!   r!   r"   r#     s   z#DocumentIntelligenceClient.__init__r%   c                 C   r&   )z
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawDocumentIntelligenceClient
        r   r)   r!   r!   r"   with_raw_response     	z,DocumentIntelligenceClient.with_raw_responsehi-INhtmlNr   r   callback_urlrequest_optionsr   r   r   r   c                C   s@   ||d}d}|durd|i}| j |||d}t| |j||dS )a  
        Create a new document intelligence job with convenience methods.

        This is a high-level method that returns a DocumentIntelligenceJob object
        with methods for uploading, starting, waiting, and downloading.

        Parameters
        ----------
        language : str
            Language code in BCP-47 format (default: "hi-IN")
            Supported: hi-IN, en-IN, bn-IN, gu-IN, kn-IN, ml-IN, mr-IN, or-IN,
                      pa-IN, ta-IN, te-IN, ur-IN, as-IN, bodo-IN, doi-IN, ks-IN,
                      kok-IN, mai-IN, mni-IN, ne-IN, sa-IN, sat-IN, sd-IN

        output_format : str
            Output format: "html" or "md" (default: "html")

        callback_url : str, optional
            Webhook URL for completion notification

        request_options : RequestOptions, optional
            Request-specific configuration

        Returns
        -------
        DocumentIntelligenceJob
            A job object with convenience methods for the workflow

        Examples
        --------
        from sarvamai import SarvamAI

        client = SarvamAI(api_subscription_key="YOUR_API_KEY")

        # Create job
        job = client.document_intelligence.create_job(
            language="hi-IN",
            output_format="html"
        )

        # Upload, start, wait, download
        job.upload_file("document.pdf")
        job.start()
        job.wait_until_complete()
        job.download_output("./output.html")
        r   Nurljob_parameterscallbackr   r   r   r   r   )
initialiser   r   r    r   r   r   r   
job_paramsr   r[   r!   r!   r"   
create_job  s"   8z%DocumentIntelligenceClient.create_jobr   r   r   c                C      | j j|||d}|jS )a	  
        Creates a new document intelligence job.

        **Supported Languages (BCP-47 format):**
        - `hi-IN`: Hindi (default)
        - `en-IN`: English
        - `bn-IN`: Bengali
        - `gu-IN`: Gujarati
        - `kn-IN`: Kannada
        - `ml-IN`: Malayalam
        - `mr-IN`: Marathi
        - `or-IN`: Odia
        - `pa-IN`: Punjabi
        - `ta-IN`: Tamil
        - `te-IN`: Telugu
        - `ur-IN`: Urdu
        - `as-IN`: Assamese
        - `bodo-IN`: Bodo
        - `doi-IN`: Dogri
        - `ks-IN`: Kashmiri
        - `kok-IN`: Konkani
        - `mai-IN`: Maithili
        - `mni-IN`: Manipuri
        - `ne-IN`: Nepali
        - `sa-IN`: Sanskrit
        - `sat-IN`: Santali
        - `sd-IN`: Sindhi

        **Output Formats:**
        - `html`: Structured HTML with layout preservation (default)
        - `md`: Markdown format

        **Prompt Types:**
        Customize how specific content types are processed:
        - `default_ocr`: Standard text extraction (default for all text blocks)
        - `table_to_html`: Convert tables to HTML format
        - `table_to_markdown`: Convert tables to Markdown format
        - `chart_to_markdown`: Extract chart data as Markdown table
        - `chart_to_json`: Extract chart data as JSON
        - `describe_image`: Generate image caption
        - `caption_en`: Same as describe_image (English)
        - `caption_in`: Caption in document language

        **Webhook Callback:**
        Optionally provide a callback URL to receive notification when processing completes.

        Parameters
        ----------
        job_parameters : typing.Optional[DocDigitizationJobParametersParams]
            Job configuration parameters. Omit the request body to use defaults.

        callback : typing.Optional[DocDigitizationWebhookCallbackParams]
            Optional webhook for completion notification

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        DocDigitizationCreateJobResponse
            Successful Response

        Examples
        --------
        from sarvamai import SarvamAI

        client = SarvamAI(
            api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
        )
        client.document_intelligence.initialise()
        r   r   r   datar    r   r   r   	_responser!   r!   r"   r   _  s   Nz%DocumentIntelligenceClient.initialiser   r   r2   c                C   r   )a  
        Returns presigned URLs for uploading input files.

        **File Constraints:**
        - Exactly one file required (PDF or ZIP)
        - PDF files: `.pdf` extension
        - ZIP files: `.zip` extension

        Parameters
        ----------
        job_id : str
            Job identifier returned from Create Job

        files : typing.Sequence[str]
            List of filenames to upload (exactly 1 file: PDF or ZIP)

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        DocDigitizationUploadFilesResponse
            Successful Response

        Examples
        --------
        from sarvamai import SarvamAI

        client = SarvamAI(
            api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
        )
        client.document_intelligence.get_upload_links(
            job_id="job_id",
            files=["files"],
        )
        r   r2   r   r   rF   r   r    r   r2   r   r   r!   r!   r"   rF     s   +z+DocumentIntelligenceClient.get_upload_linksc                C      | j j||d}|jS )a  
        Validates the uploaded file and starts processing.

        **Validation Checks:**
        - File must be uploaded before starting
        - File size must not exceed 200 MB
        - PDF must be parseable by the PDF parser
        - ZIP must contain only JPEG/PNG images
        - ZIP must be flat (no nested folders beyond one level)
        - ZIP must contain at least one valid image
        - Page/image count must not exceed 500
        - User must have sufficient credits

        **Processing:**
        Job runs asynchronously. Poll the status endpoint or use webhook callback for completion notification.

        Parameters
        ----------
        job_id : str
            The unique identifier of the job

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        DocDigitizationJobStatusResponse
            Successful Response

        Examples
        --------
        from sarvamai import SarvamAI

        client = SarvamAI(
            api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
        )
        client.document_intelligence.start(
            job_id="job_id",
        )
        r   r   r`   r   r    r   r   r   r!   r!   r"   r`     s   +z DocumentIntelligenceClient.startc                C   r   )a  
        Returns the current status of a job with page-level metrics.

        **Job States:**
        - `Accepted`: Job created, awaiting file upload
        - `Pending`: File uploaded, waiting to start
        - `Running`: Processing in progress
        - `Completed`: All pages processed successfully
        - `PartiallyCompleted`: Some pages succeeded, some failed
        - `Failed`: All pages failed or job-level error

        **Page Metrics:**
        Response includes detailed progress: total pages, pages processed, succeeded, failed, and per-page errors.

        Parameters
        ----------
        job_id : str
            The unique identifier of the job

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        DocDigitizationJobStatusResponse
            Successful Response

        Examples
        --------
        from sarvamai import SarvamAI

        client = SarvamAI(
            api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
        )
        client.document_intelligence.get_status(
            job_id="job_id",
        )
        r   r   rd   r   r   r!   r!   r"   rd     s   )z%DocumentIntelligenceClient.get_statusc                C   r   )a  
        Returns presigned URLs for downloading output files.

        **Prerequisites:**
        - Job must be in `Completed` or `PartiallyCompleted` state
        - Failed jobs have no output available

        Parameters
        ----------
        job_id : str
            The unique identifier of the job

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        DocDigitizationDownloadFilesResponse
            Successful Response

        Examples
        --------
        from sarvamai import SarvamAI

        client = SarvamAI(
            api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
        )
        client.document_intelligence.get_download_links(
            job_id="job_id",
        )
        r   r   r   r   r   r!   r!   r"   r   >  s   "z-DocumentIntelligenceClient.get_download_links)r   r   r   r   r#   r   r   r   r   r   r   r   r   r   OMITr   r   r   r   Sequencer   rF   r
   r`   rd   r	   r   r!   r!   r!   r"   r      s    
S
Z
1
/
-r   c                
   @   r   )$AsyncDocumentIntelligenceJobu   
    An async convenience wrapper for managing document intelligence jobs.

    This class provides high-level async methods for the complete document processing workflow:
    create job → upload file → start → wait → download output.
    Nr   r   AsyncDocumentIntelligenceClientr   r   r   c                C   r   r   r   r   r!   r!   r"   r#   n  r$   z%AsyncDocumentIntelligenceJob.__init__r%   c                 C   r&   r'   r(   r)   r!   r!   r"   r   |  r*   z#AsyncDocumentIntelligenceJob.job_idc                 C   r&   r+   r,   r)   r!   r!   r"   r     r*   z%AsyncDocumentIntelligenceJob.languagec                 C   r&   r-   r.   r)   r!   r!   r"   r     r*   z*AsyncDocumentIntelligenceJob.output_formatr/   c              	      s$  t j|}| jj| j|gdI dH }|jstd|j|}|s*td| |j	}t j
|d  }ddddd	d
}||d}t|d}	|	 }
W d   n1 sYw   Y  t 4 I dH }|j||
|ddddI dH }|  W d  I dH  dS 1 I dH sw   Y  dS )r0   r1   Nr3   r4   r   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   )rC   rD   rE   r   rF   r   rG   rH   rI   rJ   rK   rL   rM   rN   rO   AsyncClientrP   rQ   )r    r/   rR   rS   rT   rU   rV   rW   rX   rY   rZ   http_clientr[   r!   r!   r"   r\     sB   	

	.z(AsyncDocumentIntelligenceJob.upload_filec                       | j | jI dH | _| jS )r^   Nr_   r)   r!   r!   r"   r`        	z"AsyncDocumentIntelligenceJob.startc                    r   )rb   Nrc   r)   r!   r!   r"   rd     r   z'AsyncDocumentIntelligenceJob.get_statusre   rf   rB   c                    sz   ddl }t }h d}	 |  I dH }|j|v r|S |dur4t | |kr4td| j d| d||I dH  q)rg   r   Nrh   Trl   rm   rn   )asyncioro   rd   rp   rq   r   rr   )r    rf   rB   r   rs   rt   ru   r!   r!   r"   rv     s   
z0AsyncDocumentIntelligenceJob.wait_until_completec                 C   sD   | j r | j jr t| j jdkr | j jd }|j|j|j|jdS dS )rw   r   rx   N)r   r}   r~   ry   rz   r{   r|   r   r!   r!   r"   r     s   
z-AsyncDocumentIntelligenceJob.get_page_metricsr   c           
   	      s   | j | jI dH }|jstdtt|j }|j| }|j}t	
 4 I dH }|j|ddI dH }|  W d  I dH  n1 I dH sJw   Y  tj|}|r^tj|dd t|d}	|	|j W d   |S 1 suw   Y  |S )r   Nr   r>   r   Tr   r   )r   r   r   r   rH   r   r   r   rJ   rO   r   rI   rQ   rC   rD   r   r   rM   r   r@   )
r    r   r   r   rT   r   r   r[   r   rY   r!   r!   r"   r     s(   

(
z,AsyncDocumentIntelligenceJob.download_outputr   r   r!   r!   r!   r"   r   f  sB    
5
 +r   c                   @   r   )!r   r   c                C   r   r   )r   r   r   r!   r!   r"   r#   D  s   z(AsyncDocumentIntelligenceClient.__init__r%   c                 C   r&   )z
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawDocumentIntelligenceClient
        r   r)   r!   r!   r"   r   I  r   z1AsyncDocumentIntelligenceClient.with_raw_responser   r   Nr   r   r   r   r   c                   sH   ||d}d}|durd|i}| j |||dI dH }t| |j||dS )au  
        Create a new document intelligence job with convenience methods.

        This is a high-level method that returns an AsyncDocumentIntelligenceJob object
        with async methods for uploading, starting, waiting, and downloading.

        Parameters
        ----------
        language : str
            Language code in BCP-47 format (default: "hi-IN")
            Supported: hi-IN, en-IN, bn-IN, gu-IN, kn-IN, ml-IN, mr-IN, or-IN,
                      pa-IN, ta-IN, te-IN, ur-IN, as-IN, bodo-IN, doi-IN, ks-IN,
                      kok-IN, mai-IN, mni-IN, ne-IN, sa-IN, sat-IN, sd-IN

        output_format : str
            Output format: "html" or "md" (default: "html")

        callback_url : str, optional
            Webhook URL for completion notification

        request_options : RequestOptions, optional
            Request-specific configuration

        Returns
        -------
        AsyncDocumentIntelligenceJob
            A job object with async convenience methods for the workflow

        Examples
        --------
        import asyncio
        from sarvamai import AsyncSarvamAI

        async def main():
            client = AsyncSarvamAI(api_subscription_key="YOUR_API_KEY")

            # Create job
            job = await client.document_intelligence.create_job(
                language="hi-IN",
                output_format="html"
            )

            # Upload, start, wait, download
            await job.upload_file("document.pdf")
            await job.start()
            await job.wait_until_complete()
            await job.download_output("./output.html")

        asyncio.run(main())
        r   Nr   r   r   )r   r   r   r   r!   r!   r"   r   T  s$   <z*AsyncDocumentIntelligenceClient.create_jobr   r   r   c                       | j j|||dI dH }|jS )a	  
        Creates a new document intelligence job.

        **Supported Languages (BCP-47 format):**
        - `hi-IN`: Hindi (default)
        - `en-IN`: English
        - `bn-IN`: Bengali
        - `gu-IN`: Gujarati
        - `kn-IN`: Kannada
        - `ml-IN`: Malayalam
        - `mr-IN`: Marathi
        - `or-IN`: Odia
        - `pa-IN`: Punjabi
        - `ta-IN`: Tamil
        - `te-IN`: Telugu
        - `ur-IN`: Urdu
        - `as-IN`: Assamese
        - `bodo-IN`: Bodo
        - `doi-IN`: Dogri
        - `ks-IN`: Kashmiri
        - `kok-IN`: Konkani
        - `mai-IN`: Maithili
        - `mni-IN`: Manipuri
        - `ne-IN`: Nepali
        - `sa-IN`: Sanskrit
        - `sat-IN`: Santali
        - `sd-IN`: Sindhi

        **Output Formats:**
        - `html`: Structured HTML with layout preservation (default)
        - `md`: Markdown format

        **Prompt Types:**
        Customize how specific content types are processed:
        - `default_ocr`: Standard text extraction (default for all text blocks)
        - `table_to_html`: Convert tables to HTML format
        - `table_to_markdown`: Convert tables to Markdown format
        - `chart_to_markdown`: Extract chart data as Markdown table
        - `chart_to_json`: Extract chart data as JSON
        - `describe_image`: Generate image caption
        - `caption_en`: Same as describe_image (English)
        - `caption_in`: Caption in document language

        **Webhook Callback:**
        Optionally provide a callback URL to receive notification when processing completes.

        Parameters
        ----------
        job_parameters : typing.Optional[DocDigitizationJobParametersParams]
            Job configuration parameters. Omit the request body to use defaults.

        callback : typing.Optional[DocDigitizationWebhookCallbackParams]
            Optional webhook for completion notification

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        DocDigitizationCreateJobResponse
            Successful Response

        Examples
        --------
        import asyncio

        from sarvamai import AsyncSarvamAI

        client = AsyncSarvamAI(
            api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
        )


        async def main() -> None:
            await client.document_intelligence.initialise()


        asyncio.run(main())
        r   Nr   r   r!   r!   r"   r     s   Vz*AsyncDocumentIntelligenceClient.initialiser   r   r2   c                   r   )a/  
        Returns presigned URLs for uploading input files.

        **File Constraints:**
        - Exactly one file required (PDF or ZIP)
        - PDF files: `.pdf` extension
        - ZIP files: `.zip` extension

        Parameters
        ----------
        job_id : str
            Job identifier returned from Create Job

        files : typing.Sequence[str]
            List of filenames to upload (exactly 1 file: PDF or ZIP)

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        DocDigitizationUploadFilesResponse
            Successful Response

        Examples
        --------
        import asyncio

        from sarvamai import AsyncSarvamAI

        client = AsyncSarvamAI(
            api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
        )


        async def main() -> None:
            await client.document_intelligence.get_upload_links(
                job_id="job_id",
                files=["files"],
            )


        asyncio.run(main())
        r   Nr   r   r!   r!   r"   rF     s
   3z0AsyncDocumentIntelligenceClient.get_upload_linksc                      | j j||dI dH }|jS )a(  
        Validates the uploaded file and starts processing.

        **Validation Checks:**
        - File must be uploaded before starting
        - File size must not exceed 200 MB
        - PDF must be parseable by the PDF parser
        - ZIP must contain only JPEG/PNG images
        - ZIP must be flat (no nested folders beyond one level)
        - ZIP must contain at least one valid image
        - Page/image count must not exceed 500
        - User must have sufficient credits

        **Processing:**
        Job runs asynchronously. Poll the status endpoint or use webhook callback for completion notification.

        Parameters
        ----------
        job_id : str
            The unique identifier of the job

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        DocDigitizationJobStatusResponse
            Successful Response

        Examples
        --------
        import asyncio

        from sarvamai import AsyncSarvamAI

        client = AsyncSarvamAI(
            api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
        )


        async def main() -> None:
            await client.document_intelligence.start(
                job_id="job_id",
            )


        asyncio.run(main())
        r   Nr   r   r!   r!   r"   r`   =  s
   3z%AsyncDocumentIntelligenceClient.startc                   r   )a  
        Returns the current status of a job with page-level metrics.

        **Job States:**
        - `Accepted`: Job created, awaiting file upload
        - `Pending`: File uploaded, waiting to start
        - `Running`: Processing in progress
        - `Completed`: All pages processed successfully
        - `PartiallyCompleted`: Some pages succeeded, some failed
        - `Failed`: All pages failed or job-level error

        **Page Metrics:**
        Response includes detailed progress: total pages, pages processed, succeeded, failed, and per-page errors.

        Parameters
        ----------
        job_id : str
            The unique identifier of the job

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        DocDigitizationJobStatusResponse
            Successful Response

        Examples
        --------
        import asyncio

        from sarvamai import AsyncSarvamAI

        client = AsyncSarvamAI(
            api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
        )


        async def main() -> None:
            await client.document_intelligence.get_status(
                job_id="job_id",
            )


        asyncio.run(main())
        r   Nr   r   r!   r!   r"   rd   u  s
   1z*AsyncDocumentIntelligenceClient.get_statusc                   r   )a  
        Returns presigned URLs for downloading output files.

        **Prerequisites:**
        - Job must be in `Completed` or `PartiallyCompleted` state
        - Failed jobs have no output available

        Parameters
        ----------
        job_id : str
            The unique identifier of the job

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        DocDigitizationDownloadFilesResponse
            Successful Response

        Examples
        --------
        import asyncio

        from sarvamai import AsyncSarvamAI

        client = AsyncSarvamAI(
            api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
        )


        async def main() -> None:
            await client.document_intelligence.get_download_links(
                job_id="job_id",
            )


        asyncio.run(main())
        r   Nr   r   r!   r!   r"   r     s
   *z2AsyncDocumentIntelligenceClient.get_download_links)r   r   r   r   r#   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rF   r
   r`   rd   r	   r   r!   r!   r!   r"   r   C  s    
W
b
9
9
7r   )rC   ro   r   rO   core.client_wrapperr   r   core.request_optionsr   (requests.doc_digitization_job_parametersr   *requests.doc_digitization_webhook_callbackr   *types.doc_digitization_create_job_responser   .types.doc_digitization_download_files_responser	   *types.doc_digitization_job_status_responser
   ,types.doc_digitization_upload_files_responser   
raw_clientr   r   castr   r   r   r   r   r   r!   r!   r!   r"   <module>   s,    \  h ^