File size: 793 Bytes
4f5fa64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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}')