Spaces:
Runtime error
Runtime error
Delete gpt-3-notebook.ipynb
Browse files- gpt-3-notebook.ipynb +0 -1
gpt-3-notebook.ipynb
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
{"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":[]}]}
|
|
|
|