
    Ngn                     V    d Z ddlmZ ddlmZmZmZ ddlmZm	Z	  G d de          Z
dS )zLoads rich text files.    )Path)AnyListUnion)UnstructuredFileLoader"satisfies_min_unstructured_versionc                   P     e Zd ZdZ	 d	deeef         dedef fdZde	fdZ
 xZS )
UnstructuredRTFLoadera  Load `RTF` files using `Unstructured`.

    You can run the loader in one of two modes: "single" and "elements".
    If you use "single" mode, the document will be returned as a single
    langchain Document object. If you use "elements" mode, the unstructured
    library will split the document into elements such as Title and NarrativeText.
    You can pass in additional unstructured kwargs after mode to apply
    different unstructured settings.

    Examples
    --------
    from langchain_community.document_loaders import UnstructuredRTFLoader

    loader = UnstructuredRTFLoader(
        "example.rtf", mode="elements", strategy="fast",
    )
    docs = loader.load()

    References
    ----------
    https://unstructured-io.github.io/unstructured/bricks.html#partition-rtf
    single	file_pathmodeunstructured_kwargsc                     d}t          |          st          d| d           t                      j        d||d| dS )aS  
        Initialize with a file path.

        Args:
            file_path: The path to the file to load.
            mode: The mode to use for partitioning. See unstructured for details.
                Defaults to "single".
            **unstructured_kwargs: Additional keyword arguments to pass
                to unstructured.
        z0.5.12z:Partitioning rtf files is only supported in unstructured>=.)r   r   N )r   
ValueErrorsuper__init__)selfr   r   r   min_unstructured_version	__class__s        d/var/www/html/ai-engine/env/lib/python3.11/site-packages/langchain_community/document_loaders/rtf.pyr   zUnstructuredRTFLoader.__init__$   sr      $, 12JKK 	=!9= = =  
 	O94OO;NOOOOO    returnc                 6    ddl m}  |dd| j        i| j        S )Nr   )partition_rtffilenamer   )unstructured.partition.rtfr   r   r   )r   r   s     r   _get_elementsz#UnstructuredRTFLoader._get_elements=   s4    <<<<<<}QQdnQ8PQQQr   )r   )__name__
__module____qualname____doc__r   strr   r   r   r   r   __classcell__)r   s   @r   r
   r
      s         4 P Pd#P P  #	P P P P P P2Rt R R R R R R R Rr   r
   N)r#   pathlibr   typingr   r   r   1langchain_community.document_loaders.unstructuredr   r   r
   r   r   r   <module>r)      s            # # # # # # # # # #       4R 4R 4R 4R 4R2 4R 4R 4R 4R 4Rr   