From 4f8664d88208f0704223fd6847dbc071c9d0da11 Mon Sep 17 00:00:00 2001 From: JolanThomassin Date: Mon, 15 Jan 2024 15:31:20 +0000 Subject: [PATCH] Fixes #9, magic string --- ailab/db/finesse/__init__.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ailab/db/finesse/__init__.py b/ailab/db/finesse/__init__.py index 0715070..0ce0ca1 100644 --- a/ailab/db/finesse/__init__.py +++ b/ailab/db/finesse/__init__.py @@ -1,6 +1,9 @@ import os import json +# Constants +DEFAULT_JSON_PATH = "/ailab/db/finesse/prompt" + def load_prompt(prompt_path, filename): full_path = os.path.join(prompt_path, filename) @@ -11,7 +14,13 @@ def load_prompt(prompt_path, filename): return content -def load_json_template(json_path): +def load_json_template(json_path=DEFAULT_JSON_PATH): + """ + Load a JSON template from the specified path. + + Returns: + str: A JSON-formatted string representing the loaded data. + """ json_file_path = json_path + "/json_template.json" with open(json_file_path, "r") as file: @@ -20,4 +29,4 @@ def load_json_template(json_path): # Convert the dictionary back to a JSON-formatted string content = json.dumps(data, indent=4) # Use 'indent' for pretty printing - return content \ No newline at end of file + return content