o
    |!g                    @   s*  d dl Z d dlZd dlmZ ddlm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 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) ddl*m+Z+ ddl,m-Z- ddl.m/Z/ ddl0m1Z1 ddl2m3Z3 ddl4m5Z5 ddl6m7Z7 ddl8m9Z9 ddl:m;Z; ddl<m=Z= dd l>m?Z? dd!l@mAZA dd"lBmCZC d#d$lDmEZE d#d%lFmGZG d#d&lHmIZI zd dlJZJeJjKLd'reMd dlNmOZJ W n eMy   d dlJZJY nw e Pe jQd(ZRG d)d* d*ZSG d+d, d,ZTdS )-    N)JSONDecodeError   )ApiError)AsyncClientWrapperSyncClientWrapper)jsonable_encoder)remove_none_from_dict)UnprocessableEntityError)ChatData)CloudDocument)CloudDocumentCreate)ConfiguredTransformationItem)DataSinkCreate)EvalExecutionParams)HttpValidationError)InputMessage)LlamaParseParameters)ManagedIngestionStatusResponse)MetadataFilters)#PaginatedListCloudDocumentsResponse)"PaginatedListPipelineFilesResponse)Pipeline)PipelineCreate)PipelineDataSource)PipelineDataSourceCreate)PipelineDeployment)PipelineFile)PipelineFileCreate)PipelineType)PlaygroundSession)PresetRetrievalParams)RetrievalMode)RetrieveResults)TextNode   )%PipelineFileUpdateCustomMetadataValue)PipelineUpdateEmbeddingConfig)PipelineUpdateTransformConfigz1..c                   @   
  e Zd ZdefddZddddddeje deje deje d	eje d
ej	e
 f
ddZddddeje deje ded
e
fddZddddeje deje ded
e
fddZded
e
fddZeeeeeeeeeeeddedeje deje dejej	e  deje deje deje deje deje d eje d!eje d"eje d
e
fd#d$Zded
dfd%d&Zded
efd'd(Zded
e
fd)d*Zded
e
fd+d,Zded
e
fd-d.Zddd/ded0eje d1eje d
ej	e  fd2d3Z!dedej	e" d
ej	e  fd4d5Z#ddddd6ded0eje d1eje d7eje$ d8eje$ d
e%fd9d:Z&d;eded
efd<d=Z'ed>d;eded?ejej(eeje) f  d
e fd@dAZ*d;eded
dfdBdCZ+dedDej,d
ej(eef fdEdFZ-ded
dfdGdHZ.ded
ej	e/ fdIdJZ0dedej	e1 d
ej	e/ fdKdLZ2edMd0ededNeje3 d
e/fdOdPZ4d0eded
dfdQdRZ5d0eded
e
fdSdTZ6d0eded
efdUdVZ7eeeeeeeeeeedWdedXeje$ dYeje3 dZeje$ d[eje d\eje$ d]eje3 d^eje8 d_eje$ d`eje9 daeje dbedceje d
e:fdddeZ;ded
ej	e< fdfdgZ=dheded
e<fdidjZ>ded
e?fdkdlZ@eeedmdednejej	eA  doejeB dceje d
ejCf
dpdqZDddddddrdedseje$ d7eje$ d;eje dteje dueje d
ej	eE fdvdwZFdedej	eG d
ej	eE fdxdyZHdedej	eG d
ej	eE fdzd{ZIddddddrdedseje$ d7eje$ d;eje dteje dueje d
eJfd|d}ZKd~eded
eEfddZLd~eded
dfddZMd~eded
efddZNd~eded
ej	eO fddZPdS )PipelinesClientclient_wrapperc                C   
   || _ d S N_client_wrapperselfr*    r1   h/mnt/skqttb/ctump_chatbot/chatbot/lib/python3.10/site-packages/llama_cloud/resources/pipelines/client.py__init__7      
zPipelinesClient.__init__N
project_idproject_namepipeline_namepipeline_typer6   r7   r8   r9   returnc             	   C   s   | j jjdtj| j   ddt||||d| j  dd}d|j	  kr,dk r9n nt
tjt | S |j	d	krHtt
t| z| }W n ty]   t|j	|jd
w t|j	|d
)aA  
        Search for pipelines by various parameters.

        Parameters:
            - project_id: typing.Optional[str].

            - project_name: typing.Optional[str].

            - pipeline_name: typing.Optional[str].

            - pipeline_type: typing.Optional[PipelineType].
        ---
        from llama_cloud import PipelineType
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.pipelines.search_pipelines(
            pipeline_type=PipelineType.PLAYGROUND,
        )
        GET/api/v1/pipelinesr5   <   paramsheaderstimeout   ,    status_codebodyr.   httpx_clientrequesturllibparseurljoinget_base_urlr   get_headersrG   pydanticparse_obj_astypingListr   jsonr	   r   r   r   textr0   r6   r7   r8   r9   	_response_response_jsonr1   r1   r2   search_pipelines:   s.   
z PipelinesClient.search_pipelinesr6   organization_idr\   rK   c                C      | j jjdtj| j   ddt||dt|| j 	 dd}d|j
  kr-dk r7n ntt| S |j
d	krFttt| z| }W n ty[   t|j
|jd
w t|j
|d
)
        Create a new pipeline for a project.

        Parameters:
            - project_id: typing.Optional[str].

            - organization_id: typing.Optional[str].

            - request: PipelineCreate.
        POSTr<   r=   r[   r>   r@   rU   rA   rB   rC   rD   rE   rF   r.   rJ   rK   rL   rM   rN   rO   r   r   rP   rG   rQ   rR   r   rU   r	   r   r   r   rV   r0   r6   r\   rK   rX   rY   r1   r1   r2   create_pipelinep   s$   
zPipelinesClient.create_pipelinec                C   r]   )H  
        Upsert a pipeline for a project.
        Updates if a pipeline with the same name and project_id already exists. Otherwise, creates a new pipeline.

        Parameters:
            - project_id: typing.Optional[str].

            - organization_id: typing.Optional[str].

            - request: PipelineCreate.
        PUTr<   r=   r[   r>   r`   rC   rD   rE   rF   ra   rb   r1   r1   r2   upsert_pipeline   s$   
zPipelinesClient.upsert_pipelinepipeline_idc                 C   s   | j jjdtj| j   dd| | j  dd}d|j  kr'dk r1n nt	
t| S |jdkr@tt	
t| z| }W n tyU   t|j|jd	w t|j|d	)
p
        Get a pipeline by ID for a given project.

        Parameters:
            - pipeline_id: str.
        r;   r<   api/v1/pipelines/r>   rA   rB   rC   rD   rE   rF   r.   rJ   rK   rL   rM   rN   rO   rP   rG   rQ   rR   r   rU   r	   r   r   r   rV   r0   rg   rX   rY   r1   r1   r2   get_pipeline   s    
