├── .gitignore ├── README.md └── ZapierLangchain.ipynb /.gitignore: -------------------------------------------------------------------------------- 1 | .env -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | ## Dependencies 3 | 4 | ``` 5 | pip install pip install jupyterlab 6 | pip install langchain 7 | pip install openai 8 | pip install python-dotenv 9 | ``` 10 | 11 | ## Requirements 12 | - OpenAI APIkey 13 | - Zapier Natural Language API Key 14 | - Zapier NLA Project ID (create a demo task in their UI according to website instructions listed below in resources) 15 | 16 | 17 | ## RUN 18 | 1. clone repo 19 | 2. cd into `zapier-langchain/quickstart` 20 | 3. add `.env` file with your OpenAI and Zapier API keys 21 | 4. run 22 | ```jupyter-lab``` in terminal 23 | 5. Setup your Zapier NLA project in the Zapier NLA UI 24 | 6. Edit the agent.task and run all cells in `ZapierLangchain.ipynb` 25 | 26 | ## Resources 27 | 28 | - Jupyter notebook https://jupyter.org/install 29 | - Langchain Quickstart Guide https://langchain.readthedocs.io/en/latest/getting_started/getting_started.html 30 | - OpenAI API Keys https://platform.openai.com/account/api-keys 31 | - Zapier NLA Docs https://nla.zapier.com/api/v1/dynamic/docs 32 | - Zapier NLA Get Started https://nla.zapier.com/get-started/ 33 | - Zapier API signup https://zapier.com/l/natural-language-actions 34 | -------------------------------------------------------------------------------- /ZapierLangchain.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 34, 6 | "id": "1c38fa93-a267-43af-9f88-4a3a72c848f6", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "import os\n", 11 | "%load_ext dotenv\n", 12 | "%dotenv\n", 13 | "from langchain.llms import OpenAI\n", 14 | "from langchain.agents import initialize_agent\n", 15 | "from langchain.agents.agent_toolkits import ZapierToolkit\n", 16 | "from langchain.utilities.zapier import ZapierNLAWrapper" 17 | ] 18 | }, 19 | { 20 | "cell_type": "code", 21 | "execution_count": 35, 22 | "id": "e5f00136-0f38-46f2-918b-969d4c02707d", 23 | "metadata": {}, 24 | "outputs": [], 25 | "source": [ 26 | "llm = OpenAI(temperature=0)\n", 27 | "zapier = ZapierNLAWrapper()\n", 28 | "toolkit = ZapierToolkit.from_zapier_nla_wrapper(zapier)\n", 29 | "agent = initialize_agent(toolkit.get_tools(), llm, agent=\"zero-shot-react-description\", verbose=True)" 30 | ] 31 | }, 32 | { 33 | "cell_type": "code", 34 | "execution_count": 36, 35 | "id": "4525d66e-b40b-42bf-9dfb-0f901a479074", 36 | "metadata": {}, 37 | "outputs": [ 38 | { 39 | "name": "stdout", 40 | "output_type": "stream", 41 | "text": [ 42 | "\n", 43 | "\n", 44 | "\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n", 45 | "\u001b[32;1m\u001b[1;3m I need to craft an email that will convince Dylan to visit the website.\n", 46 | "Action: Gmail: Send Email\n", 47 | "Action Input: Send an email to Dylan@starmorph.com with the subject \"Visit Starmorph.com to Help Your Small Business Integrate GPT-3 Services Today\" and the body \"Dear Dylan, \n", 48 | "\n", 49 | "Are you looking for a way to help your small business integrate GPT-3 services? Look no further than Starmorph.com! Our website provides a comprehensive suite of tools and services to help you get the most out of GPT-3. \n", 50 | "\n", 51 | "Visit Starmorph.com today to learn more about how we can help you get the most out of GPT-3. \n", 52 | "\n", 53 | "[Hyperlink to Starmorph.com]\n", 54 | "\n", 55 | "Sincerely, \n", 56 | "\n", 57 | "[Your Name]\n", 58 | "\n", 59 | "Cc: [Your Email]\n", 60 | "\"\u001b[0m\n", 61 | "Observation: \u001b[36;1m\u001b[1;3m{\"labelIds\": \"UNREAD, Label_2285473055360660832, SENT, INBOX\"}\u001b[0m\n", 62 | "Thought:\u001b[32;1m\u001b[1;3m The email has been sent.\n", 63 | "Final Answer: The email has been sent to Dylan@starmorph.com with the subject \"Visit Starmorph.com to Help Your Small Business Integrate GPT-3 Services Today\" and the body \"Dear Dylan, \n", 64 | "\n", 65 | "Are you looking for a way to help your small business integrate GPT-3 services? Look no further than Starmorph.com! Our website provides a comprehensive suite of tools and services to help you get the most out of GPT-3. \n", 66 | "\n", 67 | "Visit Starmorph.com today to learn more about how we can help you get the most out of GPT-3. \n", 68 | "\n", 69 | "[Hyperlink to Starmorph.com]\n", 70 | "\n", 71 | "Sincerely, \n", 72 | "\n", 73 | "[Your Name]\n", 74 | "\n", 75 | "Cc: [Your Email]\n", 76 | "\".\u001b[0m\n", 77 | "\n", 78 | "\u001b[1m> Finished chain.\u001b[0m\n" 79 | ] 80 | }, 81 | { 82 | "data": { 83 | "text/plain": [ 84 | "'The email has been sent to Dylan@starmorph.com with the subject \"Visit Starmorph.com to Help Your Small Business Integrate GPT-3 Services Today\" and the body \"Dear Dylan, \\n\\nAre you looking for a way to help your small business integrate GPT-3 services? Look no further than Starmorph.com! Our website provides a comprehensive suite of tools and services to help you get the most out of GPT-3. \\n\\nVisit Starmorph.com today to learn more about how we can help you get the most out of GPT-3. \\n\\n[Hyperlink to Starmorph.com]\\n\\nSincerely, \\n\\n[Your Name]\\n\\nCc: [Your Email]\\n\".'" 85 | ] 86 | }, 87 | "execution_count": 36, 88 | "metadata": {}, 89 | "output_type": "execute_result" 90 | } 91 | ], 92 | "source": [ 93 | "agent.run(\"Send an Email to Dylan@starmorph.com via gmail that is a pitch for why you should visit https://starmorph.com to help your small business integrate GPT-3 services today. Provide a hyperlink to the website and make the email likely to convert to website visitors.\")" 94 | ] 95 | } 96 | ], 97 | "metadata": { 98 | "kernelspec": { 99 | "display_name": "Python 3 (ipykernel)", 100 | "language": "python", 101 | "name": "python3" 102 | }, 103 | "language_info": { 104 | "codemirror_mode": { 105 | "name": "ipython", 106 | "version": 3 107 | }, 108 | "file_extension": ".py", 109 | "mimetype": "text/x-python", 110 | "name": "python", 111 | "nbconvert_exporter": "python", 112 | "pygments_lexer": "ipython3", 113 | "version": "3.9.12" 114 | } 115 | }, 116 | "nbformat": 4, 117 | "nbformat_minor": 5 118 | } 119 | --------------------------------------------------------------------------------