Undocumented
Method | __init__ |
Initializes a FlatFileDB instance (inherits from qAApDB), which manages data in text files using a structured folder hierarchy. |
Method | add |
Writes a new attribute to the <attribute>.txt file. If there is an error writing to the file, it raises a WriteInDatabaseError. |
Method | attribute |
Checks if a attribute exists. |
Method | comment |
Checks if a note for the specified document by the specified note_title exists. |
Method | get |
Retrieves data from all public Document files. |
Method | get |
Retrieves the specified attribute values. |
Method | get |
Retrieves the catalog. |
Method | get |
Retrieves the content and icon of a specified document. |
Method | get |
Retrieves the base64-encoded images for a specified document. Returns an empty list if there are no images. |
Method | get |
Retrieves the base64-encoded images for a specified note of a document. Returns an empty list if there are no images. |
Method | get |
Retrieves all notes for a specified document. If perpage is greater than 0, it returns only the notes for the specified page (0-indexed). If perpage less than 1, it returns all notes. Returns an empty list if there are no notes. |
Method | get |
Retrieves the vector store as binary from a file. |
Method | post |
Checks if a directory for the specified document exists. |
Method | write |
Writes new content in the <attributes>.txt file. If there is an error writing to the file, it raises a WriteInDatabaseError. |
Method | write |
Writes the catalog to a JSON file. |
Method | write |
Writes a note for a specified document by a specified note_title. It creates a directory for the note, writes the note content to a text file, saves the note icon as a PNG file, and saves screenshots as PNG files... |
Method | write |
Writes a new document to the database. It creates a directory for the document, writes the document content to a text file, saves the icon as a PNG file, and saves screenshots as PNG files. If the document already exists, it raises a FileAlreadyExistsError... |
Method | write |
Writes the binary representation of a vectorstore in a file. |
Instance Variable | root |
Undocumented |
Method | _setup |
Initializes the required database folder structure and files. |
Initializes a FlatFileDB instance (inherits from qAApDB), which manages data in text files using a structured folder hierarchy. Args: root (str): The root directory path where the folder hierarchy will be created. All data files and subdirectories will be stored under this path.
Writes a new attribute to the <attribute>.txt file. If there is an error writing to the file, it raises a WriteInDatabaseError. Args: attribute (str): Name of the attribute to write. data (str): The new attribute value to write. Returns: bool: True if the write operation was successful Raises: FileAlreadyExistsError: If the attribute already exists. WriteInDatabaseError: If there is an error writing to the file.
qA_Ap.db.qaapdb.qaapDB.attribute_exists
Checks if a attribute exists. Args: attribute (str): Name of the attribute to check. Returns: bool: True if the attribute exists, False otherwise. Raises: FileNotFoundError: If the <attribute>.txt file does not exist.
qA_Ap.db.qaapdb.qaapDB.comment_exists
Checks if a note for the specified document by the specified note_title exists. Args: post_title (str): Name of the document. note_title (str): Name of the note_title. Returns: bool: True if the note exists, False otherwise.
Retrieves data from all public Document files. This method scans the 'documents' directory for files named 'document.txt', reads their content, and compiles the data into a list of dictionaries. Each dictionary contains the content of a Document file and the Document name. Returns: list[dict[str,str]]: A list of dictionaries where each dictionary contains: - "page_content": The content of the document file. - "title": The name of the directory containing the document file. i.e. the document title
Retrieves the specified attribute values. Returns: str: The attribute name Raises: FileNotFoundError: If the <attribute>.txt file does not exist.
qA_Ap.db.qaapdb.qaapDB.get_catalog
Retrieves the catalog. Returns: str: JSON string representing the catalog. Raises: FileNotFoundError: If the catalog.json file does not exist.
qA_Ap.db.qaapdb.qaapDB.get_document
Retrieves the content and icon of a specified document. Args: post_title (str): Name of the document to retrieve. Returns: tuple[str,str]: A tuple containing the document content (and the icon in base64 format if it exists or an empty string). Raises: FileNotFoundError: If the document does not exist or if the document.txt is missing.
Retrieves the base64-encoded images for a specified document. Returns an empty list if there are no images. Args: post_title (str): Name of the document. includes (list[str]): List of image file stems to include (e.g., ["screen1", "screen2"]). Returns: list[str]: A list of base64-encoded images for the document. Raises: FileNotFoundError: If the document does not exist.
str
, note_title: str
, includes: list[ str]
= None) -> list[ str]
:
¶
qA_Ap.db.qaapdb.qaapDB.get_note_medias
Retrieves the base64-encoded images for a specified note of a document. Returns an empty list if there are no images. Args: post_title (str): Name of the document. note_title (str): Name of the note_title. includes (list[str]): List of image file stems to include (e.g., ["screen1", "screen2"]). Returns: list[str]: A list of base64-encoded images for the note. Raises: FileNotFoundError: If the note does not exist.
str
, perpage: int
= 0, page: int
= 0) -> list[ tuple[ str, str, str]]
:
¶
Retrieves all notes for a specified document. If perpage is greater than 0, it returns only the notes for the specified page (0-indexed). If perpage less than 1, it returns all notes. Returns an empty list if there are no notes. Args: post_title (str): Name of the document to retrieve notes for. perpage (int): Number of notes per page. Default is 0 (all notes). page (int): Page number to retrieve (0-indexed). Default is 0. Returns: list[tuple[str,str,str]]: A list of tuples, each containing: - The note content as a string. - The note_title name as a string. - The document name as a string. Raises: FileNotFoundError: If the document does not exist or if there are no notes.
qA_Ap.db.qaapdb.qaapDB.get_vector_store
Retrieves the vector store as binary from a file. Returns: bytes: The bytes representation of the vectorstore. Raises: FileNotFoundError: If the file is not found or any other exception occurs during the file read operation.
qA_Ap.db.qaapdb.qaapDB.post_exists
Checks if a directory for the specified document exists. Args: post_title (str): Name of the document to check. Returns: bool: True if the document exists, False otherwise.
qA_Ap.db.qaapdb.qaapDB.write_attribute
Writes new content in the <attributes>.txt file. If there is an error writing to the file, it raises a WriteInDatabaseError. Args: attribute (str): The attribute name data (str): The list of attributes to write. One attribute per line. Returns: bool: True if the write operation was successful Raises: WriteInDatabaseError: If there is an error writing to the file.
qA_Ap.db.qaapdb.qaapDB.write_catalog
Writes the catalog to a JSON file. Args: json (str): JSON string representing the catalog. Returns: bool: True if the write operation was successful Raises: WriteInDatabaseError: If there is an error writing to the file.
str
, note_title: str
, content: str
, medias: list[ str, str]
= []) -> bool
:
¶
qA_Ap.db.qaapdb.qaapDB.write_comment
Writes a note for a specified document by a specified note_title. It creates a directory for the note, writes the note content to a text file, saves the note icon as a PNG file, and saves screenshots as PNG files. If the document does not exist, it raises a FileNotFoundError. If the note already exists, it raises a FileAlreadyExistsError. Args: post_title (str): Name of the document to write the note for. note_title (str): Name of the note_title. content (str): Content of the note. icon (str): Base64 encoded icon of the note. screenshots (list[str]): list of base64 encoded screenshots of the note. Returns: bool: True if the write operation was successful Raises: FileNotFoundError: If the document does not exist. FileAlreadyExistsError: If the note already exists. WriteInDatabaseError: If there is an error writing to the file or creating directories.
str
, content: str
, icon: str
= '', medias: list[ str, str]
= []) -> bool
:
¶
qA_Ap.db.qaapdb.qaapDB.write_post
Writes a new document to the database. It creates a directory for the document, writes the document content to a text file, saves the icon as a PNG file, and saves screenshots as PNG files. If the document already exists, it raises a FileAlreadyExistsError. Args: post_title (str): Name of the document to write. content (str): Content of the document. icon (str): Base64 encoded icon of the document. screenshots (list[str]): list of base64 encoded screenshots of the document. Returns: bool: True if the write operation was successful Raises: FileAlreadyExistsError: If the document already exists. WriteInDatabaseError: If there is an error writing to the file or creating directories.
Writes the binary representation of a vectorstore in a file. Args: bytes: The bytes representation of the vectorstore. Returns: bool: True if the write operation is successful. Raises: WriteInDatabaseError: If any exception occurs during the file write operation.