zPipelinesClient.get_pipelineembedding_configtransform_configconfigured_transformationsdata_sink_idembedding_model_config_id	data_sinkpreset_retrieval_parameterseval_parametersllama_parse_parametersnamemanaged_pipeline_idro   rp   rq   rr   rs   rt   ru   rv   rw   rx   ry   c                C   st  i }|t ur
||d< |t ur||d< |t ur||d< |t ur"||d< |t ur*||d< |t ur2||d< |t ur:||d< |	t urB|	|d< |
t urJ|
|d	< |t urR||d
< |t urZ||d< | jjjdtj| j  dd| t|| j	 dd}d|j
  krdk rn ntt| S |j
dkrttt| z| }W n ty   t|j
|jdw t|j
|d)  
        Update an existing pipeline for a project.

        Parameters:
            - pipeline_id: str.

            - embedding_config: typing.Optional[PipelineUpdateEmbeddingConfig].

            - transform_config: typing.Optional[PipelineUpdateTransformConfig]. Configuration for the transformation.

            - configured_transformations: typing.Optional[typing.List[ConfiguredTransformationItem]].

            - data_sink_id: typing.Optional[str].

            - embedding_model_config_id: typing.Optional[str].

            - data_sink: typing.Optional[DataSinkCreate].

            - preset_retrieval_parameters: typing.Optional[PresetRetrievalParams].

            - eval_parameters: typing.Optional[EvalExecutionParams].

            - llama_parse_parameters: typing.Optional[LlamaParseParameters].

            - name: typing.Optional[str].

            - managed_pipeline_id: typing.Optional[str].
        ro   rp   rq   rr   rs   rt   ru   rv   rw   rx   ry   re   r<   ri   r>   rU   rA   rB   rC   rD   rE   rF   OMITr.   rJ   rK   rL   rM   rN   rO   r   rP   rG   rQ   rR   r   rU   r	   r   r   r   rV   r0   rg   ro   rp   rq   rr   rs   rt   ru   rv   rw   rx   ry   _requestrX   rY   r1   r1   r2   update_existing_pipeline   sP   ,
z(PipelinesClient.update_existing_pipelinec                 C   s   | j jjdtj| j   dd| | j  dd}d|j  kr(dk r)dS  |jd	kr8t	t
t| z| }W n tyM   t|j|jd
w t|j|d
)a;  
        Delete a pipeline by ID.

        Parameters:
            - pipeline_id: str.
        ---
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.pipelines.delete_pipeline(
            pipeline_id="string",
        )
        DELETEr<   ri   r>   rj   rC   rD   NrE   rF   r.   rJ   rK   rL   rM   rN   rO   rP   rG   r	   rQ   rR   r   rU   r   r   rV   rl   r1   r1   r2   delete_pipeline"  s"   
zPipelinesClient.delete_pipelinec                 C      | j jjdtj| j   dd| d| j  dd}d|j  kr(dk r2n nt	
t| S |jd	krAtt	
t| z| }W n tyV   t|j|jd
w t|j|d
)aJ  
        Get the status of a pipeline by ID.

        Parameters:
            - pipeline_id: str.
        ---
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.pipelines.get_pipeline_status(
            pipeline_id="string",
        )
        r;   r<   ri   /statusr>   rj   rC   rD   rE   rF   r.   rJ   rK   rL   rM   rN   rO   rP   rG   rQ   rR   r   rU   r	   r   r   r   rV   rl   r1   r1   r2   get_pipeline_statusB  s     
z#PipelinesClient.get_pipeline_statusc                 C   r   )
        Run ingestion for the pipeline by incrementally updating the data-sink with upstream changes from data-sources & files.

        Parameters:
            - pipeline_id: str.
        r_   r<   ri   /syncr>   rj   rC   rD   rE   rF   rk   rl   r1   r1   r2   sync_pipelineb       
zPipelinesClient.sync_pipelinec                 C   r   )=
        Parameters:
            - pipeline_id: str.
        r_   r<   ri   /sync/cancelr>   rj   rC   rD   rE   rF   rk   rl   r1   r1   r2   cancel_pipeline_syncy  s$   
z$PipelinesClient.cancel_pipeline_syncc                 C   r   )]
        Copy a pipeline by ID.

        Parameters:
            - pipeline_id: str.
        r_   r<   ri   /copyr>   rj   rC   rD   rE   rF   rk   rl   r1   r1   r2   copy_pipeline  r   zPipelinesClient.copy_pipelinedata_source_idonly_manually_uploadedr   r   c                C   s   | j jjdtj| j   dd| dt||d| j  dd}d|j	  kr.d	k r;n nt
tjt | S |j	d
krJtt
t| z| }W n ty_   t|j	|jdw t|j	|d)a  
        Get files for a pipeline.

        Parameters:
            - pipeline_id: str.

            - data_source_id: typing.Optional[str].

            - only_manually_uploaded: typing.Optional[bool].
        ---
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.pipelines.list_pipeline_files(
            pipeline_id="string",
        )
        r;   r<   ri   /filesr   r>   r?   rC   rD   rE   rF   r.   rJ   rK   rL   rM   rN   rO   r   rP   rG   rQ   rR   rS   rT   r   rU   r	   r   r   r   rV   r0   rg   r   r   rX   rY   r1   r1   r2   list_pipeline_files  s&    	
z#PipelinesClient.list_pipeline_filesc                C      | j jjdtj| j   dd| dt|| j  dd}d|j	  kr+dk r8n nt
tjt | S |j	d	krGtt
t| z| }W n ty\   t|j	|jd
w t|j	|d
)a  
        Add files to a pipeline.

        Parameters:
            - pipeline_id: str.

            - request: typing.List[PipelineFileCreate].
        ---
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.pipelines.add_files_to_pipeline(
            pipeline_id="string",
            request=[],
        )
        re   r<   ri   r   r>   r{   rC   rD   rE   rF   r.   rJ   rK   rL   rM   rN   rO   r   rP   rG   rQ   rR   rS   rT   r   rU   r	   r   r   r   rV   r0   rg   rK   rX   rY   r1   r1   r2   add_files_to_pipeline  s"    
z%PipelinesClient.add_files_to_pipeliner   r   limitoffsetr   r   c             	   C   s   | j jjdtj| j   dd| dt||||d| j  dd}d|j	  kr0d	k r:n nt
t| S |j	d
krItt
t| z| }W n ty^   t|j	|jdw t|j	|d)a  
        Get files for a pipeline.

        Parameters:
            - pipeline_id: str.

            - data_source_id: typing.Optional[str].

            - only_manually_uploaded: typing.Optional[bool].

            - limit: typing.Optional[int].

            - offset: typing.Optional[int].
        ---
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.pipelines.list_pipeline_files_2(
            pipeline_id="string",
        )
        r;   r<   ri   /files2r   r>   r?   rC   rD   rE   rF   r.   rJ   rK   rL   rM   rN   rO   r   rP   rG   rQ   rR   r   rU   r	   r   r   r   rV   r0   rg   r   r   r   r   rX   rY   r1   r1   r2   list_pipeline_files_2  s.     
z%PipelinesClient.list_pipeline_files_2file_idc              
   C      | j jjdtj| j   dd| d| d| j  dd}d|j  kr+d	k r5n nt	
