Created
July 27, 2020 02:41
-
-
Save brockmanmatt/9d244ea778acaa359c0c6e8c5152cb41 to your computer and use it in GitHub Desktop.
opposingViewpoint.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"name": "opposingViewpoint.ipynb", | |
"provenance": [], | |
"collapsed_sections": [], | |
"authorship_tag": "ABX9TyMrLjis+QPlRfZaScH6cpHB", | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/brockmanmatt/9d244ea778acaa359c0c6e8c5152cb41/opposingviewpoint.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "J7wnsgT2kPut", | |
"colab_type": "code", | |
"colab": { | |
"resources": { | |
"http://localhost:8080/nbextensions/google.colab/files.js": { | |
"data": "Ly8gQ29weXJpZ2h0IDIwMTcgR29vZ2xlIExMQwovLwovLyBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKLy8geW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgovLyBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKLy8KLy8gICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjAKLy8KLy8gVW5sZXNzIHJ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bWl0cy4gU2VlIGIvNjIxMTU2NjAuCiAgICBsZXQgcG9zaXRpb24gPSAwOwogICAgd2hpbGUgKHBvc2l0aW9uIDwgZmlsZURhdGEuYnl0ZUxlbmd0aCkgewogICAgICBjb25zdCBsZW5ndGggPSBNYXRoLm1pbihmaWxlRGF0YS5ieXRlTGVuZ3RoIC0gcG9zaXRpb24sIE1BWF9QQVlMT0FEX1NJWkUpOwogICAgICBjb25zdCBjaHVuayA9IG5ldyBVaW50OEFycmF5KGZpbGVEYXRhLCBwb3NpdGlvbiwgbGVuZ3RoKTsKICAgICAgcG9zaXRpb24gKz0gbGVuZ3RoOwoKICAgICAgY29uc3QgYmFzZTY0ID0gYnRvYShTdHJpbmcuZnJvbUNoYXJDb2RlLmFwcGx5KG51bGwsIGNodW5rKSk7CiAgICAgIHlpZWxkIHsKICAgICAgICByZXNwb25zZTogewogICAgICAgICAgYWN0aW9uOiAnYXBwZW5kJywKICAgICAgICAgIGZpbGU6IGZpbGUubmFtZSwKICAgICAgICAgIGRhdGE6IGJhc2U2NCwKICAgICAgICB9LAogICAgICB9OwogICAgICBwZXJjZW50LnRleHRDb250ZW50ID0KICAgICAgICAgIGAke01hdGgucm91bmQoKHBvc2l0aW9uIC8gZmlsZURhdGEuYnl0ZUxlbmd0aCkgKiAxMDApfSUgZG9uZWA7CiAgICB9CiAgfQoKICAvLyBBbGwgZG9uZS4KICB5aWVsZCB7CiAgICByZXNwb25zZTogewogICAgICBhY3Rpb246ICdjb21wbGV0ZScsCiAgICB9CiAgfTsKfQoKc2NvcGUuZ29vZ2xlID0gc2NvcGUuZ29vZ2xlIHx8IHt9OwpzY29wZS5nb29nbGUuY29sYWIgPSBzY29wZS5nb29nbGUuY29sYWIgfHwge307CnNjb3BlLmdvb2dsZS5jb2xhYi5fZmlsZXMgPSB7CiAgX3VwbG9hZEZpbGVzLAogIF91cGxvYWRGaWxlc0NvbnRpbnVlLAp9Owp9KShzZWxmKTsK", | |
"ok": true, | |
"headers": [ | |
[ | |
"content-type", | |
"application/javascript" | |
] | |
], | |
"status": 200, | |
"status_text": "" | |
} | |
}, | |
"base_uri": "https://localhost:8080/", | |
"height": 89 | |
}, | |
"outputId": "89a20402-6e53-45a1-eace-e02127d821ec" | |
}, | |
"source": [ | |
"from google.colab import files\n", | |
"uploaded = files.upload()\n", | |
"print(\"done\")" | |
], | |
"execution_count": 2, | |
"outputs": [ | |
{ | |
"output_type": "display_data", | |
"data": { | |
"text/html": [ | |
"\n", | |
" <input type=\"file\" id=\"files-5ea42241-89f4-474b-98ac-a1992282dfb7\" name=\"files[]\" multiple disabled\n", | |
" style=\"border:none\" />\n", | |
" <output id=\"result-5ea42241-89f4-474b-98ac-a1992282dfb7\">\n", | |
" Upload widget is only available when the cell has been executed in the\n", | |
" current browser session. Please rerun this cell to enable.\n", | |
" </output>\n", | |
" <script src=\"/nbextensions/google.colab/files.js\"></script> " | |
], | |
"text/plain": [ | |
"<IPython.core.display.HTML object>" | |
] | |
}, | |
"metadata": { | |
"tags": [] | |
} | |
}, | |
{ | |
"output_type": "stream", | |
"text": [ | |
"Saving key.json to key.json\n", | |
"done\n" | |
], | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "WHPHrUnhpKnI", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"I'll install the API" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "zq0ltp2xn4yt", | |
"colab_type": "code", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 292 | |
}, | |
"outputId": "e1419fef-a17a-4f39-c175-f4647523b74c" | |
}, | |
"source": [ | |
"!pip install openai\n", | |
"import openai, json, pandas as pd" | |
], | |
"execution_count": 3, | |
"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: 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: idna<3,>=2.5 in /usr/local/lib/python3.6/dist-packages (from requests>=2.20->openai) (2.10)\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: 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=83e8a6d07a876c1dbab6f339a2db6e5f644b1784651c346d2314f8645aeb9910\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": "markdown", | |
"metadata": { | |
"id": "Q2yE0jcnpMEV", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"Loading in key.json that I uploaded; I do this so I don't need to worry about accidently leaking creds if I share the colab (which I'm 99% sure is just a json file that won't expose them)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "bwNXXwHen5x9", | |
"colab_type": "code", | |
"colab": {} | |
}, | |
"source": [ | |
"openai.api_key = json.load(open(\"key.json\", \"r\"))[\"key\"]" | |
], | |
"execution_count": 8, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "k67w5H0fpTkT", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"Default keyword arguments to pass the aPI" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "e1EwpqqJkTYh", | |
"colab_type": "code", | |
"colab": {} | |
}, | |
"source": [ | |
"#arguments to send the API\n", | |
"kwargs = {\n", | |
"\"engine\":\"davinci\",\n", | |
"\"temperature\":0,\n", | |
"\"max_tokens\":150,\n", | |
"\"stop\":\"\\n\\n\",\n", | |
"}" | |
], | |
"execution_count": 22, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "zZubgPoOpWDH", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"Quick wrapper to automatically save prompts and responses sent for later analysis if needed" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "sXTDJx0An9Bl", | |
"colab_type": "code", | |
"colab": {} | |
}, | |
"source": [ | |
"import datetime\n", | |
"def query(prompt, myKwargs = kwargs):\n", | |
" \"\"\"\n", | |
" wrapper for the API to save the prompt and the result\n", | |
" \"\"\"\n", | |
"\n", | |
" r = openai.Completion.create(prompt=prompt, **myKwargs)[\"choices\"][0][\"text\"].strip()\n", | |
" with open(\"{}.json\".format(datetime.datetime.now().strftime(\"%Y%m%d%s\")), \"w\") as fh:\n", | |
" json.dump({\"prompt\":prompt, \"response\":r}, fh, indent=4)\n", | |
" return r" | |
], | |
"execution_count": 23, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "EdFXafcJpZ3Q", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"Test to make sure my query works" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "4SlyKgjyopPn", | |
"colab_type": "code", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 35 | |
}, | |
"outputId": "2eff5c4c-057d-474a-b9e5-cd16245d18cd" | |
}, | |
"source": [ | |
"newKwargs = kwargs.copy()\n", | |
"newKwargs[\"stop\"] = \"\\n\"\n", | |
"query(\"q: what is 1+1?\\na:\", newKwargs)" | |
], | |
"execution_count": 24, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"application/vnd.google.colaboratory.intrinsic+json": { | |
"type": "string" | |
}, | |
"text/plain": [ | |
"'2'" | |
] | |
}, | |
"metadata": { | |
"tags": [] | |
}, | |
"execution_count": 24 | |
} | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "FHiNyGmNFpwx", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"Here we'll establish two individuals who are opposite. That works on some tests!" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "6UuU_1YMDn-6", | |
"colab_type": "code", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 35 | |
}, | |
"outputId": "0dd66071-72fd-4a14-a75b-5091d0b94a0a" | |
}, | |
"source": [ | |
"prompt = \"\"\"Tom and Jerry are opposites. Tom is short, and Jerry is tall. Tom's a mouse, Jerry is a cat. Tom and Jerry hold opposite beliefs on most things.\n", | |
"\n", | |
"Tom believes that Pineapple belongs on Pizza.\n", | |
"Jerry believes\"\"\"\n", | |
"query(prompt)" | |
], | |
"execution_count": 25, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"application/vnd.google.colaboratory.intrinsic+json": { | |
"type": "string" | |
}, | |
"text/plain": [ | |
"'that Pineapple does not belong on Pizza.'" | |
] | |
}, | |
"metadata": { | |
"tags": [] | |
}, | |
"execution_count": 25 | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "zPzd_HOKGGX4", | |
"colab_type": "code", | |
"colab": {} | |
}, | |
"source": [ | |
"prompt = \"\"\"Tom and Jerry are opposites. Tom is short, and Jerry is tall. Tom's a mouse, Jerry is a cat. Tom and Jerry hold opposite beliefs on most things.\n", | |
"\n", | |
"Tom believes that {}.\n", | |
"Jerry believes\"\"\"\n" | |
], | |
"execution_count": 26, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "06qlIu6kGG94", | |
"colab_type": "code", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 35 | |
}, | |
"outputId": "2e103ddf-8f44-4bc7-c7dd-11e52d92a956" | |
}, | |
"source": [ | |
"query(prompt.format(\"the world is round\"))" | |
], | |
"execution_count": 27, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"application/vnd.google.colaboratory.intrinsic+json": { | |
"type": "string" | |
}, | |
"text/plain": [ | |
"'that the world is flat.'" | |
] | |
}, | |
"metadata": { | |
"tags": [] | |
}, | |
"execution_count": 27 | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "UvRv9XEMGWU0", | |
"colab_type": "code", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 35 | |
}, | |
"outputId": "f4800077-c25a-4a52-c879-09e370aecc97" | |
}, | |
"source": [ | |
"query(prompt.format(\"studying is important\"))" | |
], | |
"execution_count": 28, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"application/vnd.google.colaboratory.intrinsic+json": { | |
"type": "string" | |
}, | |
"text/plain": [ | |
"'that studying is a waste of time.'" | |
] | |
}, | |
"metadata": { | |
"tags": [] | |
}, | |
"execution_count": 28 | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "xOL7x9sSGa7n", | |
"colab_type": "code", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 35 | |
}, | |
"outputId": "950431c5-b316-464a-f73d-e7657320003f" | |
}, | |
"source": [ | |
"query(prompt.format(\"Han shot firsst\"))" | |
], | |
"execution_count": 29, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"application/vnd.google.colaboratory.intrinsic+json": { | |
"type": "string" | |
}, | |
"text/plain": [ | |
"'that Greedo shot first.'" | |
] | |
}, | |
"metadata": { | |
"tags": [] | |
}, | |
"execution_count": 29 | |
} | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "ZJlf_gRcHRHi", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"This is actually something that we should have asked a long time ago. We can ask this incredibly advanced AI its thoughts..." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "qW3ZtfS2GhXt", | |
"colab_type": "code", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 35 | |
}, | |
"outputId": "a88b028e-6c1b-4893-bb14-32b11b2e23fa" | |
}, | |
"source": [ | |
"prompt = \"\"\"q: what's 1+1?\n", | |
"a: 2\n", | |
"\n", | |
"q:who shot first?\\na:\"\"\"\n", | |
"query(prompt)" | |
], | |
"execution_count": 30, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"application/vnd.google.colaboratory.intrinsic+json": { | |
"type": "string" | |
}, | |
"text/plain": [ | |
"'Han Solo'" | |
] | |
}, | |
"metadata": { | |
"tags": [] | |
}, | |
"execution_count": 30 | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "42V4TBIGHfEd", | |
"colab_type": "code", | |
"colab": {} | |
}, | |
"source": [ | |
"prompt = \"\"\"Tom and Jerry are opposites. Tom is short, and Jerry is tall. Tom's a mouse, Jerry is a cat. Tom and Jerry hold opposite beliefs on most things.\n", | |
"\n", | |
"Tom believes that {}.\n", | |
"Jerry believes\"\"\"\n" | |
], | |
"execution_count": 31, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "g9PWntQxGnvF", | |
"colab_type": "code", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 35 | |
}, | |
"outputId": "e55007d9-4a5e-44d6-a75d-2aa23e7ca232" | |
}, | |
"source": [ | |
"query(prompt.format(\"the vikings are the best\"))" | |
], | |
"execution_count": 32, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"application/vnd.google.colaboratory.intrinsic+json": { | |
"type": "string" | |
}, | |
"text/plain": [ | |
"'that the vikings are the worst.'" | |
] | |
}, | |
"metadata": { | |
"tags": [] | |
}, | |
"execution_count": 32 | |
} | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "qnSykfMuHh-E", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"So we don't want to just be opposite. we want to have differing views." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "hdRMVz53HgGe", | |
"colab_type": "code", | |
"colab": {} | |
}, | |
"source": [ | |
"prompt = \"\"\"Tom and Jerry are very different. Tom is short, and Jerry is tall. Tom's a mouse, Jerry is a cat. Tom and Jerry hold opposite beliefs on most things. For instance, Tom likes Jazz. Jerry likes rock.\n", | |
"\n", | |
"Tom believes {}.\n", | |
"Jerry believes\"\"\"\n" | |
], | |
"execution_count": 43, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "xAl35lI0HsKR", | |
"colab_type": "code", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 35 | |
}, | |
"outputId": "c58f7264-f806-41e3-b25c-efaaed01f0d8" | |
}, | |
"source": [ | |
"query(prompt.format(\"the Vikings are the best\"))" | |
], | |
"execution_count": 44, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"application/vnd.google.colaboratory.intrinsic+json": { | |
"type": "string" | |
}, | |
"text/plain": [ | |
"'the Packers are the best.'" | |
] | |
}, | |
"metadata": { | |
"tags": [] | |
}, | |
"execution_count": 44 | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "J_a4AKTVHsvM", | |
"colab_type": "code", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 35 | |
}, | |
"outputId": "ccd13b06-d14a-4b42-c75f-061edcf807da" | |
}, | |
"source": [ | |
"query(prompt.format(\"Kenysian economics\"))" | |
], | |
"execution_count": 45, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"application/vnd.google.colaboratory.intrinsic+json": { | |
"type": "string" | |
}, | |
"text/plain": [ | |
"'in the free market.'" | |
] | |
}, | |
"metadata": { | |
"tags": [] | |
}, | |
"execution_count": 45 | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "xPX3WXrEH659", | |
"colab_type": "code", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 35 | |
}, | |
"outputId": "ae42dd1d-c1eb-4d21-d1bc-05848c8730f3" | |
}, | |
"source": [ | |
"query(prompt.format(\"Hayekian economics\"))" | |
], | |
"execution_count": 46, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"application/vnd.google.colaboratory.intrinsic+json": { | |
"type": "string" | |
}, | |
"text/plain": [ | |
"'Keynesian economics.'" | |
] | |
}, | |
"metadata": { | |
"tags": [] | |
}, | |
"execution_count": 46 | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "_rbFQs2lIBEm", | |
"colab_type": "code", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 35 | |
}, | |
"outputId": "29142113-e342-4ef9-8b75-8b2ac765d1d2" | |
}, | |
"source": [ | |
"query(prompt.format(\"expert driven systems\"))" | |
], | |
"execution_count": 47, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"application/vnd.google.colaboratory.intrinsic+json": { | |
"type": "string" | |
}, | |
"text/plain": [ | |
"'in the power of the people.'" | |
] | |
}, | |
"metadata": { | |
"tags": [] | |
}, | |
"execution_count": 47 | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "NOAj78lQIF2B", | |
"colab_type": "code", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 35 | |
}, | |
"outputId": "bbc30471-341c-4a17-b78d-addfc057f97a" | |
}, | |
"source": [ | |
"query(prompt.format(\"conservative values\"))" | |
], | |
"execution_count": 50, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"application/vnd.google.colaboratory.intrinsic+json": { | |
"type": "string" | |
}, | |
"text/plain": [ | |
"'liberal values.'" | |
] | |
}, | |
"metadata": { | |
"tags": [] | |
}, | |
"execution_count": 50 | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "hpO-sP-vIIYp", | |
"colab_type": "code", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 35 | |
}, | |
"outputId": "1c1fdc1b-165f-42c5-b183-6e5a8e496b9e" | |
}, | |
"source": [ | |
"query(prompt.format(\"libertarian values\"))" | |
], | |
"execution_count": 51, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"application/vnd.google.colaboratory.intrinsic+json": { | |
"type": "string" | |
}, | |
"text/plain": [ | |
"'in the welfare state.'" | |
] | |
}, | |
"metadata": { | |
"tags": [] | |
}, | |
"execution_count": 51 | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "xspZSI2oIaZ1", | |
"colab_type": "code", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 35 | |
}, | |
"outputId": "fbe65104-5fa7-43b3-9cac-8819493047ed" | |
}, | |
"source": [ | |
"query(prompt.format(\"schools should open\"))" | |
], | |
"execution_count": 52, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"application/vnd.google.colaboratory.intrinsic+json": { | |
"type": "string" | |
}, | |
"text/plain": [ | |
"'schools should close.'" | |
] | |
}, | |
"metadata": { | |
"tags": [] | |
}, | |
"execution_count": 52 | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "BeK9eo0yIio7", | |
"colab_type": "code", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 35 | |
}, | |
"outputId": "bec8b95b-1a54-4446-8483-a9346f8c2cb9" | |
}, | |
"source": [ | |
"query(prompt.format(\"universal healthcare\"))" | |
], | |
"execution_count": 58, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"application/vnd.google.colaboratory.intrinsic+json": { | |
"type": "string" | |
}, | |
"text/plain": [ | |
"'in the free market.'" | |
] | |
}, | |
"metadata": { | |
"tags": [] | |
}, | |
"execution_count": 58 | |
} | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "FqOeWNOeI3bQ", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"huh, it knows historical presidential races" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "Tgxwi26_Il2j", | |
"colab_type": "code", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 35 | |
}, | |
"outputId": "9fbed92a-88e2-45c6-f7e6-2805d50291f6" | |
}, | |
"source": [ | |
"query(prompt.format(\"vote for Ike\"))" | |
], | |
"execution_count": 59, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"application/vnd.google.colaboratory.intrinsic+json": { | |
"type": "string" | |
}, | |
"text/plain": [ | |
"'vote for Adlai.'" | |
] | |
}, | |
"metadata": { | |
"tags": [] | |
}, | |
"execution_count": 59 | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "4yauA4rdI0R_", | |
"colab_type": "code", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 35 | |
}, | |
"outputId": "15dc6fb1-ba25-4505-91cf-a42212b06e25" | |
}, | |
"source": [ | |
" " | |
], | |
"execution_count": 61, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"application/vnd.google.colaboratory.intrinsic+json": { | |
"type": "string" | |
}, | |
"text/plain": [ | |
"'in Waterfall.'" | |
] | |
}, | |
"metadata": { | |
"tags": [] | |
}, | |
"execution_count": 61 | |
} | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment