Adi-ds's picture
Upload prompting.py
4f5fa64 verified
raw
history blame
793 Bytes
from yaml import load, Loader
params = load(open('params.yml').read(), Loader=Loader)
def add_prompt(
paragraph_1: str,
paragraph_2: str,
instruction: str = params['instruction']
):
assert isinstance(paragraph_1, str), f'paragraph_1 should be a string. Got {type(paragraph_1)}!'
assert isinstance(paragraph_2, str), f'paragraph_2 should be a string. Got {type(paragraph_2)}!'
assert isinstance(instruction, str), f'instruction should be a string. Got {type(instruction)}!'
try:
final_prompt = f"INSTRUCTION: {instruction} PARAGRAPH_1:{paragraph_1} PARAGRAPH_2:{paragraph_2}\nThe semantic similarity between the two paragraphs is: "
return final_prompt
except Exception as e:
print(f'An error occured in the function `add_prompt`:\n{e}')