t| S |jd
krDtt	
t| z| }W n tyY   t|j|jdw t|j|d)a  
        Get status of a file for a pipeline.

        Parameters:
            - file_id: str.

            - pipeline_id: str.
        ---
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.pipelines.get_pipeline_file_status(
            file_id="string",
            pipeline_id="string",
        )
        r;   r<   ri   /files/r   r>   rj   rC   rD   rE   rF   r   r0   r   rg   rX   rY   r1   r1   r2   get_pipeline_file_status2  s$   
z(PipelinesClient.get_pipeline_file_statuscustom_metadatar   c             	   C      i }|t ur
||d< | jjjdtj| j  dd| d| t|| j	 dd}d|j
  kr7d	k rAn ntt| S |j
d
krPttt| z| }W n tye   t|j
|jdw t|j
|d)a  
        Update a file for a pipeline.

        Parameters:
            - file_id: str.

            - pipeline_id: str.

            - custom_metadata: typing.Optional[typing.Dict[str, typing.Optional[PipelineFileUpdateCustomMetadataValue]]].
        ---
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.pipelines.update_pipeline_file(
            file_id="string",
            pipeline_id="string",
        )
        r   re   r<   ri   r   r>   r{   rC   rD   rE   rF   r}   r.   rJ   rK   rL   rM   rN   rO   r   rP   rG   rQ   rR   r   rU   r	   r   r   r   rV   r0   r   rg   r   r   rX   rY   r1   r1   r2   update_pipeline_fileW  s,   	
z$PipelinesClient.update_pipeline_filec              	   C      | j jjdtj| j   dd| d| | j  dd}d|j  kr+dk r,d	S  |jd
kr;t	t
t| z| }W n tyP   t|j|jdw t|j|d)a  
        Delete a file from a pipeline.

        Parameters:
            - file_id: str.

            - pipeline_id: str.
        ---
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.pipelines.delete_pipeline_file(
            file_id="string",
            pipeline_id="string",
        )
        r   r<   ri   r   r>   rj   rC   rD   NrE   rF   r   r   r1   r1   r2   delete_pipeline_file  s&   
z$PipelinesClient.delete_pipeline_fileupload_filec                C   s   | j jjdtj| j   dd| dti d|i| j  dd}d|j	  kr.d	k r=n nt
tjttf | S |j	d
krLtt
t| z| }W n tya   t|j	|jdw t|j	|d)
        Import metadata for a pipeline.

        Parameters:
            - pipeline_id: str.

            - upload_file: typing.IO.
        re   r<   ri   	/metadatar   r>   datafilesrA   rB   rC   rD   rE   rF   r.   rJ   rK   rL   rM   rN   rO   r   rP   rG   rQ   rR   rS   DictstrrU   r	   r   r   r   rV   r0   rg   r   rX   rY   r1   r1   r2   import_pipeline_metadata  s$   	 
z(PipelinesClient.import_pipeline_metadatac                 C   s   | j jjdtj| j   dd| d| j  dd}d|j  kr)dk r*d	S  |jd
kr9t	t
t| z| }W n tyN   t|j|jdw t|j|d)a^  
        Delete metadata for all files in a pipeline.

        Parameters:
            - pipeline_id: str.
        ---
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.pipelines.delete_pipeline_files_metadata(
            pipeline_id="string",
        )
        r   r<   ri   r   r>   rj   rC   rD   NrE   rF   r   rl   r1   r1   r2   delete_pipeline_files_metadata  s"    
z.PipelinesClient.delete_pipeline_files_metadatac                 C      | j jjdtj| j   dd| d| j  dd}d|j  kr(dk r5n nt	
tjt | S |jd	krDtt	
t| z| }W n tyY   t|j|jd
w t|j|d
)aN  
        Get data sources for a pipeline.

        Parameters:
            - pipeline_id: str.
        ---
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.pipelines.list_pipeline_data_sources(
            pipeline_id="string",
        )
        r;   r<   ri   /data-sourcesr>   rj   rC   rD   rE   rF   r.   rJ   rK   rL   rM   rN   rO   rP   rG   rQ   rR   rS   rT   r   rU   r	   r   r   r   rV   rl   r1   r1   r2   list_pipeline_data_sources  s$   
z*PipelinesClient.list_pipeline_data_sourcesc                C   r   )a  
        Add data sources to a pipeline.

        Parameters:
            - pipeline_id: str.

            - request: typing.List[PipelineDataSourceCreate].
        ---
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.pipelines.add_data_sources_to_pipeline(
            pipeline_id="string",
            request=[],
        )
        re   r<   ri   r   r>   r{   rC   rD   rE   rF   r.   rJ   rK   rL   rM   rN   rO   r   rP   rG   rQ   rR   rS   rT   r   rU   r	   r   r   r   rV   r   r1   r1   r2   add_data_sources_to_pipeline  &   	
z,PipelinesClient.add_data_sources_to_pipelinesync_intervalr   c             	   C   r   )a  
        Update the configuration of a data source in a pipeline.

        Parameters:
            - data_source_id: str.

            - pipeline_id: str.

            - sync_interval: typing.Optional[float].
        ---
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.pipelines.update_pipeline_data_source(
            data_source_id="string",
            pipeline_id="string",
        )
        r   re   r<   ri   /data-sources/r>   r{   rC   rD   rE   rF   r}   r.   rJ   rK   rL   rM   rN   rO   r   rP   rG   rQ   rR   r   rU   r	   r   r   r   rV   r0   r   rg   r   r   rX   rY   r1   r1   r2   update_pipeline_data_source4  s.   

z+PipelinesClient.update_pipeline_data_sourcec              	   C   r   )a  
        Delete a data source from a pipeline.

        Parameters:
            - data_source_id: str.

            - pipeline_id: str.
        ---
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.pipelines.delete_pipeline_data_source(
            data_source_id="string",
            pipeline_id="string",
        )
        r   r<   ri   r   r>   rj   rC   rD   NrE   rF   r   r0   r   rg   rX   rY   r1   r1   r2   delete_pipeline_data_sourceb  s(   	
z+PipelinesClient.delete_pipeline_data_sourcec              
   C   r   )
        Run ingestion for the pipeline data source by incrementally updating the data-sink with upstream changes from data-source.

        Parameters:
            - data_source_id: str.

            - pipeline_id: str.
        r_   r<   ri   r   r   r>   rj   rC   rD   rE   rF   rk   r   r1   r1   r2   sync_pipeline_data_source  s&   		
z)PipelinesClient.sync_pipeline_data_sourcec              
   C   r   )a  
        Get the status of a data source for a pipeline.

        Parameters:
            - data_source_id: str.

            - pipeline_id: str.
        ---
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.pipelines.get_pipeline_data_source_status(
            data_source_id="string",
            pipeline_id="string",
        )
        r;   r<   ri   r   r   r>   rj   rC   rD   rE   rF   r   r   r1   r1   r2   get_pipeline_data_source_status  &   	
