Added constant for prompt file
This commit is contained in:
@@ -20,6 +20,7 @@ from termcolor import colored
|
||||
from colorama import init
|
||||
|
||||
CONFIG_FILE = "yolo.yaml"
|
||||
PROMPT_FILE = "yolo.prompt"
|
||||
|
||||
def read_yaml_config() -> any:
|
||||
"""
|
||||
@@ -126,10 +127,10 @@ def get_os_friendly_name():
|
||||
def get_full_prompt(user_prompt, shell):
|
||||
"""
|
||||
Constructs a full prompt string by appending the user's prompt to a predefined prompt template
|
||||
located in the 'yolo.prompt' file.
|
||||
located in the PROMPT_FILE file.
|
||||
|
||||
The function finds the absolute path of the currently executing file, and based on this path,
|
||||
identifies the directory of 'yolo.prompt'. It reads this file, replaces placeholders {shell}
|
||||
identifies the directory of PROMPT_FILE. It reads this file, replaces placeholders {shell}
|
||||
and {os} in the text file with a passed shell parameter and the friendly name of the operating
|
||||
system respectively. The user prompt is then appended to this pre-prompt. If the resulting
|
||||
prompt does not end with a question mark or a period, a question mark is added at last.
|
||||
@@ -139,19 +140,19 @@ def get_full_prompt(user_prompt, shell):
|
||||
user_prompt : str
|
||||
The prompt supplied by the user to be appended to the pre-prompt.
|
||||
shell : str
|
||||
The shell information to be inserted in the place of {shell} placeholder in 'yolo.prompt'.
|
||||
The shell information to be inserted in the place of {shell} placeholder in PROMPT_FILE.
|
||||
|
||||
Returns
|
||||
-------
|
||||
str
|
||||
The full prompt, constructed from the template prompt in 'yolo.prompt',
|
||||
The full prompt, constructed from the template prompt in PROMPT_FILE,
|
||||
user-provided shell info, the OS name, and the user-supplied prompt string.
|
||||
"""
|
||||
yolo_path = os.path.abspath(__file__)
|
||||
prompt_path = os.path.dirname(yolo_path)
|
||||
|
||||
## Load the prompt and prep it
|
||||
prompt_file = os.path.join(prompt_path, "yolo.prompt")
|
||||
prompt_file = os.path.join(prompt_path, PROMPT_FILE)
|
||||
pre_prompt = open(prompt_file,"r").read()
|
||||
pre_prompt = pre_prompt.replace("{shell}", shell)
|
||||
pre_prompt = pre_prompt.replace("{os}", get_os_friendly_name())
|
||||
|
||||
Reference in New Issue
Block a user