Skip to main content

create_file

Reads an uploaded file and returns a File object. Parameters:
  • file (BytesIO): A BytesIO object representing the contents of the file.
  • filename (str): The name of the file.
Returns: File: A File object.

create_file_from_raw_bytes

Reads raw bytes and returns a File object. Parameters:
  • raw_bytes (bytes): The raw bytes content of the file.
  • filename (str): The name of the file.
Returns: File: A File object.

File

Represents an uploaded file comprised of Documents. Parameters:
  • name (str): The name of the file.
  • file_id (str): The unique identifier of the file.
  • metadata (Dict[str, Any], optional): Additional metadata associated with the file. Defaults to None.
  • docs (List[Dict[str, Any]], optional): A list of documents contained within the file. Defaults to None.
  • raw_bytes (bytes, optional): The raw bytes content of the file. Defaults to b"".

init

from_bytes

Creates a File object from a BytesIO object. Parameters:
  • file (BytesIO): A BytesIO object representing the contents of the file.
  • filename (str): The name of the file.
Returns: File: A File object.

from_raw_bytes

Creates a File object from raw bytes. Parameters:
  • raw_bytes (bytes): The raw bytes content of the file.
  • filename (str): The name of the file.
Returns: File: A File object.

repr

str

copy

Create a deep copy of this File

strip_consecutive_newlines

Strips consecutive newlines from a string. Parameters:
  • text (str): The string to strip.
Returns: str: The string with consecutive newlines stripped.

DocxFile

from_bytes

Creates a DocxFile object from a BytesIO object. Parameters:
  • file (BytesIO): A BytesIO object representing the contents of the docx file.
  • filename (str): The name of the file.
Returns: DocxFile: A DocxFile object.

PdfFile

from_bytes

Creates a PdfFile object from a BytesIO object. Parameters:
  • file (BytesIO): A BytesIO object representing the contents of the pdf file.
  • filename (str): The name of the file.
Returns: PdfFile: A PdfFile object.

TxtFile

from_bytes

Creates a TxtFile object from a BytesIO object. Parameters:
  • file (BytesIO): A BytesIO object representing the contents of the txt file.
  • filename (str): The name of the file.
Returns: TxtFile: A TxtFile object.

JsonFile

from_bytes

Creates a JsonFile object from a BytesIO object. Parameters:
  • file (BytesIO): A BytesIO object representing the contents of the json file.
  • filename (str): The name of the file.
Returns: JsonFile: A JsonFile object.

HtmlFile

from_bytes

Creates a HtmlFile object from a BytesIO object. Parameters:
  • file (BytesIO): A BytesIO object representing the contents of the html file.
  • filename (str): The name of the file.
Returns: HtmlFile: A HtmlFile object.