z/PipelinesClient.get_pipeline_data_source_statusdense_similarity_top_kdense_similarity_cutoffsparse_similarity_top_kenable_rerankingrerank_top_nalphasearch_filtersfiles_top_kretrieval_moderetrieve_image_nodes
class_namer   r   r   r   r   r   r   r   r   r   queryr   c                C   sz  d|i}|t ur||d< |t ur||d< |t ur||d< |t ur$||d< |t ur,||d< |t ur4||d< |t ur<||d< |	t urD|	|d	< |
t urL|
|d
< |t urT||d< |t ur\||d< | jjjdtj| j  dd| dt|| j	 dd}d|j
  krdk rn ntt| S |j
dkrttt| z| }W n ty   t|j
|jdw t|j
|d)ai  
        Get retrieval results for a managed pipeline and a query

        Parameters:
            - pipeline_id: str.

            - dense_similarity_top_k: typing.Optional[int].

            - dense_similarity_cutoff: typing.Optional[float].

            - sparse_similarity_top_k: typing.Optional[int].

            - enable_reranking: typing.Optional[bool].

            - rerank_top_n: typing.Optional[int].

            - alpha: typing.Optional[float].

            - search_filters: typing.Optional[MetadataFilters].

            - files_top_k: typing.Optional[int].

            - retrieval_mode: typing.Optional[RetrievalMode]. The retrieval mode for the query.

            - retrieve_image_nodes: typing.Optional[bool]. Whether to retrieve image nodes.

            - query: str. The query to retrieve against.

            - class_name: typing.Optional[str].
        ---
        from llama_cloud import FilterCondition, MetadataFilters, RetrievalMode
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.pipelines.run_search(
            pipeline_id="string",
            search_filters=MetadataFilters(
                filters=[],
                condition=FilterCondition.AND,
            ),
            retrieval_mode=RetrievalMode.CHUNKS,
            query="string",
        )
        r   r   r   r   r   r   r   r   r   r   r   r   r_   r<   ri   	/retriever>   r{   rC   rD   rE   rF   r}   r.   rJ   rK   rL   rM   rN   rO   r   rP   rG   rQ   rR   r"   rU   r	   r   r   r   rV   r0   rg   r   r   r   r   r   r   r   r   r   r   r   r   r   rX   rY   r1   r1   r2   
run_search  sP   ? 
zPipelinesClient.run_searchc                 C   r   )a>  
        Get jobs for a pipeline.

        Parameters:
            - pipeline_id: str.
        ---
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.pipelines.list_pipeline_jobs(
            pipeline_id="string",
        )
        r;   r<   ri   /jobsr>   rj   rC   rD   rE   rF   r.   rJ   rK   rL   rM   rN   rO   rP   rG   rQ   rR   rS   rT   r   rU   r	   r   r   r   rV   rl   r1   r1   r2   list_pipeline_jobs1  s     
z"PipelinesClient.list_pipeline_jobsjob_idc              	   C      | j jjdtj| j   dd| d| | j  dd}d|j  kr*dk r4n nt	
t| S |jd	krCtt	
t| z| }W n tyX   t|j|jd
w t|j|d
)av  
        Get a job for a pipeline.

        Parameters:
            - job_id: str.

            - pipeline_id: str.
        ---
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.pipelines.get_pipeline_job(
            job_id="string",
            pipeline_id="string",
        )
        r;   r<   ri   /jobs/r>   rj   rC   rD   rE   rF   r.   rJ   rK   rL   rM   rN   rO   rP   rG   rQ   rR   r   rU   r	   r   r   r   rV   r0   r   rg   rX   rY   r1   r1   r2   get_pipeline_jobQ  $   
z PipelinesClient.get_pipeline_jobc                 C   r   )a[  
        Get a playground session for a user and pipeline.

        Parameters:
            - pipeline_id: str.
        ---
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.pipelines.get_playground_session(
            pipeline_id="string",
        )
        r;   r<   ri   /playground-sessionr>   rj   rC   rD   rE   rF   r.   rJ   rK   rL   rM   rN   rO   rP   rG   rQ   rR   r   rU   r	   r   r   r   rV   rl   r1   r1   r2   get_playground_sessionv  s$   
z&PipelinesClient.get_playground_sessionmessagesr   r   r   r   c                C   s   i }|t ur
||d< |t ur||d< |t ur||d< | jjjdtj| j  dd| dt|| j	 dd	}d
|j
  krEdk rPn n	ttj| S |j
dkr_ttt| z| }W n tyt   t|j
|jdw t|j
|d)a  
        Make a retrieval query + chat completion for a managed pipeline.

        Parameters:
            - pipeline_id: str.

            - messages: typing.Optional[typing.List[InputMessage]].

            - data: typing.Optional[ChatData].

            - class_name: typing.Optional[str].
        ---
        from llama_cloud import (
            ChatData,
            FilterCondition,
            LlmParameters,
            MetadataFilters,
            PresetRetrievalParams,
            RetrievalMode,
            SupportedLlmModelNames,
        )
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.pipelines.chat(
            pipeline_id="string",
            data=ChatData(
                retrieval_parameters=PresetRetrievalParams(
                    search_filters=MetadataFilters(
                        filters=[],
                        condition=FilterCondition.AND,
                    ),
                    retrieval_mode=RetrievalMode.CHUNKS,
                ),
                llm_parameters=LlmParameters(
                    model_name=SupportedLlmModelNames.GPT_3_5_TURBO,
                ),
            ),
        )
        r   r   r   r_   r<   ri   /chatr>   r{   rC   rD   rE   rF   r}   r.   rJ   rK   rL   rM   rN   rO   r   rP   rG   rQ   rR   rS   AnyrU   r	   r   r   r   rV   r0   rg   r   r   r   r   rX   rY   r1   r1   r2   chat  s0   2 
zPipelinesClient.chatskipr   r   only_direct_uploadonly_api_data_source_documentsr   r   r   c          	   
   C   s   | j jjdtj| j   dd| dt|||||d| j  dd}d|j	  kr1d	k r>n nt
tjt | S |j	d
krMtt
t| z| }W n tyb   t|j	|jdw t|j	|d)aZ  
        Return a list of documents for a pipeline.

        Parameters:
            - pipeline_id: str.

            - skip: typing.Optional[int].

            - limit: typing.Optional[int].

            - file_id: typing.Optional[str].

            - only_direct_upload: typing.Optional[bool].

            - only_api_data_source_documents: typing.Optional[bool].
        ---
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.pipelines.list_pipeline_documents(
            pipeline_id="string",
        )
        r;   r<   ri   
