{ "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": [ { "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\"))" ] } ], "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" } } }, "nbformat": 4, "nbformat_minor": 5 }