From 0bd0896ec290af959bc0f64dc85ac4cb10f94426 Mon Sep 17 00:00:00 2001 From: Mostafizur Rahman <59665707+imostafizur@users.noreply.github.com> Date: Sat, 27 Aug 2022 00:23:32 +0600 Subject: [PATCH 1/3] Add files via upload --- examples/codex/Codex_Model_Openai.ipynb | 166 ++++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 examples/codex/Codex_Model_Openai.ipynb diff --git a/examples/codex/Codex_Model_Openai.ipynb b/examples/codex/Codex_Model_Openai.ipynb new file mode 100644 index 0000000000..0c715e2f14 --- /dev/null +++ b/examples/codex/Codex_Model_Openai.ipynb @@ -0,0 +1,166 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "name": "Codex_Model_Openai.ipynb", + "provenance": [], + "authorship_tag": "ABX9TyPlPtzH2ehaaPvQLNrPhKZO", + "include_colab_link": true + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "source": [ + "# Install OpenAI Package" + ], + "metadata": { + "id": "N37PG0nwlkxq" + } + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "6iRtOREej7Mx", + "outputId": "ebaab23f-64dc-41d7-8057-47907b621259" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n", + "Collecting openai\n", + " Downloading openai-0.20.0.tar.gz (42 kB)\n", + "\u001b[K |████████████████████████████████| 42 kB 691 kB/s \n", + "\u001b[?25h Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n", + " Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n", + " Preparing wheel metadata ... \u001b[?25l\u001b[?25hdone\n", + "Requirement already satisfied: pandas>=1.2.3 in /usr/local/lib/python3.7/dist-packages (from openai) (1.3.5)\n", + "Collecting pandas-stubs>=1.1.0.11\n", + " Downloading pandas_stubs-1.2.0.62-py3-none-any.whl (163 kB)\n", + "\u001b[K |████████████████████████████████| 163 kB 8.4 MB/s \n", + "\u001b[?25hRequirement already satisfied: requests>=2.20 in /usr/local/lib/python3.7/dist-packages (from openai) (2.23.0)\n", + "Requirement already satisfied: openpyxl>=3.0.7 in /usr/local/lib/python3.7/dist-packages (from openai) (3.0.10)\n", + "Requirement already satisfied: tqdm in /usr/local/lib/python3.7/dist-packages (from openai) (4.64.0)\n", + "Requirement already satisfied: et-xmlfile in /usr/local/lib/python3.7/dist-packages (from openpyxl>=3.0.7->openai) (1.1.0)\n", + "Requirement already satisfied: pytz>=2017.3 in /usr/local/lib/python3.7/dist-packages (from pandas>=1.2.3->openai) (2022.1)\n", + "Requirement already satisfied: numpy>=1.17.3 in /usr/local/lib/python3.7/dist-packages (from pandas>=1.2.3->openai) (1.21.6)\n", + "Requirement already satisfied: python-dateutil>=2.7.3 in /usr/local/lib/python3.7/dist-packages (from pandas>=1.2.3->openai) (2.8.2)\n", + "Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.7/dist-packages (from pandas-stubs>=1.1.0.11->openai) (4.1.1)\n", + "Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.7/dist-packages (from python-dateutil>=2.7.3->pandas>=1.2.3->openai) (1.15.0)\n", + "Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/dist-packages (from requests>=2.20->openai) (1.24.3)\n", + "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from requests>=2.20->openai) (2022.6.15)\n", + "Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests>=2.20->openai) (2.10)\n", + "Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/dist-packages (from requests>=2.20->openai) (3.0.4)\n", + "Building wheels for collected packages: openai\n", + " Building wheel for openai (PEP 517) ... \u001b[?25l\u001b[?25hdone\n", + " Created wheel for openai: filename=openai-0.20.0-py3-none-any.whl size=54118 sha256=8fadf9ff82960e0b69fe2bd5e20dce2e3d1037800f098343126781a3d92416b4\n", + " Stored in directory: /root/.cache/pip/wheels/71/8d/9b/e28529ec53123e0279208f99148d4661232120d78cb866839b\n", + "Successfully built openai\n", + "Installing collected packages: pandas-stubs, openai\n", + "Successfully installed openai-0.20.0 pandas-stubs-1.2.0.62\n" + ] + } + ], + "source": [ + "pip install openai" + ] + }, + { + "cell_type": "markdown", + "source": [ + "# The main Program using Codex model of openAI." + ], + "metadata": { + "id": "oGJHObfulYC0" + } + }, + { + "cell_type": "code", + "source": [ + "import os\n", + "import openai\n", + "\n", + "Query = input('Ask me a question: ')\n", + "print('Mostafizur')\n", + "\n", + "openai.api_key = (\"API-key")\n", + "\n", + "response = openai.Completion.create(\n", + " model=\"code-davinci-002\",\n", + " prompt=\"\",\n", + " temperature=0,\n", + " max_tokens=256,\n", + " top_p=1,\n", + " frequency_penalty=0,\n", + " presence_penalty=0\n", + ")\n", + "content = response.choices[0].text\n", + "print(content)\n", + "Query = content" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "hiy700MTkV8K", + "outputId": "6f5c77d4-5776-4355-ded2-29ff55f0329f" + }, + "execution_count": 3, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Ask me a question: cat\n", + "Mostafizur\n", + "package com.example.demo.controller;\n", + "\n", + "import com.example.demo.model.User;\n", + "import com.example.demo.service.UserService;\n", + "import org.springframework.beans.factory.annotation.Autowired;\n", + "import org.springframework.web.bind.annotation.RequestMapping;\n", + "import org.springframework.web.bind.annotation.RestController;\n", + "\n", + "import java.util.List;\n", + "\n", + "@RestController\n", + "public class UserController {\n", + "\n", + " @Autowired\n", + " private UserService userService;\n", + "\n", + " @RequestMapping(\"/getUser\")\n", + " public List getUser(){\n", + " return userService.getUser();\n", + " }\n", + "}\n" + ] + } + ] + } + ] +} \ No newline at end of file From 72a8fa382ec858d3ec487642fabaa9665bcdf925 Mon Sep 17 00:00:00 2001 From: Mostafizur Rahman <59665707+imostafizur@users.noreply.github.com> Date: Sat, 27 Aug 2022 00:36:43 +0600 Subject: [PATCH 2/3] Worng File. --- examples/codex/Codex_Model_Openai.ipynb | 166 ------------------------ 1 file changed, 166 deletions(-) delete mode 100644 examples/codex/Codex_Model_Openai.ipynb diff --git a/examples/codex/Codex_Model_Openai.ipynb b/examples/codex/Codex_Model_Openai.ipynb deleted file mode 100644 index 0c715e2f14..0000000000 --- a/examples/codex/Codex_Model_Openai.ipynb +++ /dev/null @@ -1,166 +0,0 @@ -{ - "nbformat": 4, - "nbformat_minor": 0, - "metadata": { - "colab": { - "name": "Codex_Model_Openai.ipynb", - "provenance": [], - "authorship_tag": "ABX9TyPlPtzH2ehaaPvQLNrPhKZO", - "include_colab_link": true - }, - "kernelspec": { - "name": "python3", - "display_name": "Python 3" - }, - "language_info": { - "name": "python" - } - }, - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "id": "view-in-github", - "colab_type": "text" - }, - "source": [ - "\"Open" - ] - }, - { - "cell_type": "markdown", - "source": [ - "# Install OpenAI Package" - ], - "metadata": { - "id": "N37PG0nwlkxq" - } - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "6iRtOREej7Mx", - "outputId": "ebaab23f-64dc-41d7-8057-47907b621259" - }, - "outputs": [ - { - "output_type": "stream", - "name": "stdout", - "text": [ - "Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n", - "Collecting openai\n", - " Downloading openai-0.20.0.tar.gz (42 kB)\n", - "\u001b[K |████████████████████████████████| 42 kB 691 kB/s \n", - "\u001b[?25h Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n", - " Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n", - " Preparing wheel metadata ... \u001b[?25l\u001b[?25hdone\n", - "Requirement already satisfied: pandas>=1.2.3 in /usr/local/lib/python3.7/dist-packages (from openai) (1.3.5)\n", - "Collecting pandas-stubs>=1.1.0.11\n", - " Downloading pandas_stubs-1.2.0.62-py3-none-any.whl (163 kB)\n", - "\u001b[K |████████████████████████████████| 163 kB 8.4 MB/s \n", - "\u001b[?25hRequirement already satisfied: requests>=2.20 in /usr/local/lib/python3.7/dist-packages (from openai) (2.23.0)\n", - "Requirement already satisfied: openpyxl>=3.0.7 in /usr/local/lib/python3.7/dist-packages (from openai) (3.0.10)\n", - "Requirement already satisfied: tqdm in /usr/local/lib/python3.7/dist-packages (from openai) (4.64.0)\n", - "Requirement already satisfied: et-xmlfile in /usr/local/lib/python3.7/dist-packages (from openpyxl>=3.0.7->openai) (1.1.0)\n", - "Requirement already satisfied: pytz>=2017.3 in /usr/local/lib/python3.7/dist-packages (from pandas>=1.2.3->openai) (2022.1)\n", - "Requirement already satisfied: numpy>=1.17.3 in /usr/local/lib/python3.7/dist-packages (from pandas>=1.2.3->openai) (1.21.6)\n", - "Requirement already satisfied: python-dateutil>=2.7.3 in /usr/local/lib/python3.7/dist-packages (from pandas>=1.2.3->openai) (2.8.2)\n", - "Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.7/dist-packages (from pandas-stubs>=1.1.0.11->openai) (4.1.1)\n", - "Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.7/dist-packages (from python-dateutil>=2.7.3->pandas>=1.2.3->openai) (1.15.0)\n", - "Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/dist-packages (from requests>=2.20->openai) (1.24.3)\n", - "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from requests>=2.20->openai) (2022.6.15)\n", - "Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests>=2.20->openai) (2.10)\n", - "Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/dist-packages (from requests>=2.20->openai) (3.0.4)\n", - "Building wheels for collected packages: openai\n", - " Building wheel for openai (PEP 517) ... \u001b[?25l\u001b[?25hdone\n", - " Created wheel for openai: filename=openai-0.20.0-py3-none-any.whl size=54118 sha256=8fadf9ff82960e0b69fe2bd5e20dce2e3d1037800f098343126781a3d92416b4\n", - " Stored in directory: /root/.cache/pip/wheels/71/8d/9b/e28529ec53123e0279208f99148d4661232120d78cb866839b\n", - "Successfully built openai\n", - "Installing collected packages: pandas-stubs, openai\n", - "Successfully installed openai-0.20.0 pandas-stubs-1.2.0.62\n" - ] - } - ], - "source": [ - "pip install openai" - ] - }, - { - "cell_type": "markdown", - "source": [ - "# The main Program using Codex model of openAI." - ], - "metadata": { - "id": "oGJHObfulYC0" - } - }, - { - "cell_type": "code", - "source": [ - "import os\n", - "import openai\n", - "\n", - "Query = input('Ask me a question: ')\n", - "print('Mostafizur')\n", - "\n", - "openai.api_key = (\"API-key")\n", - "\n", - "response = openai.Completion.create(\n", - " model=\"code-davinci-002\",\n", - " prompt=\"\",\n", - " temperature=0,\n", - " max_tokens=256,\n", - " top_p=1,\n", - " frequency_penalty=0,\n", - " presence_penalty=0\n", - ")\n", - "content = response.choices[0].text\n", - "print(content)\n", - "Query = content" - ], - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "hiy700MTkV8K", - "outputId": "6f5c77d4-5776-4355-ded2-29ff55f0329f" - }, - "execution_count": 3, - "outputs": [ - { - "output_type": "stream", - "name": "stdout", - "text": [ - "Ask me a question: cat\n", - "Mostafizur\n", - "package com.example.demo.controller;\n", - "\n", - "import com.example.demo.model.User;\n", - "import com.example.demo.service.UserService;\n", - "import org.springframework.beans.factory.annotation.Autowired;\n", - "import org.springframework.web.bind.annotation.RequestMapping;\n", - "import org.springframework.web.bind.annotation.RestController;\n", - "\n", - "import java.util.List;\n", - "\n", - "@RestController\n", - "public class UserController {\n", - "\n", - " @Autowired\n", - " private UserService userService;\n", - "\n", - " @RequestMapping(\"/getUser\")\n", - " public List getUser(){\n", - " return userService.getUser();\n", - " }\n", - "}\n" - ] - } - ] - } - ] -} \ No newline at end of file From 92672b4c99c4c6698b008c6970a5ec4f37a9daaf Mon Sep 17 00:00:00 2001 From: Mostafizur Rahman <59665707+imostafizur@users.noreply.github.com> Date: Sat, 27 Aug 2022 00:37:30 +0600 Subject: [PATCH 3/3] Codex Model in Jupyter Notebook or Google Colab. --- examples/codex/Codex_Model_OpenAI.ipynb | 166 ++++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 examples/codex/Codex_Model_OpenAI.ipynb diff --git a/examples/codex/Codex_Model_OpenAI.ipynb b/examples/codex/Codex_Model_OpenAI.ipynb new file mode 100644 index 0000000000..97410bfcc9 --- /dev/null +++ b/examples/codex/Codex_Model_OpenAI.ipynb @@ -0,0 +1,166 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "view-in-github" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "N37PG0nwlkxq" + }, + "source": [ + "# Install OpenAI Package" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "6iRtOREej7Mx", + "outputId": "ebaab23f-64dc-41d7-8057-47907b621259" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n", + "Collecting openai\n", + " Downloading openai-0.20.0.tar.gz (42 kB)\n", + "\u001b[K |████████████████████████████████| 42 kB 691 kB/s \n", + "\u001b[?25h Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n", + " Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n", + " Preparing wheel metadata ... \u001b[?25l\u001b[?25hdone\n", + "Requirement already satisfied: pandas>=1.2.3 in /usr/local/lib/python3.7/dist-packages (from openai) (1.3.5)\n", + "Collecting pandas-stubs>=1.1.0.11\n", + " Downloading pandas_stubs-1.2.0.62-py3-none-any.whl (163 kB)\n", + "\u001b[K |████████████████████████████████| 163 kB 8.4 MB/s \n", + "\u001b[?25hRequirement already satisfied: requests>=2.20 in /usr/local/lib/python3.7/dist-packages (from openai) (2.23.0)\n", + "Requirement already satisfied: openpyxl>=3.0.7 in /usr/local/lib/python3.7/dist-packages (from openai) (3.0.10)\n", + "Requirement already satisfied: tqdm in /usr/local/lib/python3.7/dist-packages (from openai) (4.64.0)\n", + "Requirement already satisfied: et-xmlfile in /usr/local/lib/python3.7/dist-packages (from openpyxl>=3.0.7->openai) (1.1.0)\n", + "Requirement already satisfied: pytz>=2017.3 in /usr/local/lib/python3.7/dist-packages (from pandas>=1.2.3->openai) (2022.1)\n", + "Requirement already satisfied: numpy>=1.17.3 in /usr/local/lib/python3.7/dist-packages (from pandas>=1.2.3->openai) (1.21.6)\n", + "Requirement already satisfied: python-dateutil>=2.7.3 in /usr/local/lib/python3.7/dist-packages (from pandas>=1.2.3->openai) (2.8.2)\n", + "Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.7/dist-packages (from pandas-stubs>=1.1.0.11->openai) (4.1.1)\n", + "Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.7/dist-packages (from python-dateutil>=2.7.3->pandas>=1.2.3->openai) (1.15.0)\n", + "Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/dist-packages (from requests>=2.20->openai) (1.24.3)\n", + "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from requests>=2.20->openai) (2022.6.15)\n", + "Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests>=2.20->openai) (2.10)\n", + "Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/dist-packages (from requests>=2.20->openai) (3.0.4)\n", + "Building wheels for collected packages: openai\n", + " Building wheel for openai (PEP 517) ... \u001b[?25l\u001b[?25hdone\n", + " Created wheel for openai: filename=openai-0.20.0-py3-none-any.whl size=54118 sha256=8fadf9ff82960e0b69fe2bd5e20dce2e3d1037800f098343126781a3d92416b4\n", + " Stored in directory: /root/.cache/pip/wheels/71/8d/9b/e28529ec53123e0279208f99148d4661232120d78cb866839b\n", + "Successfully built openai\n", + "Installing collected packages: pandas-stubs, openai\n", + "Successfully installed openai-0.20.0 pandas-stubs-1.2.0.62\n" + ] + } + ], + "source": [ + "pip install openai" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "oGJHObfulYC0" + }, + "source": [ + "# The main Program using Codex model of openAI." + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "hiy700MTkV8K", + "outputId": "6f5c77d4-5776-4355-ded2-29ff55f0329f" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Ask me a question: cat\n", + "Mostafizur\n", + "package com.example.demo.controller;\n", + "\n", + "import com.example.demo.model.User;\n", + "import com.example.demo.service.UserService;\n", + "import org.springframework.beans.factory.annotation.Autowired;\n", + "import org.springframework.web.bind.annotation.RequestMapping;\n", + "import org.springframework.web.bind.annotation.RestController;\n", + "\n", + "import java.util.List;\n", + "\n", + "@RestController\n", + "public class UserController {\n", + "\n", + " @Autowired\n", + " private UserService userService;\n", + "\n", + " @RequestMapping(\"/getUser\")\n", + " public List getUser(){\n", + " return userService.getUser();\n", + " }\n", + "}\n" + ] + } + ], + "source": [ + "import os\n", + "import openai\n", + "\n", + "Query = input('Ask me a question: ')\n", + "print('Mostafizur')\n", + "\n", + "openai.api_key = (\"Give your API-key here.\")\n", + "\n", + "response = openai.Completion.create(\n", + " model=\"code-davinci-002\",\n", + " prompt=\"\",\n", + " temperature=0,\n", + " max_tokens=256,\n", + " top_p=1,\n", + " frequency_penalty=0,\n", + " presence_penalty=0\n", + ")\n", + "content = response.choices[0].text\n", + "print(content)\n", + "Query = content" + ] + } + ], + "metadata": { + "colab": { + "authorship_tag": "ABX9TyPlPtzH2ehaaPvQLNrPhKZO", + "include_colab_link": true, + "name": "Codex_Model_Openai.ipynb", + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +}