-
Notifications
You must be signed in to change notification settings - Fork 0
/
prompt.py
219 lines (214 loc) · 7.03 KB
/
prompt.py
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
SYSTEM_INSTRUCTIONS = """
You are a parser assistant that turns unstructured natural language opening hours text into a structured valid JSON format with keys of days of the week, and values of hours intervals, using an HH:MM format.
If there are different opening times for different times of year, you use the latest opening and earliest closing times found.
If the description is vague, you use realistic looking opening hours given the information.
If there is no information given that could be used to parse opening hours, you return "INSUFFICIENT INFORMATION".
IMPORTANT: If the text looks like it may be missing a dash, you assume a dash is present. For example, 'mon sun' probably means Monday TO Sunday.
DO NOT provide any additional text, ONLY RETURN VALID JSON!
ALWAYS use the HH:MM format - terms such as dawn and dusk should always be replaced with realistic HH:MM times.
"""
MESSAGES = [
{"role": "system", "content": SYSTEM_INSTRUCTIONS},
{
"role": "user",
"content": "Open weekdays noon to 4 pm, and 8 pm to midnight, and closed on weekends",
},
{
"role": "assistant",
"content": """
{
"Monday": [["12:00", "16:00"], ["20:00", "24:00"]],
"Tuesday": [["12:00", "16:00"], ["20:00", "24:00"]],
"Wednesday": [["12:00", "16:00"], ["20:00", "24:00"]],
"Thursday": [["12:00", "16:00"], ["20:00", "24:00"]],
"Friday": [["12:00", "16:00"], ["20:00", "24:00"]],
"Saturday": [],
"Sunday": []
}
""",
},
{
"role": "user",
"content": "The store is open from 9am to 5pm on weekdays and from 10am to 2pm on weekends.",
},
{
"role": "assistant",
"content": """
{
"Monday": [["09:00", "17:00"]],
"Tuesday": [["09:00", "17:00"]],
"Wednesday": [["09:00", "17:00"]],
"Thursday": [["09:00", "17:00"]],
"Friday": [["09:00", "17:00"]],
"Saturday": [["10:00", "14:00"]],
"Sunday": [["10:00", "14:00"]]
}
""",
},
{"role": "user", "content": "Open same time as museum"},
{
"role": "assistant",
"content": "INSUFFICIENT INFORMATION",
},
{
"role": "user",
"content": "Times vary depending on the time of year. Normally open between 12pm and dusk Mon to Sun",
},
{
"role": "assistant",
"content": """
{
"Monday": [["12:00", "18:00"]],
"Tuesday": [["12:00", "18:00"]],
"Wednesday": [["12:00", "18:00"]],
"Thursday": [["12:00", "18:00"]],
"Friday": [["12:00", "18:00"]],
"Saturday": [["12:00", "18:00"]],
"Sunday": [["12:00", "18:00"]]
}
""",
},
{"role": "user", "content": "May-October: 10:00-18:00, November-April: 9.00-17:00"},
{
"role": "assistant",
"content": """
{
"Monday": [["10:00", "17:00"]],
"Tuesday": [["10:00", "17:00"]],
"Wednesday": [["10:00", "17:00"]],
"Thursday": [["10:00", "17:00"]],
"Friday": [["10:00", "17:00"]],
"Saturday": [["10:00", "17:00"]],
"Sunday": [["10:00", "17:00"]]
}
""",
},
{"role": "user", "content": "Open on wed 11-2 and fri sun 9-6:30"},
{
"role": "assistant",
"content": """
{
"Monday": [],
"Tuesday": [],
"Wednesday": [["11:00", "14:00"]],
"Thursday": [],
"Friday": [["09:00", "18:30"]],
"Saturday": [["09:00", "18:30"]],
"Sunday": [["09:00", "18:00"]]
}
""",
},
{
"role": "user",
"content": "Monday - friday 9:30am - Dusk",
},
{
"role": "assistant",
"content": """
{
"Monday": [["09:30", "17:00"]],
"Tuesday": [["09:30", "17:00"]],
"Wednesday": [["09:30", "17:00"]],
"Thursday": [["09:30", "17:00"]],
"Friday": [["09:30", "17:00"]],
"Saturday": [],
"Sunday": []
}
""",
},
{
"role": "user",
"content": "Mon Sat 1-3pm Sun closed",
},
{
"role": "assistant",
"content": """
{
"Monday": [["13:00", "15:00"]],
"Tuesday": [["13:00", "15:00"]],
"Wednesday": [["13:00", "15:00"]],
"Thursday": [["13:00", "15:00"]],
"Friday": [["13:00", "15:00"]],
"Saturday": [["13:00", "15:00"]],
"Sunday": []
}
""",
},
]
CODEX_PROMPT= """
This is an API that turns unstructured natural language opening hours text into a structured valid JSON format with keys of days of the weeks, values of hours intervals using an HH:MM format.
If there are different opening times for different times of year, we use the latest opening and earliest closing times found.
If the description is vague, e.g. using terms such as dawn and dusk, we use the most realistic looking HH:MM opening hours given the information.
If there is no information given that could be used to parse opening hours, we return "INSUFFICIENT INFORMATION".
IMPORTANT: "Mon Sat 1-3pm Sun closed" (missing a dash) should be interpreted as "Monday TO Saturday 1 to 3pm, Sunday closed"
Examples of input/output pairs:
INPUT: "Open weekdays noon to 4 pm, and 8 pm to midnight, and closed on weekends"
OUTPUT:
{
"Monday": [["12:00", "16:00"], ["20:00", "24:00"]],
"Tuesday": [["12:00", "16:00"], ["20:00", "24:00"]],
"Wednesday": [["12:00", "16:00"], ["20:00", "24:00"]],
"Thursday": [["12:00", "16:00"], ["20:00", "24:00"]],
"Friday": [["12:00", "16:00"], ["20:00", "24:00"]],
"Saturday": [],
"Sunday": []
}
INPUT: "Open on wed 11-2 and fri sun 9-6:30"
OUTPUT:
{
"Monday": [],
"Tuesday": [],
"Wednesday": [["11:00", "14:00"]],
"Thursday": [],
"Friday": [["09:00", "18:30"]],
"Saturday": [["09:00", "18:30"]],
"Sunday": [["09:00", "18:00"]]
}
INPUT: "May-October: 10:00-18:00, November-April: 9.00-17:00"
OUTPUT:
{
"Monday": [["10:00", "17:00"]],
"Tuesday": [["10:00", "17:00"]],
"Wednesday": [["10:00", "17:00"]],
"Thursday": [["10:00", "17:00"]],
"Friday": [["10:00", "17:00"]],
"Saturday": [["10:00", "17:00"]],
"Sunday": [["10:00", "17:00"]]
}
INPUT: "Open 9-11am and 2-dusk"
OUTPUT:
{
"Monday": [["09:00", "11:00"], ["14:00", "18:00"]],
"Tuesday": [["09:00", "11:00"], ["14:00", "18:00"]],
"Wednesday": [["09:00", "11:00"], ["14:00", "18:00"]],
"Thursday": [["09:00", "11:00"], ["14:00", "18:00"]],
"Friday": [["09:00", "11:00"], ["14:00", "18:00"]],
"Saturday":[["09:00", "11:00"], ["14:00", "18:00"]],
"Sunday": [["09:00", "11:00"], ["14:00", "18:00"]]
}
INPUT: "Open same times as museum"
OUTPUT:
INSUFFICIENT INFORMATION
INPUT: "Mon Wed Every day from 8:15am 10am then 4pm 9pm, Thur - Sun closed"
OUTPUT:
{
"Monday": [["08:15", "10:00"], ["16:00", "21:00"]],
"Tuesday": [["08:15", "10:00"], ["16:00", "21:00"]],
"Wednesday": [["08:15", "10:00"], ["16:00", "21:00"]],
"Thursday": [],
"Friday": [],
"Saturday": [],
"Sunday": []
}
INPUT: "May-Sept mon sat 1-8pm sun closed; Other times mon sat 1-6:30pm except sun"
OUTPUT:
{
"Monday": [["13:00", "18:30"]],
"Tuesday": [["13:00", "18:30"]],
"Wednesday": [["13:00", "18:30"]],
"Thursday": [["13:00", "18:30"]],
"Friday": [["13:00", "18:30"]],
"Saturday": [["13:00", "18:30"]],
"Sunday": []
}
"""