{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "### Notebook for creating the template documents" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from ipynb.fs.defs.preprocess_data import get_template_documents\n", "from ipynb.fs.defs.preprocess_data import store_documents\n", "from langchain.docstore.document import Document\n", "import os\n", "import shutil\n", "\n", "# Load all already existing documents and store paths of new documents to be processed\n", "all_template_documents = get_template_documents(True)\n", "template_paths = os.listdir(\"./../input_data/Templates/template_files/new\")\n", "\n", "print(all_template_documents)\n", "print(\"\\n\")\n", "print(template_paths)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Manually create the documents for each template\n", "full_path = \"./../input_data/Templates/template_files/processed\"\n", "\n", "template_document_1 = Document(\n", " page_content=f\"You can find a possible template for the backup policy from the Annex A of ISO 27001 attached to this message. It contains pre-written texts for purpose, scope, content and more for the backup policy.\", \n", " metadata={\n", " \"template_path\": full_path + \"/\" + template_paths[0], \n", " \"source\": template_paths[0],\n", " })\n", "\n", "template_document_2 = Document(\n", " page_content=f\"You can find a possible template for the change management policy from the Annex A of ISO 27001 attached to this message. It contains pre-written texts for purpose, scope, content, procedures, risk management and more for the change management policy.\", \n", " metadata={\n", " \"template_path\": full_path + \"/\" + template_paths[1], \n", " \"source\": template_paths[1],\n", " })\n", "\n", "\n", "template_document_3 = Document(\n", " page_content=f\"You can find a possible template for the encryption policy from the Annex A of ISO 27001 attached to this message. It contains pre-written texts for purpose, scope, content and more for the encryption policy.\", \n", " metadata={\n", " \"template_path\": full_path + \"/\" + template_paths[2], \n", " \"source\": template_paths[2],\n", " })\n", "\n", "\n", "template_document_4 = Document(\n", " page_content=f\"You can find a possible template for a checklist for all ISO-27001 controls (Version 2013) attached to this message. It contains a simple checklist for the ISO 27001 controls 5 to 18.\", \n", " metadata={\n", " \"template_path\": full_path + \"/\" + template_paths[3], \n", " \"source\": template_paths[3],\n", " })\n", "\n", "template_document_5 = Document(\n", " page_content=f\"You can find a possible template for a risk assessment needed for the ISO-27001 certification attached to this message. It contains a simple checklist of selected controls for which a risk assessment is needed.\", \n", " metadata={\n", " \"template_path\": full_path + \"/\" + template_paths[4], \n", " \"source\": template_paths[4],\n", " })\n", "\n", "template_document_5 = Document(\n", " page_content=f\"You can find a possible template for a risk assessment needed for the ISO-27001 certification attached to this message. It contains a simple checklist of selected controls for which a risk assessment is needed.\", \n", " metadata={\n", " \"template_path\": full_path + \"/\" + template_paths[4], \n", " \"source\": template_paths[4],\n", " })\n", "\n", "new_template_documents = []\n", "new_template_documents.append(template_document_1)\n", "new_template_documents.append(template_document_2)\n", "new_template_documents.append(template_document_3)\n", "new_template_documents.append(template_document_4)\n", "new_template_documents.append(template_document_5)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Store the new templates and all templates\n", "store_documents(new_template_documents, \"./../input_data/Templates/documents/new_documents\")\n", "\n", "all_template_documents.extend(new_template_documents)\n", "store_documents(new_template_documents, \"./../input_data/Templates/documents/all_documents\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Move new templates to processed templates\n", "for path in template_paths:\n", " source_file = f\"./../input_data/Templates/template_files/new/{path}\"\n", " destination_folder = \"./../input_data/Templates/template_files/processed\"\n", " shutil.move(source_file, destination_folder)" ] } ], "metadata": { "kernelspec": { "display_name": "venv", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.5" } }, "nbformat": 4, "nbformat_minor": 2 }