Spaces:
Sleeping
Sleeping
File size: 5,543 Bytes
579ab0b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
{
"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
}
|