-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
Copy pathfunctions_prompt.py
241 lines (230 loc) · 8.61 KB
/
functions_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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
list_emails_function = """
{
"type": "function",
"function": {
"name": "list_emails",
"description": "Return a list of emails matching an optionally specified query.",
"parameters": {
"type": "dic",
"properties": [
{
"maxResults": {
"type": "integer",
"description": "The default maximum number of emails to return is 100; the maximum allowed value for this field is 500."
}
},
{
"query": {
"type": "string",
"description": "One or more keywords in the email subject and body, or one or more filters. There can be 6 types of filters: 1) Field-specific Filters: from, to, cc, bcc, subject; 2) Date Filters: before, after, older than, newer than); 3) Status Filters: read, unread, starred, importatant; 4) Attachment Filters: has, filename or type; 5) Size Filters: larger, smaller; 6) logical operators (or, and, not)."
}
}
],
"required": []
}
}
}
"""
get_email_function = """
{
"type": "function",
"function": {
"name": "get_email_detail",
"description": "Get detailed info about a specific email",
"parameters": {
"type": "dict",
"properties": [
{
"detail": {
"type": "string",
"description": "what detail the user wants to know about - two possible values: body or attachment"
}
},
{
"which": {
"type": "string",
"description": "which email to get detail about - possible values include: 'first', 'second', ..., 'last', 'from ...', and 'subject ...'"
}
},
],
"required": ["detail", "which"]
}
}
}
"""
send_email_function = """
{
"type": "function",
"function": {
"name": "send_email",
"description": "Compose, reply, or forward email",
"parameters": {
"type": "dict",
"properties": [
{
"action": {
"type": "string",
"description": "Whether to compose, reply, or forward an email"
}
},
{
"to": {
"type": "string",
"description": "The recipient of the email"
}
},
{
"subject": {
"type": "string",
"description": "The email subject"
}
},
{
"body": {
"type": "string",
"description": "The email content"
}
},
{
"email_id": {
"type": "string",
"description": "the email id to reply or forward to"
}
}
],
"required": ["action", "to", "subject", "body"]
}
}
}
"""
get_pdf_summary_function = """
{
"type": "function",
"function": {
"name": "get_pdf_summary",
"description": "get a summary of a PDF attachment",
"parameters": {
"type": "dict",
"properties": [
{
"file_name": {
"type": "string",
"description": "The name of the PDF file"
}
},
],
"required": ["file_name"]
}
}
}
"""
create_draft_function = """
{
"type": "function",
"function": {
"name": "create_draft",
"description": "Create a new, reply, or forward email draft",
"parameters": {
"type": "dict",
"properties": [
{
"action": {
"type": "string",
"description": "Whether to draft a new, reply, or forward an email"
}
},
{
"to": {
"type": "string",
"description": "The recipient of the email"
}
},
{
"subject": {
"type": "string",
"description": "The email subject"
}
},
{
"body": {
"type": "string",
"description": "The email content"
}
},
{
"email_id": {
"type": "string",
"description": "the email id to reply or forward to, or empty if draft a new email."
}
}
],
"required": ["action", "to", "subject", "body", "email_id"]
}
}
}
"""
# for now, only allow for one draft email to be saved in a session
# to support for multiple drafts, cf how get_email_detail after list_emails is implemented.
send_draft_function = """
{
"type": "function",
"function": {
"name": "send_draft",
"description": "Send a draft email",
"parameters": {
"type": "dict",
"properties": [
{
"id": {
"type": "string",
"description": "draft id"
}
},
],
"required": ["id"]
}
}
}
"""
examples = """
{"name": "list_emails", "parameters": {"query": "has:attachment larger:5mb"}}
{"name": "list_emails", "parameters": {"query": "has:attachment"}}
{"name": "list_emails", "parameters": {"query": "newer_than:1d"}}
{"name": "list_emails", "parameters": {"query": "older_than:1d"}}
{"name": "list_emails", "parameters": {"query": "is:unread"}}
{"name": "list_emails", "parameters": {"query": "<query> is:unread"}}
{"name": "list_emails", "parameters": {"query": "<query> is:read"}}
{"name": "get_email_detail", "parameters": {"detail": "body", "which": "first"}}
{"name": "get_email_detail", "parameters": {"detail": "body", "which": "last"}}
{"name": "get_email_detail", "parameters": {"detail": "body", "which": "second"}}
{"name": "get_email_detail", "parameters": {"detail": "body", "which": "subject <subject info>"}}
{"name": "get_email_detail", "parameters": {"detail": "attachment", "which": "from <sender info>"}}
{"name": "get_email_detail", "parameters": {"detail": "attachment", "which": "first"}}
{"name": "get_email_detail", "parameters": {"detail": "attachment", "which": "last"}}
{"name": "get_email_detail", "parameters": {"detail": "attachment", "which": "<email id>"}}
{"name": "send_email", "parameters": {"action": "compose", "to": "[email protected]", "subject": "xxxxx", "body": "xxxxx"}}
{"name": "send_email", "parameters": {"action": "reply", "to": "", "subject": "xxxxx", "body": "xxxxx", "email_id": "xxxxx"}}
{"name": "send_email", "parameters": {"action": "forward", "to": "[email protected]", "subject": "xxxxx", "body": "xxxxx", "email_id": "xxxxx"}}
{"name": "create_draft", "parameters": {"action": "new", "to": "[email protected]", "subject": "xxxxx", "body": "xxxxx", "email_id": ""}}
{"name": "create_draft", "parameters": {"action": "reply", "to": "", "subject": "xxxxx", "body": "xxxxx", "email_id": "xxxxx"}}
{"name": "create_draft", "parameters": {"action": "forward", "to": "[email protected]", "subject": "xxxxx", "body": "xxxxx", "email_id": "xxxxx"}}
{"name": "send_draft", "parameters": {"id": "..."}}
{"name": "get_pdf_summary", "parameters": {"file_name": "..."}}
"""
system_prompt = f"""
Environment: ipython
Cutting Knowledge Date: December 2023
Today Date: 1 December 2024
Your name is Email Agent, an assistant that can perform all email related tasks for your user.
Respond to the user's ask by making use of the following functions if needed.
If no available functions can be used, just say "I don't know" and don't make up facts.
Here is a list of available functions in JSON format:
{list_emails_function}
{get_email_function}
{send_email_function}
{get_pdf_summary_function}
{create_draft_function}
{send_draft_function}
Example responses:
{examples}
"""