/documentsr   r>   r?   rC   rD   rE   rF   r.   rJ   rK   rL   rM   rN   rO   r   rP   rG   rQ   rR   rS   rT   r   rU   r	   r   r   r   rV   	r0   rg   r   r   r   r   r   rX   rY   r1   r1   r2   list_pipeline_documents  s4   #	
z'PipelinesClient.list_pipeline_documentsc                C   r   )a  
        Batch create documents for a pipeline.

        Parameters:
            - pipeline_id: str.

            - request: typing.List[CloudDocumentCreate].
        ---
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.pipelines.create_batch_pipeline_documents(
            pipeline_id="string",
            request=[],
        )
        r_   r<   ri   r   r>   r{   rC   rD   rE   rF   r.   rJ   rK   rL   rM   rN   rO   r   rP   rG   rQ   rR   rS   rT   r   rU   r	   r   r   r   rV   r   r1   r1   r2   create_batch_pipeline_documents   r   z/PipelinesClient.create_batch_pipeline_documentsc                C   r   )a  
        Batch create or update a document for a pipeline.

        Parameters:
            - pipeline_id: str.

            - request: typing.List[CloudDocumentCreate].
        ---
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.pipelines.upsert_batch_pipeline_documents(
            pipeline_id="string",
            request=[],
        )
        re   r<   ri   r   r>   r{   rC   rD   rE   rF   r   r   r1   r1   r2   upsert_batch_pipeline_documentsH  r   z/PipelinesClient.upsert_batch_pipeline_documentsc          	   
   C   s   | j jjdtj| j   dd| dt|||||d| j  dd}d|j	  kr1d	k r;n nt
t| S |j	d
krJtt
t| z| }W n ty_   t|j	|jdw t|j	|d)ad  
        Return a list of documents for a pipeline.

        Parameters:
            - pipeline_id: str.

            - skip: typing.Optional[int].

            - limit: typing.Optional[int].

            - file_id: typing.Optional[str].

            - only_direct_upload: typing.Optional[bool].

            - only_api_data_source_documents: typing.Optional[bool].
        ---
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.pipelines.paginated_list_pipeline_documents(
            pipeline_id="string",
        )
        r;   r<   ri   /documents/paginatedr   r>   r?   rC   rD   rE   rF   r.   rJ   rK   rL   rM   rN   rO   r   rP   rG   rQ   rR   r   rU   r	   r   r   r   rV   r   r1   r1   r2   !paginated_list_pipeline_documentsp  s4   #	
z1PipelinesClient.paginated_list_pipeline_documentsdocument_idc              	   C   r   )a  
        Return a single document for a pipeline.

        Parameters:
            - document_id: str.

            - pipeline_id: str.
        ---
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.pipelines.get_pipeline_document(
            document_id="string",
            pipeline_id="string",
        )
        r;   r<   ri   /documents/r>   rj   rC   rD   rE   rF   r.   rJ   rK   rL   rM   rN   rO   rP   rG   rQ   rR   r   rU   r	   r   r   r   rV   r0   r  rg   rX   rY   r1   r1   r2   get_pipeline_document  r   z%PipelinesClient.get_pipeline_documentc              	   C   r   )a?  
        Delete a document from a pipeline.
        Initiates an async job that will:

        1. Delete vectors from the vector store
        2. Delete the document from MongoDB after vectors are successfully deleted

        Parameters:
            - document_id: str.

            - pipeline_id: str.
        ---
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.pipelines.delete_pipeline_document(
            document_id="string",
            pipeline_id="string",
        )
        r   r<   ri   r  r>   rj   rC   rD   NrE   rF   r   r  r1   r1   r2   delete_pipeline_document  s&   
z(PipelinesClient.delete_pipeline_documentc              
   C   r   )a  
        Return a single document for a pipeline.

        Parameters:
            - document_id: str.

            - pipeline_id: str.
        ---
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.pipelines.get_pipeline_document_status(
            document_id="string",
            pipeline_id="string",
        )
        r;   r<   ri   r  r   r>   rj   rC   rD   rE   rF   r   r  r1   r1   r2   get_pipeline_document_status  r   z,PipelinesClient.get_pipeline_document_statusc              
   C   s   | j jjdtj| j   dd| d| d| j  dd}d|j  kr+d	k r8n nt	
tjt | S |jd
krGtt	
t| z| }W n ty\   t|j|jdw t|j|d)a  
        Return a list of chunks for a pipeline document.

        Parameters:
            - document_id: str.

            - pipeline_id: str.
        ---
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.pipelines.list_pipeline_document_chunks(
            document_id="string",
            pipeline_id="string",
        )
        r;   r<   ri   r  /chunksr>   rj   rC   rD   rE   rF   r.   rJ   rK   rL   rM   rN   rO   rP   rG   rQ   rR   rS   rT   r#   rU   r	   r   r   r   rV   r  r1   r1   r2   list_pipeline_document_chunks"  s&   	
z-PipelinesClient.list_pipeline_document_chunks)Q__name__
__module____qualname__r   r3   rS   Optionalr   r   rT   r   rZ   r   rc   rf   rm   r}   r&   r'   r   r   r    r   r   r   r   r   r   r   r   r   boolr   r   r   r   intr   r   r   r   r%   r   r   IOr   r   r   r   r   r   floatr   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  r	  r#   r  r1   r1   r1   r2   r)   6   s   
9
&
$	

T  
-
*
8,
3"% "
)
.&*	

g %&
N	
>
(
,	
>%) &r)   c                   @   r(   )AsyncPipelinesClientr*   c                C   r+   r,   r-   r/   r1   r1   r2   r3   J  r4   zAsyncPipelinesClient.__init__Nr5   r6   r7   r8   r9   r:   c             	      s   | j jjdtj| j   ddt||||d| j  ddI dH }d|j	  kr0d	k r=n nt
tjt | S |j	d
krLtt
t| z| }W n tya   t|j	|jdw t|j	|d)aQ  
        Search for pipelines by various parameters.

        Parameters:
            - project_id: typing.Optional[str].

            - project_name: typing.Optional[str].

            - pipeline_name: typing.Optional[str].

            - pipeline_type: typing.Optional[PipelineType].
        ---
        from llama_cloud import PipelineType
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.pipelines.search_pipelines(
            pipeline_type=PipelineType.PLAYGROUND,
        )
        r;   r<   r=   r5   r>   r?   NrC   rD   rE   rF   rI   rW   r1   r1   r2   rZ   M  s0   
z%AsyncPipelinesClient.search_pipelinesr[   r\   rK   c                      | j jjdtj| j   ddt||dt|| j 	 ddI dH }d|j
  kr1d	k r;n ntt| S |j
d
krJttt| z| }W n ty_   t|j
|jdw t|j
|d)r^   r_   r<   r=   r[   r>   r`   NrC   rD   rE   rF   ra   rb   r1   r1   r2   rc     s&   
z$AsyncPipelinesClient.create_pipelinec                   r  )rd   re   r<   r=   r[   r>   r`   NrC   rD   rE   rF   ra   rb   r1   r1   r2   rf     s&   
z$AsyncPipelinesClient.upsert_pipelinerg   c                    s   | j jjdtj| j   dd| | j  ddI dH }d|j  kr+dk r5n nt	
t| S |jd	krDtt	
t| z| }W n tyY   t|j|jd
w t|j|d
)rh   r;   r<   ri   r>   rj   NrC   rD   rE   rF   rk   rl   r1   r1   r2   rm     s"   
z!AsyncPipelinesClient.get_pipelinern   ro   rp   rq   rr   rs   rt   ru   rv   rw   rx   ry   c                   s|  i }|t ur||d< |t ur||d< |t ur||d< |t ur#||d< |t ur+||d< |t ur3||d< |t ur;||d< |	t urC|	|d< |
t urK|
|d	< |t urS||d
< |t ur[||d< | jjjdtj| j  dd| t|| j	 ddI dH }d|j
  krdk rn ntt| S |j
