forked from michelin/Evergreen-Patterns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.py
19 lines (13 loc) · 761 Bytes
/
data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import yaml
def load_yaml(file_name):
# load the yaml file
prompts = []
with open(file_name, newline='') as yamlfile:
prompts = yaml.load(yamlfile, Loader=yaml.FullLoader)
# loop through the prompts and get the responses
prefix = "\n".join([prompt['prompt'] for prompt in prompts if prompt['family'] == 'prefix'])
suffix = "\n".join([prompt['prompt'] for prompt in prompts if prompt['family'] == 'suffix'])
# filter out the prompts that are not patterns
return prefix, suffix, [prompt for prompt in prompts if prompt['family'] != 'prefix' and prompt['family'] != 'suffix']
pattern_prefix, pattern_suffix, patterns = load_yaml('patterns.yaml')
anti_pattern_prefix, anti_pattern_suffix, anti_patterns = load_yaml('anti_patterns.yaml')