master 1c1e3cbc30c2 cached
9 files
101.8 KB
41.7k tokens
16 symbols
1 requests
Download .txt
Repository: bhattbhavesh91/gpt-3-simple-tutorial
Branch: master
Commit: 1c1e3cbc30c2
Files: 9
Total size: 101.8 KB

Directory structure:
gitextract_qjsi6js3/

├── .github/
│   └── FUNDING.yml
├── .gitignore
├── LICENSE
├── README.md
├── gpt-3-notebook.ipynb
├── gpt-pandas-code-generation.ipynb
├── gpt-pandas-matplotlib.ipynb
├── gpt.py
└── iris.csv

================================================
FILE CONTENTS
================================================

================================================
FILE: .github/FUNDING.yml
================================================
# These are supported funding model platforms
custom: ['https://www.buymeacoffee.com/bhattbhavesh91']


================================================
FILE: .gitignore
================================================
MANIFEST
build
dist
_build
docs/man/*.gz
docs/source/api/generated
docs/source/config.rst
docs/gh-pages
notebook/i18n/*/LC_MESSAGES/*.mo
notebook/i18n/*/LC_MESSAGES/nbjs.json
notebook/static/components
notebook/static/style/*.min.css*
notebook/static/*/js/built/
notebook/static/*/built/
notebook/static/built/
notebook/static/*/js/main.min.js*
notebook/static/lab/*bundle.js
node_modules
*.py[co]
__pycache__
*.egg-info
*~
*.bak
.ipynb_checkpoints
.tox
.DS_Store
\#*#
.#*
.coverage
.pytest_cache
src

*.swp
*.map
.idea/
Read the Docs
config.rst

/.project
/.pydevproject

package-lock.json
geckodriver.log


================================================
FILE: LICENSE
================================================
                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "[]"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright [yyyy] [name of copyright owner]

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.


================================================
FILE: README.md
================================================
# OpenAI's GPT-3 to generate SQL from Natural Language!

**If you like my work, you can support me by buying me a coffee by clicking the link below**

<a href="https://www.buymeacoffee.com/bhattbhavesh91" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: 41px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" ></a>

## To view the video

<table>
   <tr>
      <td><a href="http://www.youtube.com/watch?v=9g66yO0Jues" target="_blank"><img height="50" src = "https://img.shields.io/youtube/views/9g66yO0Jues?color=blue&label=Watch%20on%20YouTube&logo=youtube&logoColor=red&style=for-the-badge"></a></td>
   </tr>
</table>

or click on the image below

[![OpenAI's GPT-3 to generate SQL from Natural Language!](http://img.youtube.com/vi/9g66yO0Jues/0.jpg)](http://www.youtube.com/watch?v=9g66yO0Jues)

## Follow Me
<a href="https://twitter.com/_bhaveshbhatt" target="_blank"><img class="ai-subscribed-social-icon" src="https://bhattbhavesh91.github.io/assets/images/tw.png" width="30"></a>
<a href="https://www.youtube.com/bhaveshbhatt8791/" target="_blank"><img class="ai-subscribed-social-icon" src="https://bhattbhavesh91.github.io/assets/images/ytb.png" width="30"></a>
<a href="https://www.youtube.com/PythonTricks/" target="_blank"><img class="ai-subscribed-social-icon" src="https://bhattbhavesh91.github.io/assets/images/python_logo.png" width="30"></a>
<a href="https://github.com/bhattbhavesh91" target="_blank"><img class="ai-subscribed-social-icon" src="https://bhattbhavesh91.github.io/assets/images/gthb.png" width="30"></a>
<a href="https://www.linkedin.com/in/bhattbhavesh91/" target="_blank"><img class="ai-subscribed-social-icon" src="https://bhattbhavesh91.github.io/assets/images/lnkdn.png" width="30"></a>

<h3 align="center">Show your support by starring the repository 🙂</h3>


================================================
FILE: gpt-3-notebook.ipynb
================================================
{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"GPT-3-Demo.ipynb","provenance":[],"collapsed_sections":[],"authorship_tag":"ABX9TyNfqR7vWsi34k6mv0Yi02Yy"},"kernelspec":{"name":"python3","display_name":"Python 3"}},"cells":[{"cell_type":"code","metadata":{"id":"heIf5_ducY8T","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":297},"executionInfo":{"status":"ok","timestamp":1595471247881,"user_tz":-330,"elapsed":8803,"user":{"displayName":"Bhavesh Bhatt","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggn1iyaPhugkkpQYFRw42nt9ToNB-Rit7YeWtI4Zw=s64","userId":"01561702845917398436"}},"outputId":"c668882d-1977-4c74-bdd5-584d27bd82f3"},"source":["!pip install openai"],"execution_count":1,"outputs":[{"output_type":"stream","text":["Collecting openai\n","\u001b[?25l  Downloading https://files.pythonhosted.org/packages/a8/65/c7461f4c87984534683f480ea5742777bc39bbf5721123194c2d0347dc1f/openai-0.2.4.tar.gz (157kB)\n","\r\u001b[K     |██                              | 10kB 13.1MB/s eta 0:00:01\r\u001b[K     |████▏                           | 20kB 1.6MB/s eta 0:00:01\r\u001b[K     |██████▎                         | 30kB 1.8MB/s eta 0:00:01\r\u001b[K     |████████▍                       | 40kB 2.1MB/s eta 0:00:01\r\u001b[K     |██████████▍                     | 51kB 2.0MB/s eta 0:00:01\r\u001b[K     |████████████▌                   | 61kB 2.1MB/s eta 0:00:01\r\u001b[K     |██████████████▋                 | 71kB 2.3MB/s eta 0:00:01\r\u001b[K     |████████████████▊               | 81kB 2.4MB/s eta 0:00:01\r\u001b[K     |██████████████████▊             | 92kB 2.6MB/s eta 0:00:01\r\u001b[K     |████████████████████▉           | 102kB 2.8MB/s eta 0:00:01\r\u001b[K     |███████████████████████         | 112kB 2.8MB/s eta 0:00:01\r\u001b[K     |█████████████████████████       | 122kB 2.8MB/s eta 0:00:01\r\u001b[K     |███████████████████████████     | 133kB 2.8MB/s eta 0:00:01\r\u001b[K     |█████████████████████████████▏  | 143kB 2.8MB/s eta 0:00:01\r\u001b[K     |███████████████████████████████▎| 153kB 2.8MB/s eta 0:00:01\r\u001b[K     |████████████████████████████████| 163kB 2.8MB/s \n","\u001b[?25hRequirement already satisfied: requests>=2.20 in /usr/local/lib/python3.6/dist-packages (from openai) (2.23.0)\n","Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.6/dist-packages (from requests>=2.20->openai) (2020.6.20)\n","Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.6/dist-packages (from requests>=2.20->openai) (3.0.4)\n","Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.6/dist-packages (from requests>=2.20->openai) (2.10)\n","Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.6/dist-packages (from requests>=2.20->openai) (1.24.3)\n","Building wheels for collected packages: openai\n","  Building wheel for openai (setup.py) ... \u001b[?25l\u001b[?25hdone\n","  Created wheel for openai: filename=openai-0.2.4-cp36-none-any.whl size=170709 sha256=7ae56fa654e2071a250acdeed89d5fb874faa15c8755bb252607201d0e434798\n","  Stored in directory: /root/.cache/pip/wheels/74/96/c8/c6e170929c276b836613e1b9985343b501fe455e53d85e7d48\n","Successfully built openai\n","Installing collected packages: openai\n","Successfully installed openai-0.2.4\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"JIObOT-ybumY","colab_type":"code","colab":{},"executionInfo":{"status":"ok","timestamp":1595471299970,"user_tz":-330,"elapsed":951,"user":{"displayName":"Bhavesh Bhatt","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggn1iyaPhugkkpQYFRw42nt9ToNB-Rit7YeWtI4Zw=s64","userId":"01561702845917398436"}}},"source":["import json\n","import openai"],"execution_count":2,"outputs":[]},{"cell_type":"code","metadata":{"id":"m42z9jQxqA2b","colab_type":"code","colab":{},"executionInfo":{"status":"ok","timestamp":1595471313449,"user_tz":-330,"elapsed":1104,"user":{"displayName":"Bhavesh Bhatt","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggn1iyaPhugkkpQYFRw42nt9ToNB-Rit7YeWtI4Zw=s64","userId":"01561702845917398436"}}},"source":["with open('GPT_SECRET_KEY.json') as f:\n","    data = json.load(f)"],"execution_count":3,"outputs":[]},{"cell_type":"code","metadata":{"id":"75Yg2gB7p3Q0","colab_type":"code","colab":{},"executionInfo":{"status":"ok","timestamp":1595471324175,"user_tz":-330,"elapsed":703,"user":{"displayName":"Bhavesh Bhatt","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggn1iyaPhugkkpQYFRw42nt9ToNB-Rit7YeWtI4Zw=s64","userId":"01561702845917398436"}}},"source":["openai.api_key = data[\"API_KEY\"]"],"execution_count":4,"outputs":[]},{"cell_type":"code","metadata":{"id":"N3sAHxJrhBzK","colab_type":"code","colab":{},"executionInfo":{"status":"ok","timestamp":1595471367430,"user_tz":-330,"elapsed":1044,"user":{"displayName":"Bhavesh Bhatt","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggn1iyaPhugkkpQYFRw42nt9ToNB-Rit7YeWtI4Zw=s64","userId":"01561702845917398436"}}},"source":["from gpt import GPT\n","from gpt import Example"],"execution_count":5,"outputs":[]},{"cell_type":"code","metadata":{"id":"XiV0D9PihB2N","colab_type":"code","colab":{},"executionInfo":{"status":"ok","timestamp":1595471538287,"user_tz":-330,"elapsed":1248,"user":{"displayName":"Bhavesh Bhatt","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggn1iyaPhugkkpQYFRw42nt9ToNB-Rit7YeWtI4Zw=s64","userId":"01561702845917398436"}}},"source":["gpt = GPT(engine=\"davinci\",\n","          temperature=0.5,\n","          max_tokens=100)"],"execution_count":6,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"WwVcHYMOvGiU","colab_type":"text"},"source":["# Adding Examples for GPT Model"]},{"cell_type":"code","metadata":{"id":"0iLR1Y6YqTh7","colab_type":"code","colab":{},"executionInfo":{"status":"ok","timestamp":1595471715638,"user_tz":-330,"elapsed":1343,"user":{"displayName":"Bhavesh Bhatt","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggn1iyaPhugkkpQYFRw42nt9ToNB-Rit7YeWtI4Zw=s64","userId":"01561702845917398436"}}},"source":["gpt.add_example(Example('Fetch unique values of DEPARTMENT from Worker table.', \n","                        'Select distinct DEPARTMENT from Worker;'))"],"execution_count":7,"outputs":[]},{"cell_type":"code","metadata":{"id":"x28YlU1-qrCW","colab_type":"code","colab":{},"executionInfo":{"status":"ok","timestamp":1595471721203,"user_tz":-330,"elapsed":1433,"user":{"displayName":"Bhavesh Bhatt","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggn1iyaPhugkkpQYFRw42nt9ToNB-Rit7YeWtI4Zw=s64","userId":"01561702845917398436"}}},"source":["gpt.add_example(Example('Print the first three characters of FIRST_NAME from Worker table.', \n","                        'Select substring(FIRST_NAME,1,3) from Worker;'))"],"execution_count":8,"outputs":[]},{"cell_type":"code","metadata":{"id":"1C10LyYPqrFX","colab_type":"code","colab":{},"executionInfo":{"status":"ok","timestamp":1595471721205,"user_tz":-330,"elapsed":883,"user":{"displayName":"Bhavesh Bhatt","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggn1iyaPhugkkpQYFRw42nt9ToNB-Rit7YeWtI4Zw=s64","userId":"01561702845917398436"}}},"source":["gpt.add_example(Example(\"Find the position of the alphabet ('a') in the first name column 'Amitabh' from Worker table.\", \n","                        \"Select INSTR(FIRST_NAME, BINARY'a') from Worker where FIRST_NAME = 'Amitabh';\"))"],"execution_count":9,"outputs":[]},{"cell_type":"code","metadata":{"id":"0JvjODWbsBWP","colab_type":"code","colab":{},"executionInfo":{"status":"ok","timestamp":1595471723625,"user_tz":-330,"elapsed":964,"user":{"displayName":"Bhavesh Bhatt","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggn1iyaPhugkkpQYFRw42nt9ToNB-Rit7YeWtI4Zw=s64","userId":"01561702845917398436"}}},"source":["gpt.add_example(Example(\"Print the FIRST_NAME from Worker table after replacing 'a' with 'A'.\", \n","                        \"Select CONCAT(FIRST_NAME, ' ', LAST_NAME) AS 'COMPLETE_NAME' from Worker;\"))"],"execution_count":10,"outputs":[]},{"cell_type":"code","metadata":{"id":"uNsH4OeqsKjM","colab_type":"code","colab":{},"executionInfo":{"status":"ok","timestamp":1595471760833,"user_tz":-330,"elapsed":958,"user":{"displayName":"Bhavesh Bhatt","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggn1iyaPhugkkpQYFRw42nt9ToNB-Rit7YeWtI4Zw=s64","userId":"01561702845917398436"}}},"source":["gpt.add_example(Example(\"Display the second highest salary from the Worker table.\", \n","                        \"Select max(Salary) from Worker where Salary not in (Select max(Salary) from Worker);\"))"],"execution_count":11,"outputs":[]},{"cell_type":"code","metadata":{"id":"zhXh5g-jsKnl","colab_type":"code","colab":{},"executionInfo":{"status":"ok","timestamp":1595471795232,"user_tz":-330,"elapsed":1075,"user":{"displayName":"Bhavesh Bhatt","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggn1iyaPhugkkpQYFRw42nt9ToNB-Rit7YeWtI4Zw=s64","userId":"01561702845917398436"}}},"source":["gpt.add_example(Example(\"Display the highest salary from the Worker table.\", \n","                        \"Select max(Salary) from Worker;\"))"],"execution_count":12,"outputs":[]},{"cell_type":"code","metadata":{"id":"wWjmZe-Ntexm","colab_type":"code","colab":{},"executionInfo":{"status":"ok","timestamp":1595471796602,"user_tz":-330,"elapsed":882,"user":{"displayName":"Bhavesh Bhatt","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggn1iyaPhugkkpQYFRw42nt9ToNB-Rit7YeWtI4Zw=s64","userId":"01561702845917398436"}}},"source":["gpt.add_example(Example(\"Fetch the count of employees working in the department Admin.\", \n","                        \"SELECT COUNT(*) FROM worker WHERE DEPARTMENT = 'Admin';\"))"],"execution_count":13,"outputs":[]},{"cell_type":"code","metadata":{"id":"Q9xuF--Kt_xh","colab_type":"code","colab":{},"executionInfo":{"status":"ok","timestamp":1595471799951,"user_tz":-330,"elapsed":1149,"user":{"displayName":"Bhavesh Bhatt","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggn1iyaPhugkkpQYFRw42nt9ToNB-Rit7YeWtI4Zw=s64","userId":"01561702845917398436"}}},"source":["gpt.add_example(Example(\"Get all details of the Workers whose SALARY lies between 100000 and 500000.\", \n","                        \"Select * from Worker where SALARY between 100000 and 500000;\"))"],"execution_count":14,"outputs":[]},{"cell_type":"code","metadata":{"id":"z5jRwDCcuauE","colab_type":"code","colab":{},"executionInfo":{"status":"ok","timestamp":1595471800475,"user_tz":-330,"elapsed":786,"user":{"displayName":"Bhavesh Bhatt","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggn1iyaPhugkkpQYFRw42nt9ToNB-Rit7YeWtI4Zw=s64","userId":"01561702845917398436"}}},"source":["gpt.add_example(Example(\"Get Salary details of the Workers\", \n","                        \"Select Salary from Worker\"))"],"execution_count":15,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"3mI7FmwSu9AA","colab_type":"text"},"source":["# Example 1"]},{"cell_type":"code","metadata":{"id":"sWSmXABfrdTm","colab_type":"code","colab":{},"executionInfo":{"status":"ok","timestamp":1595471857682,"user_tz":-330,"elapsed":1211,"user":{"displayName":"Bhavesh Bhatt","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggn1iyaPhugkkpQYFRw42nt9ToNB-Rit7YeWtI4Zw=s64","userId":"01561702845917398436"}}},"source":["prompt = \"Display the lowest salary from the Worker table.\""],"execution_count":16,"outputs":[]},{"cell_type":"code","metadata":{"id":"pVzvJtmRqTku","colab_type":"code","colab":{},"executionInfo":{"status":"ok","timestamp":1595471890838,"user_tz":-330,"elapsed":2494,"user":{"displayName":"Bhavesh Bhatt","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggn1iyaPhugkkpQYFRw42nt9ToNB-Rit7YeWtI4Zw=s64","userId":"01561702845917398436"}}},"source":["output = gpt.submit_request(prompt)"],"execution_count":17,"outputs":[]},{"cell_type":"code","metadata":{"id":"niqyIPAyoLQb","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":35},"executionInfo":{"status":"ok","timestamp":1595471926542,"user_tz":-330,"elapsed":1366,"user":{"displayName":"Bhavesh Bhatt","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggn1iyaPhugkkpQYFRw42nt9ToNB-Rit7YeWtI4Zw=s64","userId":"01561702845917398436"}},"outputId":"853cd2a0-ec4e-4454-90b8-cb8be70b0d4f"},"source":["output.choices[0].text"],"execution_count":19,"outputs":[{"output_type":"execute_result","data":{"application/vnd.google.colaboratory.intrinsic+json":{"type":"string"},"text/plain":["'output: Select min(Salary) from Worker;\\n'"]},"metadata":{"tags":[]},"execution_count":19}]},{"cell_type":"markdown","metadata":{"id":"LA3DyhGJu_8o","colab_type":"text"},"source":["# Example 2"]},{"cell_type":"code","metadata":{"id":"_OdI6bFLtpel","colab_type":"code","colab":{},"executionInfo":{"status":"ok","timestamp":1595471994566,"user_tz":-330,"elapsed":1325,"user":{"displayName":"Bhavesh Bhatt","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggn1iyaPhugkkpQYFRw42nt9ToNB-Rit7YeWtI4Zw=s64","userId":"01561702845917398436"}}},"source":["prompt = \"Tell me the count of employees working in the department HR.\""],"execution_count":20,"outputs":[]},{"cell_type":"code","metadata":{"id":"XnjQ0kfbtpkE","colab_type":"code","colab":{},"executionInfo":{"status":"ok","timestamp":1595472001159,"user_tz":-330,"elapsed":2828,"user":{"displayName":"Bhavesh Bhatt","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggn1iyaPhugkkpQYFRw42nt9ToNB-Rit7YeWtI4Zw=s64","userId":"01561702845917398436"}}},"source":["output = gpt.submit_request(prompt)"],"execution_count":21,"outputs":[]},{"cell_type":"code","metadata":{"id":"Z9Yo-bZotph4","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":35},"executionInfo":{"status":"ok","timestamp":1595472005315,"user_tz":-330,"elapsed":1008,"user":{"displayName":"Bhavesh Bhatt","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggn1iyaPhugkkpQYFRw42nt9ToNB-Rit7YeWtI4Zw=s64","userId":"01561702845917398436"}},"outputId":"0e1572e6-bceb-42c8-d67f-4f29a156745c"},"source":["output.choices[0].text"],"execution_count":22,"outputs":[{"output_type":"execute_result","data":{"application/vnd.google.colaboratory.intrinsic+json":{"type":"string"},"text/plain":["\"output: SELECT COUNT(*) FROM worker WHERE DEPARTMENT = 'HR';\\n\""]},"metadata":{"tags":[]},"execution_count":22}]},{"cell_type":"markdown","metadata":{"id":"dnB7TCA_vCkF","colab_type":"text"},"source":["# Example 3"]},{"cell_type":"code","metadata":{"id":"GkaHZLIzt3pQ","colab_type":"code","colab":{},"executionInfo":{"status":"ok","timestamp":1595472072925,"user_tz":-330,"elapsed":946,"user":{"displayName":"Bhavesh Bhatt","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggn1iyaPhugkkpQYFRw42nt9ToNB-Rit7YeWtI4Zw=s64","userId":"01561702845917398436"}}},"source":["prompt = \"Get salary details of the Workers whose AGE lies between 25 and 35\""],"execution_count":23,"outputs":[]},{"cell_type":"code","metadata":{"id":"G6GmvbukmLCK","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":51},"executionInfo":{"status":"ok","timestamp":1595472104996,"user_tz":-330,"elapsed":3152,"user":{"displayName":"Bhavesh Bhatt","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggn1iyaPhugkkpQYFRw42nt9ToNB-Rit7YeWtI4Zw=s64","userId":"01561702845917398436"}},"outputId":"21c8f471-b272-47ed-dd18-36c94fbf6936"},"source":["print(gpt.get_top_reply(prompt))"],"execution_count":24,"outputs":[{"output_type":"stream","text":["output: Select Salary from Worker where AGE between 25 and 35;\n","\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"0ZaLCw6zgqxh","colab_type":"code","colab":{}},"source":[""],"execution_count":null,"outputs":[]}]}

================================================
FILE: gpt-pandas-code-generation.ipynb
================================================
{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "GPT-3-Pandas-Code.ipynb",
      "provenance": [],
      "collapsed_sections": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    }
  },
  "cells": [
    {
      "cell_type": "code",
      "metadata": {
        "id": "heIf5_ducY8T",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 297
        },
        "outputId": "fe2165bc-0b43-4a1b-a9b2-a755ae1d2cd8"
      },
      "source": [
        "!pip install openai"
      ],
      "execution_count": 1,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Collecting openai\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/a8/65/c7461f4c87984534683f480ea5742777bc39bbf5721123194c2d0347dc1f/openai-0.2.4.tar.gz (157kB)\n",
            "\u001b[K     |████████████████████████████████| 163kB 2.7MB/s \n",
            "\u001b[?25hRequirement already satisfied: requests>=2.20 in /usr/local/lib/python3.6/dist-packages (from openai) (2.23.0)\n",
            "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.6/dist-packages (from requests>=2.20->openai) (2020.6.20)\n",
            "Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.6/dist-packages (from requests>=2.20->openai) (3.0.4)\n",
            "Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.6/dist-packages (from requests>=2.20->openai) (2.10)\n",
            "Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.6/dist-packages (from requests>=2.20->openai) (1.24.3)\n",
            "Building wheels for collected packages: openai\n",
            "  Building wheel for openai (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
            "  Created wheel for openai: filename=openai-0.2.4-cp36-none-any.whl size=170709 sha256=3821b7d0954e25e78fcdb4a7718777dcdfa08c7ed830290c2c299c0dae9d8ee6\n",
            "  Stored in directory: /root/.cache/pip/wheels/74/96/c8/c6e170929c276b836613e1b9985343b501fe455e53d85e7d48\n",
            "Successfully built openai\n",
            "Installing collected packages: openai\n",
            "Successfully installed openai-0.2.4\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "JIObOT-ybumY",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "import json\n",
        "import openai\n",
        "import numpy as np\n",
        "import pandas as pd"
      ],
      "execution_count": 2,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "m42z9jQxqA2b",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "with open('GPT_SECRET_KEY.json') as f:\n",
        "    data = json.load(f)"
      ],
      "execution_count": 3,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "75Yg2gB7p3Q0",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "openai.api_key = data[\"API_KEY\"]"
      ],
      "execution_count": 4,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "N3sAHxJrhBzK",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "from gpt import GPT\n",
        "from gpt import Example"
      ],
      "execution_count": 5,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "XiV0D9PihB2N",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "gpt = GPT(engine=\"davinci\",\n",
        "          temperature=0.5,\n",
        "          max_tokens=100)"
      ],
      "execution_count": 6,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "6qLap8Xgvwjt",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "df = pd.DataFrame({\"Gender\": [\"boy\", \"boy\", \"boy\", \"boy\", \"boy\",\n",
        "                         \"girl\", \"girl\", \"girl\", \"girl\"],\n",
        "                   \"Division\": [\"one\", \"one\", \"one\", \"two\", \"two\",\n",
        "                         \"one\", \"one\", \"two\", \"two\"],\n",
        "                   \"Marks\": [50, 55, 67, 85, 44, 84, 65, 56, 87]})"
      ],
      "execution_count": 7,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "JGQIWZO-AazG",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 324
        },
        "outputId": "744be30f-e298-44b9-edf2-02379817d368"
      },
      "source": [
        "df"
      ],
      "execution_count": 8,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>Gender</th>\n",
              "      <th>Division</th>\n",
              "      <th>Marks</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>boy</td>\n",
              "      <td>one</td>\n",
              "      <td>50</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>boy</td>\n",
              "      <td>one</td>\n",
              "      <td>55</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>boy</td>\n",
              "      <td>one</td>\n",
              "      <td>67</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>boy</td>\n",
              "      <td>two</td>\n",
              "      <td>85</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>boy</td>\n",
              "      <td>two</td>\n",
              "      <td>44</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>5</th>\n",
              "      <td>girl</td>\n",
              "      <td>one</td>\n",
              "      <td>84</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>6</th>\n",
              "      <td>girl</td>\n",
              "      <td>one</td>\n",
              "      <td>65</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>7</th>\n",
              "      <td>girl</td>\n",
              "      <td>two</td>\n",
              "      <td>56</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>8</th>\n",
              "      <td>girl</td>\n",
              "      <td>two</td>\n",
              "      <td>87</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "  Gender Division  Marks\n",
              "0    boy      one     50\n",
              "1    boy      one     55\n",
              "2    boy      one     67\n",
              "3    boy      two     85\n",
              "4    boy      two     44\n",
              "5   girl      one     84\n",
              "6   girl      one     65\n",
              "7   girl      two     56\n",
              "8   girl      two     87"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 8
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "WwVcHYMOvGiU",
        "colab_type": "text"
      },
      "source": [
        "# Adding Examples for GPT Model"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "0iLR1Y6YqTh7",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "gpt.add_example(Example('How many unique values in Division Column?', \n",
        "                        'df[\"Division\"].nunique()'))"
      ],
      "execution_count": 9,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "x28YlU1-qrCW",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "gpt.add_example(Example('Find the Division of boy who scored 55 marks', \n",
        "                        'df.loc[(df.loc[:, \"Gender\"] == \"boy\") & (df.loc[:, \"Marks\"] == 55), \"Division\"]'))"
      ],
      "execution_count": 10,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "yBQMrnIQx3Uv",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "gpt.add_example(Example('Find the average Marks scored by Girls', \n",
        "                        'np.mean(df.loc[(df.loc[:, \"Gender\"] == \"girl\"), \"Marks\"])'))"
      ],
      "execution_count": 11,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "sua6IdZgw4tR",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        ""
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "3mI7FmwSu9AA",
        "colab_type": "text"
      },
      "source": [
        "# Example 1"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "sWSmXABfrdTm",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "prompt = \"Display Division of girl who scored maximum marks\""
      ],
      "execution_count": 12,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "pVzvJtmRqTku",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 71
        },
        "outputId": "f1ee2728-2b22-4835-e437-aa7221cf1201"
      },
      "source": [
        "print(gpt.get_top_reply(prompt))"
      ],
      "execution_count": 13,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "output: df.loc[(df.loc[:, \"Gender\"] == \"girl\") & (df.loc[:, \"Marks\"] == max(df.loc[:, \"Marks\"])), \"Division\"]\n",
            "\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "BA_Kzqnjdwwg",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 51
        },
        "outputId": "c0bc77c0-e964-45c3-dbe6-7e6b353c8254"
      },
      "source": [
        "df.loc[(df.loc[:, \"Gender\"] == \"girl\") & \n",
        "       (df.loc[:, \"Marks\"] == max(df.loc[:, \"Marks\"])), \n",
        "       \"Division\"]"
      ],
      "execution_count": 14,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "8    two\n",
              "Name: Division, dtype: object"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 14
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "NopaHtl1_9rH",
        "colab_type": "text"
      },
      "source": [
        "# Example 2"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "eO4IW_H_y_5F",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "prompt = \"Find the median Marks scored by Boys\""
      ],
      "execution_count": 15,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Q8ldVXxhyGVD",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 51
        },
        "outputId": "611ff255-3feb-4f98-d1ff-197a8c0466eb"
      },
      "source": [
        "print(gpt.get_top_reply(prompt))"
      ],
      "execution_count": 16,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "output: np.median(df.loc[(df.loc[:, \"Gender\"] == \"boy\"), \"Marks\"])\n",
            "\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "wUi-UN62zJe_",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "4f5a164e-03ac-40ed-a135-f5aee4f45c59"
      },
      "source": [
        "np.median(df.loc[(df.loc[:, \"Gender\"] == \"boy\"), \"Marks\"])"
      ],
      "execution_count": 17,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "55.0"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 17
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Cf6vxbTADRpf",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        ""
      ],
      "execution_count": null,
      "outputs": []
    }
  ]
}

================================================
FILE: gpt-pandas-matplotlib.ipynb
================================================
{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "gpt-pandas-code-generation.ipynb",
      "provenance": [],
      "collapsed_sections": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    }
  },
  "cells": [
    {
      "cell_type": "code",
      "metadata": {
        "id": "heIf5_ducY8T",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 297
        },
        "outputId": "74217a60-6e07-425c-a94a-51387939b7ee"
      },
      "source": [
        "!pip install openai"
      ],
      "execution_count": 1,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Collecting openai\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/a8/65/c7461f4c87984534683f480ea5742777bc39bbf5721123194c2d0347dc1f/openai-0.2.4.tar.gz (157kB)\n",
            "\r\u001b[K     |██                              | 10kB 15.3MB/s eta 0:00:01\r\u001b[K     |████▏                           | 20kB 6.1MB/s eta 0:00:01\r\u001b[K     |██████▎                         | 30kB 7.7MB/s eta 0:00:01\r\u001b[K     |████████▍                       | 40kB 7.4MB/s eta 0:00:01\r\u001b[K     |██████████▍                     | 51kB 6.5MB/s eta 0:00:01\r\u001b[K     |████████████▌                   | 61kB 6.9MB/s eta 0:00:01\r\u001b[K     |██████████████▋                 | 71kB 7.8MB/s eta 0:00:01\r\u001b[K     |████████████████▊               | 81kB 7.9MB/s eta 0:00:01\r\u001b[K     |██████████████████▊             | 92kB 8.5MB/s eta 0:00:01\r\u001b[K     |████████████████████▉           | 102kB 8.4MB/s eta 0:00:01\r\u001b[K     |███████████████████████         | 112kB 8.4MB/s eta 0:00:01\r\u001b[K     |█████████████████████████       | 122kB 8.4MB/s eta 0:00:01\r\u001b[K     |███████████████████████████     | 133kB 8.4MB/s eta 0:00:01\r\u001b[K     |█████████████████████████████▏  | 143kB 8.4MB/s eta 0:00:01\r\u001b[K     |███████████████████████████████▎| 153kB 8.4MB/s eta 0:00:01\r\u001b[K     |████████████████████████████████| 163kB 8.4MB/s \n",
            "\u001b[?25hRequirement already satisfied: requests>=2.20 in /usr/local/lib/python3.6/dist-packages (from openai) (2.23.0)\n",
            "Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.6/dist-packages (from requests>=2.20->openai) (1.24.3)\n",
            "Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.6/dist-packages (from requests>=2.20->openai) (3.0.4)\n",
            "Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.6/dist-packages (from requests>=2.20->openai) (2.10)\n",
            "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.6/dist-packages (from requests>=2.20->openai) (2020.6.20)\n",
            "Building wheels for collected packages: openai\n",
            "  Building wheel for openai (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
            "  Created wheel for openai: filename=openai-0.2.4-cp36-none-any.whl size=170709 sha256=7d8dd1fd8f27ae398961666519a46af67ea9c925b960cd786d619c7f6da3bc54\n",
            "  Stored in directory: /root/.cache/pip/wheels/74/96/c8/c6e170929c276b836613e1b9985343b501fe455e53d85e7d48\n",
            "Successfully built openai\n",
            "Installing collected packages: openai\n",
            "Successfully installed openai-0.2.4\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "JIObOT-ybumY",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 71
        },
        "outputId": "d44d7576-460f-4af2-b668-9f29cec15b74"
      },
      "source": [
        "import json\n",
        "import openai\n",
        "import numpy as np\n",
        "import pandas as pd\n",
        "import matplotlib.pyplot as plt \n",
        "import seaborn as sns"
      ],
      "execution_count": 2,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "/usr/local/lib/python3.6/dist-packages/statsmodels/tools/_testing.py:19: FutureWarning: pandas.util.testing is deprecated. Use the functions in the public API at pandas.testing instead.\n",
            "  import pandas.util.testing as tm\n"
          ],
          "name": "stderr"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "m42z9jQxqA2b",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "with open('GPT_SECRET_KEY.json') as f:\n",
        "    data = json.load(f)"
      ],
      "execution_count": 3,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "75Yg2gB7p3Q0",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "openai.api_key = data[\"API_KEY\"]"
      ],
      "execution_count": 4,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "N3sAHxJrhBzK",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "from gpt import GPT\n",
        "from gpt import Example"
      ],
      "execution_count": 5,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "XiV0D9PihB2N",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "gpt = GPT(engine=\"davinci\",\n",
        "          temperature=0.5,\n",
        "          max_tokens=100)"
      ],
      "execution_count": 6,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "6qLap8Xgvwjt",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "df = pd.DataFrame({\"Gender\": [\"boy\", \"boy\", \"boy\", \"boy\", \"boy\",\n",
        "                         \"girl\", \"girl\", \"girl\", \"girl\"],\n",
        "                   \"Division\": [\"one\", \"one\", \"one\", \"two\", \"two\",\n",
        "                         \"one\", \"one\", \"two\", \"two\"],\n",
        "                   \"Marks\": [50, 55, 67, 85, 44, 84, 65, 56, 87]})"
      ],
      "execution_count": 7,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "JGQIWZO-AazG",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 324
        },
        "outputId": "bdd987fc-929e-450e-d687-6c3b12fa52cf"
      },
      "source": [
        "df"
      ],
      "execution_count": 8,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>Gender</th>\n",
              "      <th>Division</th>\n",
              "      <th>Marks</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>boy</td>\n",
              "      <td>one</td>\n",
              "      <td>50</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>boy</td>\n",
              "      <td>one</td>\n",
              "      <td>55</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>boy</td>\n",
              "      <td>one</td>\n",
              "      <td>67</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>boy</td>\n",
              "      <td>two</td>\n",
              "      <td>85</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>boy</td>\n",
              "      <td>two</td>\n",
              "      <td>44</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>5</th>\n",
              "      <td>girl</td>\n",
              "      <td>one</td>\n",
              "      <td>84</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>6</th>\n",
              "      <td>girl</td>\n",
              "      <td>one</td>\n",
              "      <td>65</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>7</th>\n",
              "      <td>girl</td>\n",
              "      <td>two</td>\n",
              "      <td>56</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>8</th>\n",
              "      <td>girl</td>\n",
              "      <td>two</td>\n",
              "      <td>87</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "  Gender Division  Marks\n",
              "0    boy      one     50\n",
              "1    boy      one     55\n",
              "2    boy      one     67\n",
              "3    boy      two     85\n",
              "4    boy      two     44\n",
              "5   girl      one     84\n",
              "6   girl      one     65\n",
              "7   girl      two     56\n",
              "8   girl      two     87"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 8
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "WwVcHYMOvGiU",
        "colab_type": "text"
      },
      "source": [
        "# Adding Examples for GPT Model"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "0iLR1Y6YqTh7",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "gpt.add_example(Example('How many unique values in Division Column?', \n",
        "                        'df[\"Division\"].nunique()'))"
      ],
      "execution_count": 9,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "x28YlU1-qrCW",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "gpt.add_example(Example('Find the Division of boy who scored 55 marks', \n",
        "                        'df.loc[(df.loc[:, \"Gender\"] == \"boy\") & (df.loc[:, \"Marks\"] == 55), \"Division\"]'))"
      ],
      "execution_count": 10,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "yBQMrnIQx3Uv",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "gpt.add_example(Example('Find the average Marks scored by Girls', \n",
        "                        'np.mean(df.loc[(df.loc[:, \"Gender\"] == \"girl\"), \"Marks\"])'))"
      ],
      "execution_count": 11,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "sua6IdZgw4tR",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        ""
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "3mI7FmwSu9AA",
        "colab_type": "text"
      },
      "source": [
        "# Example 1"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "sWSmXABfrdTm",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "prompt = \"Display Division of girl who scored maximum marks\""
      ],
      "execution_count": 12,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "7RE6DxAyEEy5",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 52
        },
        "outputId": "8258aafd-bfd6-49fd-a4e0-cd80695bf637"
      },
      "source": [
        "gpt.get_top_reply(prompt)"
      ],
      "execution_count": 13,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "application/vnd.google.colaboratory.intrinsic+json": {
              "type": "string"
            },
            "text/plain": [
              "'output: df.loc[(df.loc[:, \"Gender\"] == \"girl\") & (df.loc[:, \"Marks\"] == max(df.loc[:, \"Marks\"])), \"Division\"]\\n'"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 13
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "FkyPKIYCEin4",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 106
        },
        "outputId": "90dcea4c-2f66-451e-baab-fee2b2ba317a"
      },
      "source": [
        "response = gpt.get_top_reply(prompt)\n",
        "print(response)\n",
        "modified_response = response.split(\"output: \")[-1].strip('\\n')\n",
        "eval(modified_response)"
      ],
      "execution_count": 14,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "output: df.loc[(df.loc[:, \"Gender\"] == \"girl\") & (df.loc[:, \"Marks\"] == max(df.loc[:, \"Marks\"])), \"Division\"]\n",
            "\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "8    two\n",
              "Name: Division, dtype: object"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 14
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "NopaHtl1_9rH",
        "colab_type": "text"
      },
      "source": [
        "# Example 2"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "eO4IW_H_y_5F",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "prompt = \"Find the median Marks scored by Boys\""
      ],
      "execution_count": 15,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Q8ldVXxhyGVD",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 69
        },
        "outputId": "d9d5cebf-1a3c-4d3d-e721-04386882d4e2"
      },
      "source": [
        "response = gpt.get_top_reply(prompt)\n",
        "print(response)\n",
        "modified_response = response.split(\"output: \")[-1].strip('\\n')\n",
        "eval(modified_response)"
      ],
      "execution_count": 16,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "output: np.median(df.loc[(df.loc[:, \"Gender\"] == \"boy\"), \"Marks\"])\n",
            "\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "55.0"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 16
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "OIftyCylGZOm",
        "colab_type": "text"
      },
      "source": [
        "# Matplotlib"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "wUi-UN62zJe_",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        ""
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "N_LN5yFvGu9h",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "df = pd.read_csv(\"iris.csv\")"
      ],
      "execution_count": 17,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "JaPeGE21G0OW",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 202
        },
        "outputId": "214ede56-9479-429e-da13-2275797187ed"
      },
      "source": [
        "df.head()"
      ],
      "execution_count": 18,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>sepal_length</th>\n",
              "      <th>sepal_width</th>\n",
              "      <th>petal_length</th>\n",
              "      <th>petal_width</th>\n",
              "      <th>species</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>5.1</td>\n",
              "      <td>3.5</td>\n",
              "      <td>1.4</td>\n",
              "      <td>0.2</td>\n",
              "      <td>setosa</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>4.9</td>\n",
              "      <td>3.0</td>\n",
              "      <td>1.4</td>\n",
              "      <td>0.2</td>\n",
              "      <td>setosa</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>4.7</td>\n",
              "      <td>3.2</td>\n",
              "      <td>1.3</td>\n",
              "      <td>0.2</td>\n",
              "      <td>setosa</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>4.6</td>\n",
              "      <td>3.1</td>\n",
              "      <td>1.5</td>\n",
              "      <td>0.2</td>\n",
              "      <td>setosa</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>5.0</td>\n",
              "      <td>3.6</td>\n",
              "      <td>1.4</td>\n",
              "      <td>0.2</td>\n",
              "      <td>setosa</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "   sepal_length  sepal_width  petal_length  petal_width species\n",
              "0           5.1          3.5           1.4          0.2  setosa\n",
              "1           4.9          3.0           1.4          0.2  setosa\n",
              "2           4.7          3.2           1.3          0.2  setosa\n",
              "3           4.6          3.1           1.5          0.2  setosa\n",
              "4           5.0          3.6           1.4          0.2  setosa"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 18
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Cf6vxbTADRpf",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "gpt.add_example(Example('Plot Scatter Plot between Sepal Length & Sepal Width', \n",
        "                        \"plt.scatter(df['sepal_length'], df['sepal_width'])\"))"
      ],
      "execution_count": 19,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "kw6K2MGOIqQ0",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "gpt.add_example(Example('Plot Bar Plot of Species', \n",
        "                        \"sns.countplot('species',data=df)\"))"
      ],
      "execution_count": 20,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "BdMy31wCI7IT",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "gpt.add_example(Example('Plot a Joint Plot between Sepal Length & Petal Length', \n",
        "                        \"sns.jointplot(x='sepal_length',y='petal_length',data=df)\"))"
      ],
      "execution_count": 21,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "SvQN_tTgKuHO",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "gpt.add_example(Example('Show me the histogram of Petal Length', \n",
        "                        \"plt.hist(df['petal_length'])\"))"
      ],
      "execution_count": 22,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "aAVofRjMId_b",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        ""
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "4ljE2bDJJoY6",
        "colab_type": "text"
      },
      "source": [
        "# Example 3"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "FDd-Cf22Jm2G",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "prompt = \"Show me the scatter plot between petal length and sepal width\""
      ],
      "execution_count": 23,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "_3eVyHEEJ1eH",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 320
        },
        "outputId": "de64cded-7157-428f-f8bc-897a1fafa044"
      },
      "source": [
        "response = gpt.get_top_reply(prompt)\n",
        "print(response)\n",
        "modified_response = response.split(\"output: \")[-1].strip('\\n')\n",
        "eval(modified_response)"
      ],
      "execution_count": 24,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "output: plt.scatter(df['petal_length'], df['sepal_width'])\n",
            "\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "<matplotlib.collections.PathCollection at 0x7f4efbe0e128>"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 24
        },
        {
          "output_type": "display_data",
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD7CAYAAAB68m/qAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAZs0lEQVR4nO3df4wcZ30G8Oe5zRUOA7FMjjac7RwyUf4oJnFySmJdhWhQyo9ExsoPxRGmpKJxhaANDQqqUVRKlCpCVlFUVQIZp1UgroEkxjIRNLWUVJAoMTo7Di5xaJM2xDlCfcQ4wdSi9vnbP3bPuZub2Z3Zd3bmfd95PpLlu92ZnXd2Z75ezzzv+9LMICIi4RuquwEiIlIOFXQRkUiooIuIREIFXUQkEiroIiKRUEEXEYlE7oJOskXyKZIPpTx3E8kZkgc6f/603GaKiEgvZxVY9hYAhwC8NeP5b5nZp92bJCIi/chV0EkuB3AVgL8FcGsZGz7nnHNsfHy8jJcSEWmMffv2/dLMRtOey/sN/W4AnwPwli7LXEvyvQD+A8Bfmtnhbi84Pj6OqampnJsXEREAIPmzrOd6XkMneTWAI2a2r8ti3wUwbmbvAbAHwL0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wFvN7Oq62+OC5AsAJswsitw2yXsB/NDMtpH8HQBvMrNjdbfLFckW2pMDXWZmhfvpBPUN3cx+AOBo3e0oS84JuIPQmSD8eOfX4c6fcL4tJJBcDuAqANvqbossRPJsAO9Fe+IdmNn/xVDMO94P4Pl+ijkQWEGPWZcJuIPRuURxAMARAHvMLNh9AXA3gM8BOF13Q0piAP6V5D6Sm+pujKN3ApgB8E+dS2LbSC6pu1El2QBgR78rq6B7oIwJuH1gZrNmdhHac8peSjLIy2IkrwZwxMz21d2WEv2BmV0M4EMAPtW5fBmqswBcDOArZrYGwG8A/FW9TXLXuXS0DsD9/b6GCnrNckzAHZzOf38fBfDButvSp0kA6zrXnb8J4AqS99XbJDdmNt35+wiA7wC4tN4WOXkJwEvz/gf4ANoFPnQfArDfzP6n3xdQQa9Rzgm4g0BylOTSzs8jAK4E8Gy9reqPmW02s+VmNo72f4EfMbONNTerbySXdG66o3Np4o8ABJsUM7NfADhMcm528PcDCC5IkOJGOFxuAfJNEu0NkjsAvA/AOSRfAvAFM7un3lY5SZ2A28y+V2Ob+nUugHs7d+mHAHzbzIKP+0XidwF8p/39AWcB+Gcz+5d6m+TszwFs71ym+C8EPjF95x/aKwH8mdPrhBRbFBGRbLrkIiISCRV0EZFIqKCLiERCBV1EJBIq6CIikVBBFxGJhAq6iEgkVNBFRCLx/6/h4Vqk6z5/AAAAAElFTkSuQmCC\n",
            "text/plain": [
              "<Figure size 432x288 with 1 Axes>"
            ]
          },
          "metadata": {
            "tags": [],
            "needs_background": "light"
          }
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "6Fx9MuHOKZrn",
        "colab_type": "text"
      },
      "source": [
        "# Example 4"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "1JQQEa_8J3j_",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "prompt = \"Show me the Joint Plot between Petal Length & Petal Length\""
      ],
      "execution_count": 25,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "GNHuzfNsKhzj",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 493
        },
        "outputId": "c6d67a08-91a8-4b5f-e916-17514ca70a3b"
      },
      "source": [
        "response = gpt.get_top_reply(prompt)\n",
        "print(response)\n",
        "modified_response = response.split(\"output: \")[-1].strip('\\n')\n",
        "eval(modified_response)"
      ],
      "execution_count": 26,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "output: sns.jointplot(x='petal_length',y='petal_length',data=df)\n",
            "\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "<seaborn.axisgrid.JointGrid at 0x7f4efbe583c8>"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 26
        },
        {
          "output_type": "display_data",
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZ8AAAGoCAYAAACZneiBAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAf0UlEQVR4nO3df5DcdZ3n8deLToAhBsfIiCRkFolsPDWu0TknGstSPAiiZ+VY90eQrdPbkq3TsqQ4o0RTy3mFF73sUnu1W+oh/lwgWwph6sSVmLoDPXNk3BBYB4GsxkPCgCQRhwQYkzC+74/uCZPO/OjvTH8/3/52Px9VU9P96e75vosq+pXP5/v+fr6OCAEAkNIpRRcAAOg8hA8AIDnCBwCQHOEDAEiO8AEAJDev6ALq0HoHoJ246AJaFTMfAEByhA8AILlWW3abtVsGHy26hFxd3t9bdAkA0DTMfAAAyRE+AIDk2mbZDWhlLAsDJ2LmAwBIjvABACRH+AAAkiN8AADJET4AgOQIHwBAcoQPACA5wgcAkBzhAwBIjvABACRH+AAAkiN8AADJsbEoWkK7b7wJ4ETMfAAAyRE+AIDkCB8AQHKEDwAgOcIHAJAc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qIpL+V9L6IeKOkr0r6bETcKmmXpPdHxOsjYlTS30XEv67dTLBLUqYbwtVCY6Okf1PbJXqXpKsnvOVgbfyLkj5eG7tW1b3gXqPqppi9tfFrVL23y+sjYn1tbKWkqyS9WtL5qm6pBHS8Uu/thraxLyJ21B7fJOlTkl4raXttolCR9MQUn32H7U9IOkPSIkk/lfSdDMdepWow7Kgd61RJ90x4fXyn8XslXVZ7/FZJ/06SIuJO27+Z5u//OCIek6Ta/n3nqXrXV6CjET5oBfUbDB6W9NOIePN0H7J9uqQvqHo76X22/7Ok0zMe26reCG/dFK8fqf0e0+z+fzky4fFs/wbQdlh2QyvotT0eNJdL2impZ3zM9nzbr6m9fljSwtrj8aA5WDtPM2V32zR2Slpt+5W1Yy2w/fszfGaHpD+uvf9iSS+ZpDYA0yB80Ar2qHo3zodU/SL/W1WD5PO2/1nS/ZLeUnvv1yV9qbaEdUTSl1W9l802Sf+U9cARcUDVDrottn+i6pLbq2b42GckXWz7AUl/JOlXkg5HxK9VXb57YELDAYBJcEsFFMr2eZLuqDUMlILt0ySNRcTztdnZF2u3EwfQINafgex6JX3L9imSjkr6UMH1AKXDzAdtzfbtkl5RN/zJiNhWRD0AqggfAEByNBwAAJIjfAAAyRE+AIDkCB8AQHL/H4gZeTz2HCrOAAAAAElFTkSuQmCC\n",
            "text/plain": [
              "<Figure size 432x432 with 3 Axes>"
            ]
          },
          "metadata": {
            "tags": [],
            "needs_background": "light"
          }
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "au8eO5gwLOPg",
        "colab_type": "text"
      },
      "source": [
        "# Example 5"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "eHEQ7C9iKjtD",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "prompt = \"Show me the Distribution of Sepal Length\""
      ],
      "execution_count": 27,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "U93zERQDLYDA",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 491
        },
        "outputId": "ee9e923a-369c-4487-97cc-c7e289f3bac3"
      },
      "source": [
        "response = gpt.get_top_reply(prompt)\n",
        "print(response)\n",
        "modified_response = response.split(\"output: \")[-1].strip('\\n')\n",
        "eval(modified_response)"
      ],
      "execution_count": 28,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "output: plt.hist(df['sepal_length'],bins=50)\n",
            "\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "(array([ 1.,  3.,  1.,  0.,  4.,  2.,  5.,  0.,  6., 10.,  0.,  9.,  4.,\n",
              "         1.,  0.,  6.,  7.,  0.,  6.,  8.,  7.,  0.,  3.,  6.,  0.,  6.,\n",
              "         4.,  9.,  0.,  7.,  5.,  2.,  0.,  8.,  3.,  0.,  4.,  1.,  1.,\n",
              "         0.,  3.,  1.,  0.,  1.,  0.,  1.,  0.,  4.,  0.,  1.]),\n",
              " array([4.3  , 4.372, 4.444, 4.516, 4.588, 4.66 , 4.732, 4.804, 4.876,\n",
              "        4.948, 5.02 , 5.092, 5.164, 5.236, 5.308, 5.38 , 5.452, 5.524,\n",
              "        5.596, 5.668, 5.74 , 5.812, 5.884, 5.956, 6.028, 6.1  , 6.172,\n",
              "        6.244, 6.316, 6.388, 6.46 , 6.532, 6.604, 6.676, 6.748, 6.82 ,\n",
              "        6.892, 6.964, 7.036, 7.108, 7.18 , 7.252, 7.324, 7.396, 7.468,\n",
              "        7.54 , 7.612, 7.684, 7.756, 7.828, 7.9  ]),\n",
              " <a list of 50 Patch objects>)"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 28
        },
        {
          "output_type": "display_data",
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXEAAAD4CAYAAAAaT9YAAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIs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dUdwDuTXA4cBb7N8rtVZuEM4NOj59VO4BNV9bkkvwpQVR8BPsPyq/8PAf8DXDenOa8Efi3JUeA7wN5jPemOsxuAW0d/Wj8MXDeHYzpOzrkY09Ev7rcAv7Ji2dyN5xg552I8q+pgkgMsn945CtwL7F/VUTcDf5bkIZY7au+xHtPL7iWpsW11OkWSXmkscUlqzBKXpMYscUlqzBKXpMYscUlqzBKXpMb+HzJPay5uLPd3AAAAAElFTkSuQmCC\n",
            "text/plain": [
              "<Figure size 432x288 with 1 Axes>"
            ]
          },
          "metadata": {
            "tags": [],
            "needs_background": "light"
          }
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "onnSCklcLcJT",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        ""
      ],
      "execution_count": null,
      "outputs": []
    }
  ]
}

================================================
FILE: gpt.py
================================================
"""Creates the Example and GPT classes for a user to interface with the OpenAI API."""

import openai


def set_openai_key(key):
    """Sets OpenAI key."""
    openai.api_key = key

class Example():
    """Stores an input, output pair and formats it to prime the model."""

    def __init__(self, inp, out):
        self.input = inp
        self.output = out

    def get_input(self):
        """Returns the input of the example."""
        return self.input

    def get_output(self):
        """Returns the intended output of the example."""
        return self.output

    def format(self):
        """Formats the input, output pair."""
        return f"input: {self.input}\noutput: {self.output}\n"


class GPT:
    """The main class for a user to interface with the OpenAI API.
    A user can add examples and set parameters of the API request."""

    def __init__(self, engine='davinci',
                 temperature=0.5,
                 max_tokens=100):
        self.examples = []
        self.engine = engine
        self.temperature = temperature
        self.max_tokens = max_tokens

    def add_example(self, ex):
        """Adds an example to the object. Example must be an instance
        of the Example class."""
        assert isinstance(ex, Example), "Please create an Example object."
        self.examples.append(ex.format())

    def get_prime_text(self):
        """Formats all examples to prime the model."""
        return '\n'.join(self.examples) + '\n'

    def get_engine(self):
        """Returns the engine specified for the API."""
        return self.engine

    def get_temperature(self):
        """Returns the temperature specified for the API."""
        return self.temperature

    def get_max_tokens(self):
        """Returns the max tokens specified for the API."""
        return self.max_tokens

    def craft_query(self, prompt):
        """Creates the query for the API request."""
        return self.get_prime_text() + "input: " + prompt + "\n"

    def submit_request(self, prompt):
        """Calls the OpenAI API with the specified parameters."""
        response = openai.Completion.create(engine=self.get_engine(),
                                            prompt=self.craft_query(prompt),
                                            max_tokens=self.get_max_tokens(),
                                            temperature=self.get_temperature(),
                                            top_p=1,
                                            n=1,
                                            stream=False,
                                            stop="\ninput:")
        return response

    def get_top_reply(self, prompt):
        """Obtains the best result as returned by the API."""
        response = self.submit_request(prompt)
        return response['choices'][0]['text']


================================================
FILE: iris.csv
================================================
sepal_length,sepal_width,petal_length,petal_width,species
5.1,3.5,1.4,0.2,setosa
4.9,3.0,1.4,0.2,setosa
4.7,3.2,1.3,0.2,setosa
4.6,3.1,1.5,0.2,setosa
5.0,3.6,1.4,0.2,setosa
5.4,3.9,1.7,0.4,setosa
4.6,3.4,1.4,0.3,setosa
5.0,3.4,1.5,0.2,setosa
4.4,2.9,1.4,0.2,setosa
4.9,3.1,1.5,0.1,setosa
5.4,3.7,1.5,0.2,setosa
4.8,3.4,1.6,0.2,setosa
4.8,3.0,1.4,0.1,setosa
4.3,3.0,1.1,0.1,setosa
5.8,4.0,1.2,0.2,setosa
5.7,4.4,1.5,0.4,setosa
5.4,3.9,1.3,0.4,setosa
5.1,3.5,1.4,0.3,setosa
5.7,3.8,1.7,0.3,setosa
5.1,3.8,1.5,0.3,setosa
5.4,3.4,1.7,0.2,setosa
5.1,3.7,1.5,0.4,setosa
4.6,3.6,1.0,0.2,setosa
5.1,3.3,1.7,0.5,setosa
4.8,3.4,1.9,0.2,setosa
5.0,3.0,1.6,0.2,setosa
5.0,3.4,1.6,0.4,setosa
5.2,3.5,1.5,0.2,setosa
5.2,3.4,1.4,0.2,setosa
4.7,3.2,1.6,0.2,setosa
4.8,3.1,1.6,0.2,setosa
5.4,3.4,1.5,0.4,setosa
5.2,4.1,1.5,0.1,setosa
5.5,4.2,1.4,0.2,setosa
4.9,3.1,1.5,0.1,setosa
5.0,3.2,1.2,0.2,setosa
5.5,3.5,1.3,0.2,setosa
4.9,3.1,1.5,0.1,setosa
4.4,3.0,1.3,0.2,setosa
5.1,3.4,1.5,0.2,setosa
5.0,3.5,1.3,0.3,setosa
4.5,2.3,1.3,0.3,setosa
4.4,3.2,1.3,0.2,setosa
5.0,3.5,1.6,0.6,setosa
5.1,3.8,1.9,0.4,setosa
4.8,3.0,1.4,0.3,setosa
5.1,3.8,1.6,0.2,setosa
4.6,3.2,1.4,0.2,setosa
5.3,3.7,1.5,0.2,setosa
5.0,3.3,1.4,0.2,setosa
7.0,3.2,4.7,1.4,versicolor
6.4,3.2,4.5,1.5,versicolor
6.9,3.1,4.9,1.5,versicolor
5.5,2.3,4.0,1.3,versicolor
6.5,2.8,4.6,1.5,versicolor
5.7,2.8,4.5,1.3,versicolor
6.3,3.3,4.7,1.6,versicolor
4.9,2.4,3.3,1.0,versicolor
6.6,2.9,4.6,1.3,versicolor
5.2,2.7,3.9,1.4,versicolor
5.0,2.0,3.5,1.0,versicolor
5.9,3.0,4.2,1.5,versicolor
6.0,2.2,4.0,1.0,versicolor
6.1,2.9,4.7,1.4,versicolor
5.6,2.9,3.6,1.3,versicolor
6.7,3.1,4.4,1.4,versicolor
5.6,3.0,4.5,1.5,versicolor
5.8,2.7,4.1,1.0,versicolor
6.2,2.2,4.5,1.5,versicolor
5.6,2.5,3.9,1.1,versicolor
5.9,3.2,4.8,1.8,versicolor
6.1,2.8,4.0,1.3,versicolor
6.3,2.5,4.9,1.5,versicolor
6.1,2.8,4.7,1.2,versicolor
6.4,2.9,4.3,1.3,versicolor
6.6,3.0,4.4,1.4,versicolor
6.8,2.8,4.8,1.4,versicolor
6.7,3.0,5.0,1.7,versicolor
6.0,2.9,4.5,1.5,versicolor
5.7,2.6,3.5,1.0,versicolor
5.5,2.4,3.8,1.1,versicolor
5.5,2.4,3.7,1.0,versicolor
5.8,2.7,3.9,1.2,versicolor
6.0,2.7,5.1,1.6,versicolor
5.4,3.0,4.5,1.5,versicolor
6.0,3.4,4.5,1.6,versicolor
6.7,3.1,4.7,1.5,versicolor
6.3,2.3,4.4,1.3,versicolor
5.6,3.0,4.1,1.3,versicolor
5.5,2.5,4.0,1.3,versicolor
5.5,2.6,4.4,1.2,versicolor
6.1,3.0,4.6,1.4,versicolor
5.8,2.6,4.0,1.2,versicolor
5.0,2.3,3.3,1.0,versicolor
5.6,2.7,4.2,1.3,versicolor
5.7,3.0,4.2,1.2,versicolor
5.7,2.9,4.2,1.3,versicolor
6.2,2.9,4.3,1.3,versicolor
5.1,2.5,3.0,1.1,versicolor
5.7,2.8,4.1,1.3,versicolor
6.3,3.3,6.0,2.5,virginica
5.8,2.7,5.1,1.9,virginica
7.1,3.0,5.9,2.1,virginica
6.3,2.9,5.6,1.8,virginica
6.5,3.0,5.8,2.2,virginica
7.6,3.0,6.6,2.1,virginica
4.9,2.5,4.5,1.7,virginica
7.3,2.9,6.3,1.8,virginica
6.7,2.5,5.8,1.8,virginica
7.2,3.6,6.1,2.5,virginica
6.5,3.2,5.1,2.0,virginica
6.4,2.7,5.3,1.9,virginica
6.8,3.0,5.5,2.1,virginica
5.7,2.5,5.0,2.0,virginica
5.8,2.8,5.1,2.4,virginica
6.4,3.2,5.3,2.3,virginica
6.5,3.0,5.5,1.8,virginica
7.7,3.8,6.7,2.2,virginica
7.7,2.6,6.9,2.3,virginica
6.0,2.2,5.0,1.5,virginica
6.9,3.2,5.7,2.3,virginica
5.6,2.8,4.9,2.0,virginica
7.7,2.8,6.7,2.0,virginica
6.3,2.7,4.9,1.8,virginica
6.7,3.3,5.7,2.1,virginica
7.2,3.2,6.0,1.8,virginica
6.2,2.8,4.8,1.8,virginica
6.1,3.0,4.9,1.8,virginica
6.4,2.8,5.6,2.1,virginica
7.2,3.0,5.8,1.6,virginica
7.4,2.8,6.1,1.9,virginica
7.9,3.8,6.4,2.0,virginica
6.4,2.8,5.6,2.2,virginica
6.3,2.8,5.1,1.5,virginica
6.1,2.6,5.6,1.4,virginica
7.7,3.0,6.1,2.3,virginica
6.3,3.4,5.6,2.4,virginica
6.4,3.1,5.5,1.8,virginica
6.0,3.0,4.8,1.8,virginica
6.9,3.1,5.4,2.1,virginica
6.7,3.1,5.6,2.4,virginica
6.9,3.1,5.1,2.3,virginica
5.8,2.7,5.1,1.9,virginica
6.8,3.2,5.9,2.3,virginica
6.7,3.3,5.7,2.5,virginica
6.7,3.0,5.2,2.3,virginica
6.3,2.5,5.0,1.9,virginica
6.5,3.0,5.2,2.0,virginica
6.2,3.4,5.4,2.3,virginica
5.9,3.0,5.1,1.8,virginica
Download .txt
gitextract_qjsi6js3/

├── .github/
│   └── FUNDING.yml
├── .gitignore
├── LICENSE
├── README.md
├── gpt-3-notebook.ipynb
├── gpt-pandas-code-generation.ipynb
├── gpt-pandas-matplotlib.ipynb
├── gpt.py
└── iris.csv
Download .txt
SYMBOL INDEX (16 symbols across 1 files)

FILE: gpt.py
  function set_openai_key (line 6) | def set_openai_key(key):
  class Example (line 10) | class Example():
    method __init__ (line 13) | def __init__(self, inp, out):
    method get_input (line 17) | def get_input(self):
    method get_output (line 21) | def get_output(self):
    method format (line 25) | def format(self):
  class GPT (line 30) | class GPT:
    method __init__ (line 34) | def __init__(self, engine='davinci',
    method add_example (line 42) | def add_example(self, ex):
    method get_prime_text (line 48) | def get_prime_text(self):
    method get_engine (line 52) | def get_engine(self):
    method get_temperature (line 56) | def get_temperature(self):
    method get_max_tokens (line 60) | def get_max_tokens(self):
    method craft_query (line 64) | def craft_query(self, prompt):
    method submit_request (line 68) | def submit_request(self, prompt):
    method get_top_reply (line 80) | def get_top_reply(self, prompt):
Condensed preview — 9 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (113K chars).
[
  {
    "path": ".github/FUNDING.yml",
    "chars": 102,
    "preview": "# These are supported funding model platforms\ncustom: ['https://www.buymeacoffee.com/bhattbhavesh91']\n"
  },
  {
    "path": ".gitignore",
    "chars": 607,
    "preview": "MANIFEST\nbuild\ndist\n_build\ndocs/man/*.gz\ndocs/source/api/generated\ndocs/source/config.rst\ndocs/gh-pages\nnotebook/i18n/*/"
  },
  {
    "path": "LICENSE",
    "chars": 11357,
    "preview": "                                 Apache License\n                           Version 2.0, January 2004\n                   "
  },
  {
    "path": "README.md",
    "chars": 2003,
    "preview": "# OpenAI's GPT-3 to generate SQL from Natural Language!\n\n**If you like my work, you can support me by buying me a coffee"
  },
  {
    "path": "gpt-3-notebook.ipynb",
    "chars": 15667,
    "preview": "{\"nbformat\":4,\"nbformat_minor\":0,\"metadata\":{\"colab\":{\"name\":\"GPT-3-Demo.ipynb\",\"provenance\":[],\"collapsed_sections\":[],"
  },
  {
    "path": "gpt-pandas-code-generation.ipynb",
    "chars": 14247,
    "preview": "{\n  \"nbformat\": 4,\n  \"nbformat_minor\": 0,\n  \"metadata\": {\n    \"colab\": {\n      \"name\": \"GPT-3-Pandas-Code.ipynb\",\n      "
  },
  {
    "path": "gpt-pandas-matplotlib.ipynb",
    "chars": 53580,
    "preview": "{\n  \"nbformat\": 4,\n  \"nbformat_minor\": 0,\n  \"metadata\": {\n    \"colab\": {\n      \"name\": \"gpt-pandas-code-generation.ipynb"
  },
  {
    "path": "gpt.py",
    "chars": 2839,
    "preview": "\"\"\"Creates the Example and GPT classes for a user to interface with the OpenAI API.\"\"\"\n\nimport openai\n\n\ndef set_openai_k"
  },
  {
    "path": "iris.csv",
    "chars": 3858,
    "preview": "sepal_length,sepal_width,petal_length,petal_width,species\n5.1,3.5,1.4,0.2,setosa\n4.9,3.0,1.4,0.2,setosa\n4.7,3.2,1.3,0.2,"
  }
]

About this extraction

This page contains the full source code of the bhattbhavesh91/gpt-3-simple-tutorial GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 9 files (101.8 KB), approximately 41.7k tokens, and a symbol index with 16 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!