dkrttt| z| }W n ty   t|j
|jdw t|j
|d)rz   ro   rp   rq   rr   rs   rt   ru   rv   rw   rx   ry   re   r<   ri   r>   r{   NrC   rD   rE   rF   r|   r~   r1   r1   r2   r     sR   ,
z-AsyncPipelinesClient.update_existing_pipelinec                    s   | j jjdtj| j   dd| | j  ddI dH }d|j  kr,dk r-dS  |jd	kr<t	t
t| z| }W n tyQ   t|j|jd
w t|j|d
)aK  
        Delete a pipeline by ID.

        Parameters:
            - pipeline_id: str.
        ---
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.pipelines.delete_pipeline(
            pipeline_id="string",
        )
        r   r<   ri   r>   rj   NrC   rD   rE   rF   r   rl   r1   r1   r2   r   5  s$   
z$AsyncPipelinesClient.delete_pipelinec                       | j jjdtj| j   dd| d| j  ddI dH }d|j  kr,d	k r6n nt	
t| S |jd
krEtt	
t| z| }W n tyZ   t|j|jdw t|j|d)aZ  
        Get the status of a pipeline by ID.

        Parameters:
            - pipeline_id: str.
        ---
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.pipelines.get_pipeline_status(
            pipeline_id="string",
        )
        r;   r<   ri   r   r>   rj   NrC   rD   rE   rF   r   rl   r1   r1   r2   r   U  s"    
