Spaces:
Sleeping
Sleeping
Upload prompting.py
Browse files- prompting.py +16 -0
prompting.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from yaml import load, Loader
|
2 |
+
params = load(open('params.yml').read(), Loader=Loader)
|
3 |
+
|
4 |
+
def add_prompt(
|
5 |
+
paragraph_1: str,
|
6 |
+
paragraph_2: str,
|
7 |
+
instruction: str = params['instruction']
|
8 |
+
):
|
9 |
+
assert isinstance(paragraph_1, str), f'paragraph_1 should be a string. Got {type(paragraph_1)}!'
|
10 |
+
assert isinstance(paragraph_2, str), f'paragraph_2 should be a string. Got {type(paragraph_2)}!'
|
11 |
+
assert isinstance(instruction, str), f'instruction should be a string. Got {type(instruction)}!'
|
12 |
+
try:
|
13 |
+
final_prompt = f"INSTRUCTION: {instruction} PARAGRAPH_1:{paragraph_1} PARAGRAPH_2:{paragraph_2}\nThe semantic similarity between the two paragraphs is: "
|
14 |
+
return final_prompt
|
15 |
+
except Exception as e:
|
16 |
+
print(f'An error occured in the function `add_prompt`:\n{e}')
|