-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoolsModule.py
More file actions
242 lines (172 loc) · 9.28 KB
/
toolsModule.py
File metadata and controls
242 lines (172 loc) · 9.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
class tools:
"""this is a class used to store the prompts for the anthropic pipeline"""
def __init__(self):
self.hoursOfOpperationRequirements = """
Days of the week are abbreviated as follows: {Mon, Tues, Wed, Thurs, Fri, Sat, Sun}
The opening or closing hour of the day includes hour and minute, separated by a colon, followed
by “am” or “pm” designation after a space. The “am” and “pm” designations are always lower
case and never include a period:
* 8:00 am
Hours of Operation is almost always expressed as a period of time. Hence, an “[Hour] space dash
space [Hour]” format is used. The long-form dash is used, which is auto-formatted when typing a
dash, followed by a space, then one or more characters, and finally another space:
* 9:30 am - 5:00 pm
Hours of Operation must include one or more days of the week. For consecutive days of the week,
use a hyphen. Days come first, then hours.
* Mon - Thurs 8:00 am - 5:00 pm
Use commas to separate non-consecutive days with the same hours, and gaps in time on the same
days. Use semicolons to separate days of the week.
* Mon, Wed, Fri 6:00 am - 12:00 pm, 1:00 pm - 5:00 pm; Sat 10:00 am - 12:00 pm
24-hour services provided 7 days a week are formatted as:
* 24 hours a day, 7 days a week
For services with the same hours each day of the week, start with Sunday and end with Saturday:
* Sun - Sat 9:00 am - 5:00 pm
For services with differing weekend and weekday hours, start with Monday:
* Mon - Fri 7:00 am - 7:00 pm; Sat 8:00 am - 5:00 pm; Sun 8:30 am - 3:00 pm
For differing hours within a Program, such as multiple services, use a line break:
* Application Hours: Mon - Fri 8:00 am - 1:00 pm
Service Hours: Mon - Wed 7:00 pm - 9:00 pm
"""
self.disabilitiesAccessRequirements = """
Lists specific accessibility features that the location has, lacks, separated by a line return. If no information is known, use “Call for information”. If some information is entered but some is not known, add “Call for more information”. Do not state that a location lacks a non-applicable feature. For example, braille directories are not applicable if the location houses just one entity (i.e. single- unit). Do not just indicate “Yes” or “Accessible”. Always characterize the accessibility features that are present.
-Location has bathroom grab bars, wheelchair ramps.
-Location lacks braille directories.
-Call for more information
"""
def create_prompt(self, fieldValue, requirements):
return f"""
Your task is to validate whether a data field value meets a set of requirements. And return a JSON object with the format shown below.
The field value is:
<field_value>
{fieldValue}
</field_value>
The requirements for the field are:
<requirements>
{requirements}
</requirements>
Carefully compare the provided field value to the stated requirements.
Return a response JSON object shown below.
- In the resoning feild of the response object, explain in detail how the value does or does not meet each requirement.
- If the value does not meet the requirements, provide a corrected value that does in the corrected field. If the value meets the requirements, the corrected field should be the same as the field value. If no corrected value can be formed, the corrected field should be an empty string.
- In the isValid field of the response object, return true if the value meets the requirements and false if it does not.
- In the original_score field of the response object, score field of the response object, return a number between 0 and 1 that represents the confidence level that the original value meets the requirements. A score of 1 means the value meets the requirements with 100% confidence. A score of 0 means the value does not meet the requirements with 0% confidence.
- In the corrected_score field of the response object, return a number between 0 and 1 that represents the confidence level that the corrected value meets the requirements. A score of 1 means the corrected value meets the requirements with 100% confidence. A score of 0 means the corrected value does not meet the requirements with 0% confidence. If the corrected field is an empty string, the corrected_score field should be 0.
Only return the response object and make sure it is formatted-as-JSON-safe-string!
{{
"original": "{fieldValue}",
"isValid": "Boolean",
"original_score": "Number",
"corrected_score": "Number",
"corrected": "String",
"reasoning": "String"
}}
"""
def create_evaluation_prompt(self, original, corrected, reasoning, original_score, corrected_score, isValid, requirements):
return f"""
your task is to evaluate a peer response to a data validation task. The peer has been asked to validate whether a data field value meets a set of requirements.
The original field value is:
<original>
{original}
</original>
The requirements for the field are:
<requirements>
{requirements}
</requirements>
The peer has given the following corrected field value:
<corrected>
{corrected}
</corrected>
The peer has given the following reasoning for their correction:
<reasoning>
{reasoning}
</reasoning>
The peer has given the following scores for their original and corrected values:
<scores>
Original Score: {original_score}
Corrected Score: {corrected_score}
</scores>
The peer has given the following evaluation of the corrected value:
<evaluation>
{isValid}
</evaluation>
Your task is to evaluate the peer's task. Return a JSON object with the format shown below.
{{
"original": "fieldValue",
"isValid": "Boolean",
"original_score": "Number",
"corrected_score": "Number",
"corrected": "String",
"reasoning": "String"
"your_evaluation": "Boolean"
"your_score": "Number"
"your_reasoning": "String"
}}
- In the your_evaluation field of the response object, return true if the corrected value meets the requirements and false if it does not.
- In the your_score field of the response object, return a number between 0 and 1 that represents the confidence level that the corrected value meets the requirements. A score of 1 means the corrected value meets the requirements with 100% confidence. A score of 0 means the corrected value does not meet the requirements with 0% confidence.
- In the your_reasoning field of the response object, explain in detail how the corrected value does or does not meet each requirement.
"""
def validate_json_prompt(self, responseToFomat):
return f"""
You will be given a string in JSON format like this:
<json>
{{
"original": "fieldValue",
"isValid": "Boolean",
"original_score": "Number",
"corrected_score": "Number",
"corrected": "String",
"reasoning": "String"
}}
</json>
Your task is to first check if this JSON string is "safe" (hint it is not). A "safe" JSON string has the following
properties:
- All keys are enclosed in double quotes
- All string values are enclosed in double quotes
- Double quotes within string values are properly escaped with a backslash (\)
- Special characters like newlines, tabs, siglequotes and backslashes within string values are properly escaped
with a backslash (\)
For example, this is an unsafe JSON string because the keys are not in quotes and the string values are not properly escaped:
<unsafe_example>
{{name: "Bob", age: 25, city: 'New York'}}
</unsafe_example>
...
Here is the JSON string to process:
<json>
{responseToFomat}
</json>
If the JSON string is safe, return the original string (hint it is not). If the JSON string is not safe, return a corrected version of the string that is safe.
"""
def validate_json_evaluation_prompt(self, responseToFomat):
return f"""
You will be given a string in JSON format like this:
<json>
{{
"original": "fieldValue",
"isValid": "Boolean",
"original_score": "Number",
"corrected_score": "Number",
"corrected": "String",
"reasoning": "String",
"your_evaluation": "Boolean",
"your_score": "Number",
"your_reasoning": "String"
}}
</json>
Your task is to first check if this JSON string is "safe" (hint it is not). A "safe" JSON string has the following
properties:
- All keys are enclosed in double quotes
- All string values are enclosed in double quotes
- Double quotes within string values are properly escaped with a backslash (\)
- Special characters like newlines, tabs, siglequotes and backslashes within string values are properly escaped
with a backslash (\)
For example, this is an unsafe JSON string because the keys are not in quotes and the string values are not properly escaped:
<unsafe_example>
{{name: "Bob", age: 25, city: 'New York'}}
</unsafe_example>
...
Here is the JSON string to process:
<json>
{responseToFomat}
</json>
If the JSON string is safe, return the original string (hint it is not). If the JSON string is not safe, return a corrected version of the string that is safe.
"""