z(AsyncPipelinesClient.get_pipeline_statusc                    r  )r   r_   r<   ri   r   r>   rj   NrC   rD   rE   rF   rk   rl   r1   r1   r2   r   u  "    
z"AsyncPipelinesClient.sync_pipelinec                    r  )r   r_   r<   ri   r   r>   rj   NrC   rD   rE   rF   rk   rl   r1   r1   r2   r     s&   
z)AsyncPipelinesClient.cancel_pipeline_syncc                    r  )r   r_   r<   ri   r   r>   rj   NrC   rD   rE   rF   rk   rl   r1   r1   r2   r     r  z"AsyncPipelinesClient.copy_pipeliner   r   r   c                   s   | j jjdtj| j   dd| dt||d| j  ddI dH }d	|j	  kr2d
k r?n nt
tjt | S |j	dkrNtt
t| z| }W n tyc   t|j	|jdw t|j	|d)a  
        Get files for a pipeline.

        Parameters:
            - pipeline_id: str.

            - data_source_id: typing.Optional[str].

            - only_manually_uploaded: typing.Optional[bool].
        ---
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.pipelines.list_pipeline_files(
            pipeline_id="string",
        )
        r;   r<   ri   r   r   r>   r?   NrC   rD   rE   rF   r   r   r1   r1   r2   r     s(    	
z(AsyncPipelinesClient.list_pipeline_filesc                      | j jjdtj| j   dd| dt|| j  ddI dH }d|j	  kr/d	k r<n nt
tjt | S |j	d
krKtt
t| z| }W n ty`   t|j	|jdw t|j	|d)a  
        Add files to a pipeline.

        Parameters:
            - pipeline_id: str.

            - request: typing.List[PipelineFileCreate].
        ---
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.pipelines.add_files_to_pipeline(
            pipeline_id="string",
            request=[],
        )
        re   r<   ri   r   r>   r{   NrC   rD   rE   rF   r   r   r1   r1   r2   r     s$    
z*AsyncPipelinesClient.add_files_to_pipeliner   r   r   c             	      s   | j jjdtj| j   dd| dt||||d| j  ddI dH }d	|j	  kr4d
k r>n nt
t| S |j	dkrMtt
t| z| }W n tyb   t|j	|jdw t|j	|d)a  
        Get files for a pipeline.

        Parameters:
            - pipeline_id: str.

            - data_source_id: typing.Optional[str].

            - only_manually_uploaded: typing.Optional[bool].

            - limit: typing.Optional[int].

            - offset: typing.Optional[int].
        ---
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.pipelines.list_pipeline_files_2(
            pipeline_id="string",
        )
        r;   r<   ri   r   r   r>   r?   NrC   rD   rE   rF   r   r   r1   r1   r2   r     s0     
z*AsyncPipelinesClient.list_pipeline_files_2r   c              
         | j jjdtj| j   dd| d| d| j  ddI dH }d	|j  kr/d
k r9n nt	
t| S |jdkrHtt	
t| z| }W n ty]   t|j|jdw t|j|d)a  
        Get status of a file for a pipeline.

        Parameters:
            - file_id: str.

            - pipeline_id: str.
        ---
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.pipelines.get_pipeline_file_status(
            file_id="string",
            pipeline_id="string",
        )
        r;   r<   ri   r   r   r>   rj   NrC   rD   rE   rF   r   r   r1   r1   r2   r   E  s&   
z-AsyncPipelinesClient.get_pipeline_file_statusr   r   c             	         i }|t ur||d< | jjjdtj| j  dd| d| t|| j	 ddI dH }d	|j
  kr;d
k rEn ntt| S |j
dkrTttt| z| }W n tyi   t|j
|jdw t|j
|d)a  
        Update a file for a pipeline.

        Parameters:
            - file_id: str.

            - pipeline_id: str.

            - custom_metadata: typing.Optional[typing.Dict[str, typing.Optional[PipelineFileUpdateCustomMetadataValue]]].
        ---
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.pipelines.update_pipeline_file(
            file_id="string",
            pipeline_id="string",
        )
        r   re   r<   ri   r   r>   r{   NrC   rD   rE   rF   r   r   r1   r1   r2   r   j  s.   	
z)AsyncPipelinesClient.update_pipeline_filec              	         | j jjdtj| j   dd| d| | j  ddI dH }d|j  kr/d	k r0dS  |jd
kr?t	t
t| z| }W n tyT   t|j|jdw t|j|d)a  
        Delete a file from a pipeline.

        Parameters:
            - file_id: str.

            - pipeline_id: str.
        ---
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.pipelines.delete_pipeline_file(
            file_id="string",
            pipeline_id="string",
        )
        r   r<   ri   r   r>   rj   NrC   rD   rE   rF   r   r   r1   r1   r2   r     s(   
z)AsyncPipelinesClient.delete_pipeline_filer   c                   s   | j jjdtj| j   dd| dti d|i| j  ddI dH }d	|j	  kr2d
k rAn nt
tjttf | S |j	dkrPtt
t| z| }W n tye   t|j	|jdw t|j	|d)r   re   r<   ri   r   r   r>   r   NrC   rD   rE   rF   r   r   r1   r1   r2   r     s&   	 
z-AsyncPipelinesClient.import_pipeline_metadatac                    s   | j jjdtj| j   dd| d| j  ddI dH }d|j  kr-d	k r.dS  |jd
kr=t	t
t| z| }W n tyR   t|j|jdw t|j|d)an  
        Delete metadata for all files in a pipeline.

        Parameters:
            - pipeline_id: str.
        ---
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.pipelines.delete_pipeline_files_metadata(
            pipeline_id="string",
        )
        r   r<   ri   r   r>   rj   NrC   rD   rE   rF   r   rl   r1   r1   r2   r     s$    
z3AsyncPipelinesClient.delete_pipeline_files_metadatac                       | j jjdtj| j   dd| d| j  ddI dH }d|j  kr,d	k r9n nt	
tjt | S |jd
krHtt	
t| z| }W n ty]   t|j|jdw t|j|d)a^  
        Get data sources for a pipeline.

        Parameters:
            - pipeline_id: str.
        ---
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.pipelines.list_pipeline_data_sources(
            pipeline_id="string",
        )
        r;   r<   ri   r   r>   rj   NrC   rD   rE   rF   r   rl   r1   r1   r2   r     s&   
z/AsyncPipelinesClient.list_pipeline_data_sourcesc                   r  )a  
        Add data sources to a pipeline.

        Parameters:
            - pipeline_id: str.

            - request: typing.List[PipelineDataSourceCreate].
        ---
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.pipelines.add_data_sources_to_pipeline(
            pipeline_id="string",
            request=[],
        )
        re   r<   ri   r   r>   r{   NrC   rD   rE   rF   r   r   r1   r1   r2   r   	  (   	
z1AsyncPipelinesClient.add_data_sources_to_pipeliner   r   c             	      r  )a  
        Update the configuration of a data source in a pipeline.

        Parameters:
            - data_source_id: str.

            - pipeline_id: str.

            - sync_interval: typing.Optional[float].
        ---
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.pipelines.update_pipeline_data_source(
            data_source_id="string",
            pipeline_id="string",
        )
        r   re   r<   ri   r   r>   r{   NrC   rD   rE   rF   r   r   r1   r1   r2   r   G	  s0   

z0AsyncPipelinesClient.update_pipeline_data_sourcec              	      r  )a  
        Delete a data source from a pipeline.

        Parameters:
            - data_source_id: str.

            - pipeline_id: str.
        ---
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.pipelines.delete_pipeline_data_source(
            data_source_id="string",
            pipeline_id="string",
        )
        r   r<   ri   r   r>   rj   NrC   rD   rE   rF   r   r   r1   r1   r2   r   u	  s*   	
z0AsyncPipelinesClient.delete_pipeline_data_sourcec              
      r  )r   r_   r<   ri   r   r   r>   rj   NrC   rD   rE   rF   rk   r   r1   r1   r2   r   	  s(   		
z.AsyncPipelinesClient.sync_pipeline_data_sourcec              
      r  )a  
        Get the status of a data source for a pipeline.

        Parameters:
            - data_source_id: str.

            - pipeline_id: str.
        ---
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.pipelines.get_pipeline_data_source_status(
            data_source_id="string",
            pipeline_id="string",
        )
        r;   r<   ri   r   r   r>   rj   NrC   rD   rE   rF   r   r   r1   r1   r2   r   	  s(   	
z4AsyncPipelinesClient.get_pipeline_data_source_statusr   r   r   r   r   r   r   r   r   r   r   r   r   c                   s  d|i}|t ur||d< |t ur||d< |t ur||d< |t ur%||d< |t ur-||d< |t ur5||d< |t ur=||d< |	t urE|	|d	< |
t urM|
|d
< |t urU||d< |t ur]||d< | jjjdtj| j  dd| dt|| j	 ddI dH }d|j
  krdk rn ntt| S |j
dkrttt| z| }W n ty   t|j
|jdw t|j
|d)ay  
        Get retrieval results for a managed pipeline and a query

        Parameters:
            - pipeline_id: str.

            - dense_similarity_top_k: typing.Optional[int].

            - dense_similarity_cutoff: typing.Optional[float].

            - sparse_similarity_top_k: typing.Optional[int].

            - enable_reranking: typing.Optional[bool].

            - rerank_top_n: typing.Optional[int].

            - alpha: typing.Optional[float].

            - search_filters: typing.Optional[MetadataFilters].

            - files_top_k: typing.Optional[int].

            - retrieval_mode: typing.Optional[RetrievalMode]. The retrieval mode for the query.

            - retrieve_image_nodes: typing.Optional[bool]. Whether to retrieve image nodes.

            - query: str. The query to retrieve against.

            - class_name: typing.Optional[str].
        ---
        from llama_cloud import FilterCondition, MetadataFilters, RetrievalMode
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.pipelines.run_search(
            pipeline_id="string",
            search_filters=MetadataFilters(
                filters=[],
                condition=FilterCondition.AND,
            ),
            retrieval_mode=RetrievalMode.CHUNKS,
            query="string",
        )
        r   r   r   r   r   r   r   r   r   r   r   r   r_   r<   ri   r   r>   r{   NrC   rD   rE   rF   r   r   r1   r1   r2   r   	  sR   ? 
zAsyncPipelinesClient.run_searchc                    r  )aN  
        Get jobs for a pipeline.

        Parameters:
            - pipeline_id: str.
        ---
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.pipelines.list_pipeline_jobs(
            pipeline_id="string",
        )
        r;   r<   ri   r   r>   rj   NrC   rD   rE   rF   r   rl   r1   r1   r2   r   F
  s"    
z'AsyncPipelinesClient.list_pipeline_jobsr   c              	         | j jjdtj| j   dd| d| | j  ddI dH }d|j  kr.d	k r8n nt	
t| S |jd
krGtt	
t| z| }W n ty\   t|j|jdw t|j|d)a  
        Get a job for a pipeline.

        Parameters:
            - job_id: str.

            - pipeline_id: str.
        ---
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.pipelines.get_pipeline_job(
            job_id="string",
            pipeline_id="string",
        )
        r;   r<   ri   r   r>   rj   NrC   rD   rE   rF   r   r   r1   r1   r2   r   f
  &   
z%AsyncPipelinesClient.get_pipeline_jobc                    r  )ak  
        Get a playground session for a user and pipeline.

        Parameters:
            - pipeline_id: str.
        ---
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.pipelines.get_playground_session(
            pipeline_id="string",
        )
        r;   r<   ri   r   r>   rj   NrC   rD   rE   rF   r   rl   r1   r1   r2   r   
  s&   
z+AsyncPipelinesClient.get_playground_sessionr   r   r   c                   s   i }|t ur||d< |t ur||d< |t ur||d< | jjjdtj| j  dd| dt|| j	 dd	I d
H }d|j
  krIdk rTn n	ttj| S |j
dkrcttt| z| }W n tyx   t|j
|jdw t|j
|d)a  
        Make a retrieval query + chat completion for a managed pipeline.

        Parameters:
            - pipeline_id: str.

            - messages: typing.Optional[typing.List[InputMessage]].

            - data: typing.Optional[ChatData].

            - class_name: typing.Optional[str].
        ---
        from llama_cloud import (
            ChatData,
            FilterCondition,
            LlmParameters,
            MetadataFilters,
            PresetRetrievalParams,
            RetrievalMode,
            SupportedLlmModelNames,
        )
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.pipelines.chat(
            pipeline_id="string",
            data=ChatData(
                retrieval_parameters=PresetRetrievalParams(
                    search_filters=MetadataFilters(
                        filters=[],
                        condition=FilterCondition.AND,
                    ),
                    retrieval_mode=RetrievalMode.CHUNKS,
                ),
                llm_parameters=LlmParameters(
                    model_name=SupportedLlmModelNames.GPT_3_5_TURBO,
                ),
            ),
        )
        r   r   r   r_   r<   ri   r   r>   r{   NrC   rD   rE   rF   r   r   r1   r1   r2   r   
  s2   2 
zAsyncPipelinesClient.chatr   r   r   r   c          	   
      s   | j jjdtj| j   dd| dt|||||d| j  ddI dH }d	|j	  kr5d
k rBn nt
tjt | S |j	dkrQtt
t| z| }W n tyf   t|j	|jdw t|j	|d)aj  
        Return a list of documents for a pipeline.

        Parameters:
            - pipeline_id: str.

            - skip: typing.Optional[int].

            - limit: typing.Optional[int].

            - file_id: typing.Optional[str].

            - only_direct_upload: typing.Optional[bool].

            - only_api_data_source_documents: typing.Optional[bool].
        ---
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.pipelines.list_pipeline_documents(
            pipeline_id="string",
        )
        r;   r<   ri   r   r   r>   r?   NrC   rD   rE   rF   r   r   r1   r1   r2   r   
  s6   #	
z,AsyncPipelinesClient.list_pipeline_documentsc                   r  )a  
        Batch create documents for a pipeline.

        Parameters:
            - pipeline_id: str.

            - request: typing.List[CloudDocumentCreate].
        ---
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.pipelines.create_batch_pipeline_documents(
            pipeline_id="string",
            request=[],
        )
        r_   r<   ri   r   r>   r{   NrC   rD   rE   rF   r   r   r1   r1   r2   r   5  r  z4AsyncPipelinesClient.create_batch_pipeline_documentsc                   r  )a  
        Batch create or update a document for a pipeline.

        Parameters:
            - pipeline_id: str.

            - request: typing.List[CloudDocumentCreate].
        ---
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.pipelines.upsert_batch_pipeline_documents(
            pipeline_id="string",
            request=[],
        )
        re   r<   ri   r   r>   r{   NrC   rD   rE   rF   r   r   r1   r1   r2   r   ]  r  z4AsyncPipelinesClient.upsert_batch_pipeline_documentsc          	   
      s   | j jjdtj| j   dd| dt|||||d| j  ddI dH }d	|j	  kr5d
k r?n nt
t| S |j	dkrNtt
t| z| }W n tyc   t|j	|jdw t|j	|d)at  
        Return a list of documents for a pipeline.

        Parameters:
            - pipeline_id: str.

            - skip: typing.Optional[int].

            - limit: typing.Optional[int].

            - file_id: typing.Optional[str].

            - only_direct_upload: typing.Optional[bool].

            - only_api_data_source_documents: typing.Optional[bool].
        ---
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.pipelines.paginated_list_pipeline_documents(
            pipeline_id="string",
        )
        r;   r<   ri   r   r   r>   r?   NrC   rD   rE   rF   r  r   r1   r1   r2   r    s6   #	
z6AsyncPipelinesClient.paginated_list_pipeline_documentsr  c              	      r  )a  
        Return a single document for a pipeline.

        Parameters:
            - document_id: str.

            - pipeline_id: str.
        ---
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.pipelines.get_pipeline_document(
            document_id="string",
            pipeline_id="string",
        )
        r;   r<   ri   r  r>   rj   NrC   rD   rE   rF   r  r  r1   r1   r2   r    r   z*AsyncPipelinesClient.get_pipeline_documentc              	      r  )aO  
        Delete a document from a pipeline.
        Initiates an async job that will:

        1. Delete vectors from the vector store
        2. Delete the document from MongoDB after vectors are successfully deleted

        Parameters:
            - document_id: str.

            - pipeline_id: str.
        ---
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.pipelines.delete_pipeline_document(
            document_id="string",
            pipeline_id="string",
        )
        r   r<   ri   r  r>   rj   NrC   rD   rE   rF   r   r  r1   r1   r2   r    s(   
z-AsyncPipelinesClient.delete_pipeline_documentc              
      r  )a  
        Return a single document for a pipeline.

        Parameters:
            - document_id: str.

            - pipeline_id: str.
        ---
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.pipelines.get_pipeline_document_status(
            document_id="string",
            pipeline_id="string",
        )
        r;   r<   ri   r  r   r>   rj   NrC   rD   rE   rF   r   r  r1   r1   r2   r	    s(   	
z1AsyncPipelinesClient.get_pipeline_document_statusc              
      s   | j jjdtj| j   dd| d| d| j  ddI dH }d	|j  kr/d
k r<n nt	
tjt | S |jdkrKtt	
t| z| }W n ty`   t|j|jdw t|j|d)a  
        Return a list of chunks for a pipeline document.

        Parameters:
            - document_id: str.

            - pipeline_id: str.
        ---
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.pipelines.list_pipeline_document_chunks(
            document_id="string",
            pipeline_id="string",
        )
        r;   r<   ri   r  r
  r>   rj   NrC   rD   rE   rF   r  r  r1   r1   r2   r  7  s(   	
z2AsyncPipelinesClient.list_pipeline_document_chunks)Qr  r  r  r   r3   rS   r  r   r   rT   r   rZ   r   rc   rf   rm   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   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   r
   r   r   r   r   r   r   r   r   r  r  r  r	  r#   r  r1   r1   r1   r2   r  I  s(   
