Skip to content

Instantly share code, notes, and snippets.

@ucalyptus
Created June 28, 2024 16:28
Show Gist options
  • Save ucalyptus/3d7ad302a79ff1d790b91728af1f93c3 to your computer and use it in GitHub Desktop.
Save ucalyptus/3d7ad302a79ff1d790b91728af1f93c3 to your computer and use it in GitHub Desktop.

Revisions

  1. ucalyptus revised this gist Jun 28, 2024. 1 changed file with 12 additions and 1 deletion.
    13 changes: 12 additions & 1 deletion result-structure-discrepancy.ipynb
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,8 @@
    "metadata": {
    "colab": {
    "provenance": [],
    "authorship_tag": "ABX9TyOeoIHSWxq7ulrc0tVKuBiA"
    "authorship_tag": "ABX9TyOeoIHSWxq7ulrc0tVKuBiA",
    "include_colab_link": true
    },
    "kernelspec": {
    "name": "python3",
    @@ -15,6 +16,16 @@
    }
    },
    "cells": [
    {
    "cell_type": "markdown",
    "metadata": {
    "id": "view-in-github",
    "colab_type": "text"
    },
    "source": [
    "<a href=\"https://colab.research.google.com/gist/ucalyptus/3d7ad302a79ff1d790b91728af1f93c3/result-structure-discrepancy.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
    ]
    },
    {
    "cell_type": "code",
    "source": [
  2. ucalyptus created this gist Jun 28, 2024.
    164 changes: 164 additions & 0 deletions result-structure-discrepancy.ipynb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,164 @@
    {
    "nbformat": 4,
    "nbformat_minor": 0,
    "metadata": {
    "colab": {
    "provenance": [],
    "authorship_tag": "ABX9TyOeoIHSWxq7ulrc0tVKuBiA"
    },
    "kernelspec": {
    "name": "python3",
    "display_name": "Python 3"
    },
    "language_info": {
    "name": "python"
    }
    },
    "cells": [
    {
    "cell_type": "code",
    "source": [
    "# prompt: json load a json in python and print a result key\n",
    "\n",
    "import json\n",
    "\n",
    "# Open the JSON file\n",
    "with open('py.json') as f:\n",
    " data = json.load(f)\n",
    "\n",
    "# Print the value of the \"result\" key\n",
    "result_out = data['completions']['gpt-4']['result']\n"
    ],
    "metadata": {
    "id": "GrxX1emLGyQA"
    },
    "execution_count": 46,
    "outputs": []
    },
    {
    "cell_type": "code",
    "source": [
    "type(result_out)"
    ],
    "metadata": {
    "colab": {
    "base_uri": "https://localhost:8080/"
    },
    "id": "eY9uWUfmHCZW",
    "outputId": "edb8c3e1-3f87-4706-cea2-a497ca06ba84"
    },
    "execution_count": 47,
    "outputs": [
    {
    "output_type": "execute_result",
    "data": {
    "text/plain": [
    "list"
    ]
    },
    "metadata": {},
    "execution_count": 47
    }
    ]
    },
    {
    "cell_type": "code",
    "source": [
    "print(result_out)"
    ],
    "metadata": {
    "colab": {
    "base_uri": "https://localhost:8080/"
    },
    "id": "IcsQl5ixLyvt",
    "outputId": "c3a12eef-8856-484f-f47f-d58e12c4eabe"
    },
    "execution_count": 49,
    "outputs": [
    {
    "output_type": "stream",
    "name": "stdout",
    "text": [
    "[['Sat, 01 Jan 2022 00:00:00 GMT', 3], ['Tue, 01 Feb 2022 00:00:00 GMT', 1], ['Tue, 01 Mar 2022 00:00:00 GMT', 5], ['Fri, 01 Apr 2022 00:00:00 GMT', 3], ['Sun, 01 May 2022 00:00:00 GMT', 2], ['Wed, 01 Jun 2022 00:00:00 GMT', 33], ['Fri, 01 Jul 2022 00:00:00 GMT', 32], ['Mon, 01 Aug 2022 00:00:00 GMT', 41], ['Thu, 01 Sep 2022 00:00:00 GMT', 13], ['Sat, 01 Oct 2022 00:00:00 GMT', 2], ['Thu, 01 Dec 2022 00:00:00 GMT', 4], ['Sun, 01 Jan 2023 00:00:00 GMT', 2], ['Wed, 01 Feb 2023 00:00:00 GMT', 4], ['Wed, 01 Mar 2023 00:00:00 GMT', 16], ['Sat, 01 Apr 2023 00:00:00 GMT', 30], ['Mon, 01 May 2023 00:00:00 GMT', 20], ['Thu, 01 Jun 2023 00:00:00 GMT', 14], ['Sat, 01 Jul 2023 00:00:00 GMT', 116], ['Tue, 01 Aug 2023 00:00:00 GMT', 42], ['Fri, 01 Sep 2023 00:00:00 GMT', 11], ['Sun, 01 Oct 2023 00:00:00 GMT', 6], ['Wed, 01 Nov 2023 00:00:00 GMT', 5], ['Fri, 01 Dec 2023 00:00:00 GMT', 1], ['Mon, 01 Jan 2024 00:00:00 GMT', 4], ['Thu, 01 Feb 2024 00:00:00 GMT', 2], ['Fri, 01 Mar 2024 00:00:00 GMT', 2], ['Mon, 01 Apr 2024 00:00:00 GMT', 4], ['Wed, 01 May 2024 00:00:00 GMT', 2]]\n"
    ]
    }
    ]
    },
    {
    "cell_type": "code",
    "source": [
    "import json\n",
    "\n",
    "# Open the JSON file\n",
    "with open('js.json') as f:\n",
    " data = json.load(f)\n",
    "\n",
    "# Print the value of the \"result\" key\n",
    "result_out = data['completions']['gpt-4']['result']"
    ],
    "metadata": {
    "id": "HCV3SYNwHhkY"
    },
    "execution_count": 37,
    "outputs": []
    },
    {
    "cell_type": "code",
    "source": [
    "type(result_out)"
    ],
    "metadata": {
    "colab": {
    "base_uri": "https://localhost:8080/"
    },
    "id": "X4Io2FgfHvI3",
    "outputId": "930ecbeb-437e-48d5-e5bb-f2cd85eed9d6"
    },
    "execution_count": 20,
    "outputs": [
    {
    "output_type": "execute_result",
    "data": {
    "text/plain": [
    "dict"
    ]
    },
    "metadata": {},
    "execution_count": 20
    }
    ]
    },
    {
    "cell_type": "code",
    "source": [
    "print(result_out['rows'][0])"
    ],
    "metadata": {
    "colab": {
    "base_uri": "https://localhost:8080/"
    },
    "id": "Khk1kbMiHwUT",
    "outputId": "b0fee07a-80ca-4a9e-f039-378dd56da4c6"
    },
    "execution_count": 43,
    "outputs": [
    {
    "output_type": "stream",
    "name": "stdout",
    "text": [
    "{'createdAt': '2022-03-02T06:03:52.665Z', 'updatedAt': '2022-03-07T23:23:38.808Z', 'userName': 'test test', 'userFirstName': 'test test', 'userLastName': 'dev dev', 'userEmail': '[email protected]', 'propertyAddress': '88888 BRUSSELS LINE, WROXETER', 'approvedRent': 0, 'approvedRentCopy': 0, 'moveInDate': '2026-01-03', 'moveInStatus': None, 'leaseFromDate': '2026-01-03', 'moveOutDate': '2026-07-03', 'leaseToDate': '2026-07-03', 'leasePeriod': 6, 'status': 'approved', 'statusAt': '2022-03-07T18:22:39.011Z', 'bookingCreatedAt': None, 'bookingUpdatedAt': None, 'archivedAt': None, 'phone': None, 'reason': None, 'comments': None, 'agreementSigned': False, 'padSetup': False, 'hasMovedIn': True, 'tags': None, 'notes': None, 'moveInNotes': None, 'leadSource': 'soulrooms', 'location': None, 'showingDate': None, 'showingTime': None, 'showingTimezone': None, 'userShowingRating': None, 'userShowingComments': None, 'agentShowingRating': None, 'agentShowingComments': None, 'lastCompletedActivity': None, 'earliestActivityDate': None, 'source': None, 'attachedForm': None, 'formSubmittedAt': None, 'deletedAt': None}\n"
    ]
    }
    ]
    },
    {
    "cell_type": "code",
    "source": [],
    "metadata": {
    "id": "Gp0xdEzdLwQA"
    },
    "execution_count": null,
    "outputs": []
    }
    ]
    }