Friday, February 16, 2024

Chat GPT Can Be A Good Interface to APIs

I read about how Open AI will let developers and users add APIs to Chat GPT.  

If I added an email_to function, here is how simple it would be to get ChatGPT to use it (and I did this using the less powerful, free version of GPT 3.5):


me: given a function api called email_to(subject, body), if I tell you in English to email someone about something, can you take my sentence and tell me what the api call would be?

ChatGPT: Of course! Please provide me with the sentence you'd like to use to email someone about something, and I'll convert it into the corresponding API call.

me: can you email Fred and ask for last week's sales figures?

ChatGPT: Certainly! The corresponding API call would be:

email_to("Request for Last Week's Sales Figures", "Hi Fred,\n\nI hope you're doing well. Could you please provide me with the sales figures from last week? It would be greatly appreciated.\n\nThank you!\n[Your Name]")

me: Can you amend the function to first include the person's email?

ChatGPT: Sure, here's an updated version of the function email_to that includes the recipient's email:

def email_to(recipient_email, subject, body): # Logic to send email to recipient_email with given subject and body pass

And here's how you would use it to email Fred and ask for last week's sales figures:

email_to("fred@example.com", "Request for Last Week's Sales Figures", "Hi Fred,\n\nI hope you're doing well. Could you please provide me with the sales figures from last week? It would be greatly appreciated.\n\nThank you!\n[Your Name]")

Replace "fred@example.com" with Fred's actual email address.


© 2024 Praveen Puri