9
&
$	

T  
-
*
8,
3"% "
)
.&
,	

g %&
N	
>
(
,	
>%) &r  )UrS   urllib.parserL   json.decoderr   core.api_errorr   core.client_wrapperr   r   core.jsonable_encoderr   core.remove_none_from_dictr   !errors.unprocessable_entity_errorr	   types.chat_datar
   types.cloud_documentr   types.cloud_document_creater   $types.configured_transformation_itemr   types.data_sink_creater   types.eval_execution_paramsr   types.http_validation_errorr   types.input_messager   types.llama_parse_parametersr   'types.managed_ingestion_status_responser   types.metadata_filtersr   -types.paginated_list_cloud_documents_responser   ,types.paginated_list_pipeline_files_responser   types.pipeliner   types.pipeline_creater   types.pipeline_data_sourcer   !types.pipeline_data_source_creater   types.pipeline_deploymentr   types.pipeline_filer   types.pipeline_file_creater   types.pipeline_typer   types.playground_sessionr   types.preset_retrieval_paramsr    types.retrieval_moder!   types.retrieve_resultsr"   types.text_noder#   0types.pipeline_file_update_custom_metadata_valuer%   &types.pipeline_update_embedding_configr&   &types.pipeline_update_transform_configr'   rQ   __version__
startswithImportErrorpydantic.v1v1castr   r}   r)   r  r1   r1   r1   r2   <module>   sx               