functions_prompt.py 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. list_emails_function = """
  2. {
  3. "type": "function",
  4. "function": {
  5. "name": "list_emails",
  6. "description": "Return a list of emails matching an optionally specified query.",
  7. "parameters": {
  8. "type": "dic",
  9. "properties": [
  10. {
  11. "maxResults": {
  12. "type": "integer",
  13. "description": "The default maximum number of emails to return is 100; the maximum allowed value for this field is 500."
  14. }
  15. },
  16. {
  17. "query": {
  18. "type": "string",
  19. "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)."
  20. }
  21. }
  22. ],
  23. "required": []
  24. }
  25. }
  26. }
  27. """
  28. get_email_function = """
  29. {
  30. "type": "function",
  31. "function": {
  32. "name": "get_email_detail",
  33. "description": "Get detailed info about a specific email",
  34. "parameters": {
  35. "type": "dict",
  36. "properties": [
  37. {
  38. "detail": {
  39. "type": "string",
  40. "description": "what detail the user wants to know about - two possible values: body or attachment"
  41. }
  42. },
  43. {
  44. "which": {
  45. "type": "string",
  46. "description": "which email to get detail about - possible values include: 'first', 'second', ..., 'last', 'from ...', and 'subject ...'"
  47. }
  48. },
  49. ],
  50. "required": ["detail", "which"]
  51. }
  52. }
  53. }
  54. """
  55. send_email_function = """
  56. {
  57. "type": "function",
  58. "function": {
  59. "name": "send_email",
  60. "description": "Compose, reply, or forward email",
  61. "parameters": {
  62. "type": "dict",
  63. "properties": [
  64. {
  65. "action": {
  66. "type": "string",
  67. "description": "Whether to compose, reply, or forward an email"
  68. }
  69. },
  70. {
  71. "to": {
  72. "type": "string",
  73. "description": "The recipient of the email"
  74. }
  75. },
  76. {
  77. "subject": {
  78. "type": "string",
  79. "description": "The email subject"
  80. }
  81. },
  82. {
  83. "body": {
  84. "type": "string",
  85. "description": "The email content"
  86. }
  87. },
  88. {
  89. "email_id": {
  90. "type": "string",
  91. "description": "the email id to reply or forward to"
  92. }
  93. }
  94. ],
  95. "required": ["action", "to", "subject", "body"]
  96. }
  97. }
  98. }
  99. """
  100. get_pdf_summary_function = """
  101. {
  102. "type": "function",
  103. "function": {
  104. "name": "get_pdf_summary",
  105. "description": "get a summary of a PDF attachment",
  106. "parameters": {
  107. "type": "dict",
  108. "properties": [
  109. {
  110. "file_name": {
  111. "type": "string",
  112. "description": "The name of the PDF file"
  113. }
  114. },
  115. ],
  116. "required": ["file_name"]
  117. }
  118. }
  119. }
  120. """
  121. create_draft_function = """
  122. {
  123. "type": "function",
  124. "function": {
  125. "name": "create_draft",
  126. "description": "Create a new, reply, or forward email draft",
  127. "parameters": {
  128. "type": "dict",
  129. "properties": [
  130. {
  131. "action": {
  132. "type": "string",
  133. "description": "Whether to draft a new, reply, or forward an email"
  134. }
  135. },
  136. {
  137. "to": {
  138. "type": "string",
  139. "description": "The recipient of the email"
  140. }
  141. },
  142. {
  143. "subject": {
  144. "type": "string",
  145. "description": "The email subject"
  146. }
  147. },
  148. {
  149. "body": {
  150. "type": "string",
  151. "description": "The email content"
  152. }
  153. },
  154. {
  155. "email_id": {
  156. "type": "string",
  157. "description": "the email id to reply or forward to, or empty if draft a new email."
  158. }
  159. }
  160. ],
  161. "required": ["action", "to", "subject", "body", "email_id"]
  162. }
  163. }
  164. }
  165. """
  166. # for now, only allow for one draft email to be saved in a session
  167. # to support for multiple drafts, cf how get_email_detail after list_emails is implemented.
  168. send_draft_function = """
  169. {
  170. "type": "function",
  171. "function": {
  172. "name": "send_draft",
  173. "description": "Send a draft email",
  174. "parameters": {
  175. "type": "dict",
  176. "properties": [
  177. {
  178. "id": {
  179. "type": "string",
  180. "description": "draft id"
  181. }
  182. },
  183. ],
  184. "required": ["id"]
  185. }
  186. }
  187. }
  188. """
  189. examples = """
  190. {"name": "list_emails", "parameters": {"query": "has:attachment larger:5mb"}}
  191. {"name": "list_emails", "parameters": {"query": "has:attachment"}}
  192. {"name": "list_emails", "parameters": {"query": "newer_than:1d"}}
  193. {"name": "list_emails", "parameters": {"query": "older_than:1d"}}
  194. {"name": "list_emails", "parameters": {"query": "is:unread"}}
  195. {"name": "list_emails", "parameters": {"query": "<query> is:unread"}}
  196. {"name": "list_emails", "parameters": {"query": "<query> is:read"}}
  197. {"name": "get_email_detail", "parameters": {"detail": "body", "which": "first"}}
  198. {"name": "get_email_detail", "parameters": {"detail": "body", "which": "last"}}
  199. {"name": "get_email_detail", "parameters": {"detail": "body", "which": "second"}}
  200. {"name": "get_email_detail", "parameters": {"detail": "body", "which": "subject <subject info>"}}
  201. {"name": "get_email_detail", "parameters": {"detail": "attachment", "which": "from <sender info>"}}
  202. {"name": "get_email_detail", "parameters": {"detail": "attachment", "which": "first"}}
  203. {"name": "get_email_detail", "parameters": {"detail": "attachment", "which": "last"}}
  204. {"name": "get_email_detail", "parameters": {"detail": "attachment", "which": "<email id>"}}
  205. {"name": "send_email", "parameters": {"action": "compose", "to": "jeffxtang@meta.com", "subject": "xxxxx", "body": "xxxxx"}}
  206. {"name": "send_email", "parameters": {"action": "reply", "to": "", "subject": "xxxxx", "body": "xxxxx", "email_id": "xxxxx"}}
  207. {"name": "send_email", "parameters": {"action": "forward", "to": "jeffxtang@meta.com", "subject": "xxxxx", "body": "xxxxx", "email_id": "xxxxx"}}
  208. {"name": "create_draft", "parameters": {"action": "new", "to": "jeffxtang@meta.com", "subject": "xxxxx", "body": "xxxxx", "email_id": ""}}
  209. {"name": "create_draft", "parameters": {"action": "reply", "to": "", "subject": "xxxxx", "body": "xxxxx", "email_id": "xxxxx"}}
  210. {"name": "create_draft", "parameters": {"action": "forward", "to": "jeffxtang@meta.com", "subject": "xxxxx", "body": "xxxxx", "email_id": "xxxxx"}}
  211. {"name": "send_draft", "parameters": {"id": "..."}}
  212. {"name": "get_pdf_summary", "parameters": {"file_name": "..."}}
  213. """
  214. system_prompt = f"""
  215. Environment: ipython
  216. Cutting Knowledge Date: December 2023
  217. Today Date: 1 December 2024
  218. Your name is Email Agent, an assistant that can perform all email related tasks for your user.
  219. Respond to the user's ask by making use of the following functions if needed.
  220. If no available functions can be used, just say "I don't know" and don't make up facts.
  221. Here is a list of available functions in JSON format:
  222. {list_emails_function}
  223. {get_email_function}
  224. {send_email_function}
  225. {get_pdf_summary_function}
  226. {create_draft_function}
  227. {send_draft_function}
  228. Example responses:
  229. {examples}
  230. """