From 8150f0c813962aaec6b0c070b27c5201e858ef8b Mon Sep 17 00:00:00 2001 From: Pavloh <89773173+ImPavloh@users.noreply.github.com> Date: Tue, 4 Apr 2023 13:24:14 +0200 Subject: [PATCH] Refactor load_prompt function Simplify the load_prompt function by eliminating redundancy --- scripts/data.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/scripts/data.py b/scripts/data.py index 72a6bbfc..8d8a7b4a 100644 --- a/scripts/data.py +++ b/scripts/data.py @@ -1,15 +1,14 @@ import os from pathlib import Path -SRC_DIR = Path(__file__).parent def load_prompt(): try: # get directory of this file: - file_dir = Path(os.path.dirname(os.path.realpath(__file__))) - data_dir = file_dir / "data" - prompt_file = data_dir / "prompt.txt" - # Load the promt from data/prompt.txt - with open(SRC_DIR/ "data/prompt.txt", "r") as prompt_file: + file_dir = Path(__file__).parent + prompt_file_path = file_dir / "data" / "prompt.txt" + + # Load the prompt from data/prompt.txt + with open(prompt_file_path, "r") as prompt_file: prompt = prompt_file.read() return prompt