From 7734a2b5abb8012980ddefa78d1f3f0774487c37 Mon Sep 17 00:00:00 2001 From: Emory Petermann Date: Tue, 25 Jul 2023 18:15:48 -0700 Subject: [PATCH] update golden-query notebook and fix typo in golden docs (#8253) updating the documentation to be consistent for Golden query tool and have a better introduction to the tool --- docs/extras/integrations/providers/golden.mdx | 2 +- .../integrations/tools/golden_query.ipynb | 292 ++++++++++-------- 2 files changed, 156 insertions(+), 138 deletions(-) diff --git a/docs/extras/integrations/providers/golden.mdx b/docs/extras/integrations/providers/golden.mdx index af6ff99abb1..21398a2a5dc 100644 --- a/docs/extras/integrations/providers/golden.mdx +++ b/docs/extras/integrations/providers/golden.mdx @@ -1,6 +1,6 @@ # Golden ->[Golden](https://golden.com) provides a set of natural language APIs for querying and enrichment using the Golden Knowledge Graph e.g. queries such as: `Products from OpenAI`, `Generative ai companies with series a funding`, and `rappers who invest` can be used to retrieve relevant structured data about relevant entities. +>[Golden](https://golden.com) provides a set of natural language APIs for querying and enrichment using the Golden Knowledge Graph e.g. queries such as: `Products from OpenAI`, `Generative ai companies with series a funding`, and `rappers who invest` can be used to retrieve structured data about relevant entities. > >The `golden-query` langchain tool is a wrapper on top of the [Golden Query API](https://docs.golden.com/reference/query-api) which enables programmatic access to these results. >See the [Golden Query API docs](https://docs.golden.com/reference/query-api) for more information. diff --git a/docs/extras/integrations/tools/golden_query.ipynb b/docs/extras/integrations/tools/golden_query.ipynb index b9ff485576c..e456434afef 100644 --- a/docs/extras/integrations/tools/golden_query.ipynb +++ b/docs/extras/integrations/tools/golden_query.ipynb @@ -1,142 +1,160 @@ { - "cells": [ - { - "attachments": {}, - "cell_type": "markdown", - "id": "245a954a", - "metadata": {}, - "source": [ - "# Golden Query\n", - "\n", - "This notebook goes over how to use the golden-query tool.\n", - "\n", - "- Go to the [Golden API docs](https://docs.golden.com/) to get an overview about the Golden API.\n", - "- Create a Golden account if you don't have one on the [Golden Website](golden.com).\n", - "- Get your API key from the [Golden API Settings](https://golden.com/settings/api) page.\n", - "- Save your API key into GOLDEN_API_KEY env variable" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "id": "34bb5968", - "metadata": {}, - "outputs": [], - "source": [ - "import os\n", - "\n", - "os.environ[\"GOLDEN_API_KEY\"] = \"\"" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "id": "ac4910f8", - "metadata": {}, - "outputs": [], - "source": [ - "from langchain.utilities.golden_query import GoldenQueryAPIWrapper" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "id": "84b8f773", - "metadata": {}, - "outputs": [], - "source": [ - "golden_query = GoldenQueryAPIWrapper()" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "id": "068991a6", - "metadata": {}, - "outputs": [ + "cells": [ { - "data": { - "text/plain": [ - "{'results': [{'id': 4673886,\n", - " 'latestVersionId': 60276991,\n", - " 'properties': [{'predicateId': 'name',\n", - " 'instances': [{'value': 'Samsung', 'citations': []}]}]},\n", - " {'id': 7008,\n", - " 'latestVersionId': 61087416,\n", - " 'properties': [{'predicateId': 'name',\n", - " 'instances': [{'value': 'Intel', 'citations': []}]}]},\n", - " {'id': 24193,\n", - " 'latestVersionId': 60274482,\n", - " 'properties': [{'predicateId': 'name',\n", - " 'instances': [{'value': 'Texas Instruments', 'citations': []}]}]},\n", - " {'id': 1142,\n", - " 'latestVersionId': 61406205,\n", - " 'properties': [{'predicateId': 'name',\n", - " 'instances': [{'value': 'Advanced Micro Devices', 'citations': []}]}]},\n", - " {'id': 193948,\n", - " 'latestVersionId': 58326582,\n", - " 'properties': [{'predicateId': 'name',\n", - " 'instances': [{'value': 'Freescale Semiconductor', 'citations': []}]}]},\n", - " {'id': 91316,\n", - " 'latestVersionId': 60387380,\n", - " 'properties': [{'predicateId': 'name',\n", - " 'instances': [{'value': 'Agilent Technologies', 'citations': []}]}]},\n", - " {'id': 90014,\n", - " 'latestVersionId': 60388078,\n", - " 'properties': [{'predicateId': 'name',\n", - " 'instances': [{'value': 'Novartis', 'citations': []}]}]},\n", - " {'id': 237458,\n", - " 'latestVersionId': 61406160,\n", - " 'properties': [{'predicateId': 'name',\n", - " 'instances': [{'value': 'Analog Devices', 'citations': []}]}]},\n", - " {'id': 3941943,\n", - " 'latestVersionId': 60382250,\n", - " 'properties': [{'predicateId': 'name',\n", - " 'instances': [{'value': 'AbbVie Inc.', 'citations': []}]}]},\n", - " {'id': 4178762,\n", - " 'latestVersionId': 60542667,\n", - " 'properties': [{'predicateId': 'name',\n", - " 'instances': [{'value': 'IBM', 'citations': []}]}]}],\n", - " 'next': 'https://golden.com/api/v2/public/queries/59044/results/?cursor=eyJwb3NpdGlvbiI6IFsxNzYxNiwgIklCTS04M1lQM1oiXX0%3D&pageSize=10',\n", - " 'previous': None}" + "cell_type": "markdown", + "id": "245a954a", + "metadata": { + "id": "245a954a" + }, + "source": [ + "# Golden Query\n", + "\n", + ">[Golden](https://golden.com) provides a set of natural language APIs for querying and enrichment using the Golden Knowledge Graph e.g. queries such as: `Products from OpenAI`, `Generative ai companies with series a funding`, and `rappers who invest` can be used to retrieve structured data about relevant entities.\n", + ">\n", + ">The `golden-query` langchain tool is a wrapper on top of the [Golden Query API](https://docs.golden.com/reference/query-api) which enables programmatic access to these results.\n", + ">See the [Golden Query API docs](https://docs.golden.com/reference/query-api) for more information.\n", + "\n", + "\n", + "This notebook goes over how to use the `golden-query` tool.\n", + "\n", + "- Go to the [Golden API docs](https://docs.golden.com/) to get an overview about the Golden API.\n", + "- Get your API key from the [Golden API Settings](https://golden.com/settings/api) page.\n", + "- Save your API key into GOLDEN_API_KEY env variable" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "34bb5968", + "metadata": { + "id": "34bb5968" + }, + "outputs": [], + "source": [ + "import os\n", + "\n", + "os.environ[\"GOLDEN_API_KEY\"] = \"\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ac4910f8", + "metadata": { + "id": "ac4910f8" + }, + "outputs": [], + "source": [ + "from langchain.utilities.golden_query import GoldenQueryAPIWrapper" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "84b8f773", + "metadata": { + "id": "84b8f773" + }, + "outputs": [], + "source": [ + "golden_query = GoldenQueryAPIWrapper()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "068991a6", + "metadata": { + "id": "068991a6", + "outputId": "c5cdc6ec-03cf-4084-cc6f-6ae792d91d39" + }, + "outputs": [ + { + "data": { + "text/plain": [ + "{'results': [{'id': 4673886,\n", + " 'latestVersionId': 60276991,\n", + " 'properties': [{'predicateId': 'name',\n", + " 'instances': [{'value': 'Samsung', 'citations': []}]}]},\n", + " {'id': 7008,\n", + " 'latestVersionId': 61087416,\n", + " 'properties': [{'predicateId': 'name',\n", + " 'instances': [{'value': 'Intel', 'citations': []}]}]},\n", + " {'id': 24193,\n", + " 'latestVersionId': 60274482,\n", + " 'properties': [{'predicateId': 'name',\n", + " 'instances': [{'value': 'Texas Instruments', 'citations': []}]}]},\n", + " {'id': 1142,\n", + " 'latestVersionId': 61406205,\n", + " 'properties': [{'predicateId': 'name',\n", + " 'instances': [{'value': 'Advanced Micro Devices', 'citations': []}]}]},\n", + " {'id': 193948,\n", + " 'latestVersionId': 58326582,\n", + " 'properties': [{'predicateId': 'name',\n", + " 'instances': [{'value': 'Freescale Semiconductor', 'citations': []}]}]},\n", + " {'id': 91316,\n", + " 'latestVersionId': 60387380,\n", + " 'properties': [{'predicateId': 'name',\n", + " 'instances': [{'value': 'Agilent Technologies', 'citations': []}]}]},\n", + " {'id': 90014,\n", + " 'latestVersionId': 60388078,\n", + " 'properties': [{'predicateId': 'name',\n", + " 'instances': [{'value': 'Novartis', 'citations': []}]}]},\n", + " {'id': 237458,\n", + " 'latestVersionId': 61406160,\n", + " 'properties': [{'predicateId': 'name',\n", + " 'instances': [{'value': 'Analog Devices', 'citations': []}]}]},\n", + " {'id': 3941943,\n", + " 'latestVersionId': 60382250,\n", + " 'properties': [{'predicateId': 'name',\n", + " 'instances': [{'value': 'AbbVie Inc.', 'citations': []}]}]},\n", + " {'id': 4178762,\n", + " 'latestVersionId': 60542667,\n", + " 'properties': [{'predicateId': 'name',\n", + " 'instances': [{'value': 'IBM', 'citations': []}]}]}],\n", + " 'next': 'https://golden.com/api/v2/public/queries/59044/results/?cursor=eyJwb3NpdGlvbiI6IFsxNzYxNiwgIklCTS04M1lQM1oiXX0%3D&pageSize=10',\n", + " 'previous': None}" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import json\n", + "\n", + "json.loads(golden_query.run(\"companies in nanotech\"))" ] - }, - "execution_count": 9, - "metadata": {}, - "output_type": "execute_result" } - ], - "source": [ - "import json\n", - "\n", - "json.loads(golden_query.run(\"companies in nanotech\"))" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": ".venv", - "language": "python", - "name": "python3" + ], + "metadata": { + "kernelspec": { + "display_name": ".venv", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.13" + }, + "vscode": { + "interpreter": { + "hash": "53f3bc57609c7a84333bb558594977aa5b4026b1d6070b93987956689e367341" + } + }, + "colab": { + "provenance": [] + } }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.9.13" - }, - "vscode": { - "interpreter": { - "hash": "53f3bc57609c7a84333bb558594977aa5b4026b1d6070b93987956689e367341" - } - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} + "nbformat": 4, + "nbformat_minor": 5 +} \ No newline at end of file