From f6c8f2f401c4a66e9a99b0f6a811429da4e47360 Mon Sep 17 00:00:00 2001 From: Mark McDonald Date: Fri, 7 Feb 2025 00:10:26 +0800 Subject: [PATCH] Fix model for search grounding REST notebook (#437) --- quickstarts/rest/Search_Grounding.ipynb | 393 +++++++++++++++++++++++- 1 file changed, 382 insertions(+), 11 deletions(-) diff --git a/quickstarts/rest/Search_Grounding.ipynb b/quickstarts/rest/Search_Grounding.ipynb index 6531e5945..d8f517c5e 100644 --- a/quickstarts/rest/Search_Grounding.ipynb +++ b/quickstarts/rest/Search_Grounding.ipynb @@ -6,7 +6,7 @@ "id": "0fgOxpmGrOvn" }, "source": [ - "##### Copyright 2024 Google LLC." + "##### Copyright 2025 Google LLC." ] }, { @@ -85,7 +85,7 @@ "id": "3xovmcsts5vW" }, "source": [ - "## Call the api" + "## Call the API" ] }, { @@ -94,7 +94,7 @@ "id": "aIn2wj3tsh4Q" }, "source": [ - "Call search grounding. The `dynamic_threshold` is optional, it sets how likely the model is to do a google-search." + "Call search grounding. The `dynamic_threshold` is optional and sets the threshold that determines whether the query could be backed by grounding. Setting to 1.0 would require 100% confidence from the model, and setting to 0.0 would invoke search grounding on any input. You can see the score in the `googleSearchDynamicRetrievalScore` response field." ] }, { @@ -103,10 +103,20 @@ "metadata": { "id": "jG3msvzFw-YN" }, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + " % Total % Received % Xferd Average Speed Time Time Time Current\n", + " Dload Upload Total Spent Left Speed\n", + "\r 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\r100 439 0 0 100 439 0 2120 --:--:-- --:--:-- --:--:-- 2120\r100 439 0 0 100 439 0 363 0:00:01 0:00:01 --:--:-- 363\r100 439 0 0 100 439 0 198 0:00:02 0:00:02 --:--:-- 198\r100 9619 0 9180 100 439 3529 168 0:00:02 0:00:02 --:--:-- 3698\n" + ] + } + ], "source": [ "%%bash\n", - "curl \"https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=$GOOGLE_API_KEY\" \\\n", + "curl \"https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key=$GOOGLE_API_KEY\" \\\n", " -H \"Content-Type: application/json\" \\\n", " -d '{\n", " \"contents\": [\n", @@ -121,7 +131,7 @@ " \"google_search_retrieval\": {\n", " \"dynamic_retrieval_config\": {\n", " \"mode\": \"MODE_DYNAMIC\",\n", - " \"dynamic_threshold\": 1,\n", + " \"dynamic_threshold\": 0.5,\n", " }\n", " }\n", " }\n", @@ -173,9 +183,130 @@ "metadata": { "id": "uCWcvi_nqSkx" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"candidates\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m[\n", + " \u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"content\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"parts\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m[\n", + " \u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"text\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;32m\"The Google stock price varies depending on the class of shares and the source. As of today, February 6th, 2025, here's a summary of the information I found:\\n\\n* **Alphabet Inc. Class C (GOOG):** Prices reported range from $193.30 (showing a 2.50% increase in the last 24 hours) to $194.54 (intraday high). One source shows a significant decrease of 6.94% from the previous close at $207.71. There is some discrepancy between reported prices.\\n\\n* **Alphabet Inc. Class A (GOOGL):** One source lists the price as $206.38 as of February 4th, 2025. Note that this is not the most current price.\\n\\nIt's important to note that stock prices are constantly changing, and these figures are snapshots from different times and sources. To get the most up-to-the-minute price, you should consult a live stock ticker or your preferred financial information source.\\n\"\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m]\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"role\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;32m\"model\"\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"finishReason\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;32m\"STOP\"\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"groundingMetadata\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"searchEntryPoint\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"renderedContent\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;32m\"\\n
\\n
\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n
\\n
\\n \\n
\\n\"\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"groundingChunks\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m[\n", + " \u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"web\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"uri\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;32m\"https://vertexaisearch.cloud.google.com/grounding-api-redirect/AUBnsYuL7uWJtwjgAuTWt0Z9-cX_i256U2016-lBn4JJqf8yBiiQI7ud9yezJolzudSPsN2fLyV8z-JhIoPA40yAv5PZ832kQYiuHELQrSKu8Yf5kQRWbn-ES_uIBXIkFoixlfYgCtA=\"\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"title\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;32m\"yahoo.com\"\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m,\n", + " \u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"web\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"uri\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;32m\"https://vertexaisearch.cloud.google.com/grounding-api-redirect/AUBnsYu5ej168MCMQA9ozLLBbiua_1cFvdHBLP0_-xYXEAhckxerQdtYkvShFPBqk9NeAA0MUlMztmyAHNwbS2qNe-lQXBX-4xOQ-khyygzaSq3bjN1PUkJyrbvX6Upy5qTaOzbz48vnEs6v3umO9Q==\"\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"title\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;32m\"tradingview.com\"\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m,\n", + " \u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"web\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"uri\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;32m\"https://vertexaisearch.cloud.google.com/grounding-api-redirect/AUBnsYtHKtN7ya-51rEnLje88PF0MtekqqACoAcRfPPzhrnTnQxfKkT4zWRYrpx7vBlgsxfpSOpWXiwbm3CxS_r4FM01zGHjfJamYQHa8grOaHEX0xKgZv1WI637IlMdMr9k_3mqAVefXNZQOWcNBeQDFyya2o69Nifmq18=\"\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"title\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;32m\"angelone.in\"\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m]\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"groundingSupports\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m[\n", + " \u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"segment\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"startIndex\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;39m160\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"endIndex\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;39m177\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"text\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;32m\"* **Alphabet Inc.\"\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"groundingChunkIndices\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m[\n", + " \u001b[0;39m0\u001b[0m\u001b[1;39m,\n", + " \u001b[0;39m1\u001b[0m\u001b[1;39m,\n", + " \u001b[0;39m2\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m]\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"confidenceScores\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m[\n", + " \u001b[0;39m0.63467747\u001b[0m\u001b[1;39m,\n", + " \u001b[0;39m0.6486053\u001b[0m\u001b[1;39m,\n", + " \u001b[0;39m0.65795654\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m]\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m,\n", + " \u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"segment\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"startIndex\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;39m390\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"endIndex\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;39m444\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"text\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;32m\"71. There is some discrepancy between reported prices.\"\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"groundingChunkIndices\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m[\n", + " \u001b[0;39m0\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m]\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"confidenceScores\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m[\n", + " \u001b[0;39m0.65081346\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m]\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m,\n", + " \u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"segment\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"startIndex\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;39m446\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"endIndex\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;39m463\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"text\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;32m\"* **Alphabet Inc.\"\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"groundingChunkIndices\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m[\n", + " \u001b[0;39m0\u001b[0m\u001b[1;39m,\n", + " \u001b[0;39m1\u001b[0m\u001b[1;39m,\n", + " \u001b[0;39m2\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m]\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"confidenceScores\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m[\n", + " \u001b[0;39m0.63467747\u001b[0m\u001b[1;39m,\n", + " \u001b[0;39m0.6486053\u001b[0m\u001b[1;39m,\n", + " \u001b[0;39m0.65795654\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m]\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m]\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"retrievalMetadata\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"googleSearchDynamicRetrievalScore\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;39m0.96872854\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"webSearchQueries\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m[\n", + " \u001b[0;32m\"what is the current google stock price\"\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m]\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"avgLogprobs\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;39m-0.18573995614151576\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m]\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"usageMetadata\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"promptTokenCount\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;39m8\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"candidatesTokenCount\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;39m239\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"totalTokenCount\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;39m247\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"promptTokensDetails\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m[\n", + " \u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"modality\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;32m\"TEXT\"\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"tokenCount\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;39m8\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m]\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"candidatesTokensDetails\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m[\n", + " \u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"modality\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;32m\"TEXT\"\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"tokenCount\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;39m239\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m]\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"modelVersion\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;32m\"gemini-1.5-flash\"\u001b[0m\u001b[1;39m\n", + "\u001b[1;39m}\u001b[0m\n" + ] + } + ], "source": [ - "!jq \"\" -r result.json" + "!jq . -r result.json" ] }, { @@ -193,7 +324,22 @@ "metadata": { "id": "IdjXdj5IpNNY" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The Google stock price varies depending on the class of shares and the source. As of today, February 6th, 2025, here's a summary of the information I found:\n", + "\n", + "* **Alphabet Inc. Class C (GOOG):** Prices reported range from $193.30 (showing a 2.50% increase in the last 24 hours) to $194.54 (intraday high). One source shows a significant decrease of 6.94% from the previous close at $207.71. There is some discrepancy between reported prices.\n", + "\n", + "* **Alphabet Inc. Class A (GOOGL):** One source lists the price as $206.38 as of February 4th, 2025. Note that this is not the most current price.\n", + "\n", + "It's important to note that stock prices are constantly changing, and these figures are snapshots from different times and sources. To get the most up-to-the-minute price, you should consult a live stock ticker or your preferred financial information source.\n", + "\n" + ] + } + ], "source": [ "!jq -r \".candidates[0].content.parts[0].text\" result.json" ] @@ -213,7 +359,94 @@ "metadata": { "id": "NIqD3Qp9qqnC" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"searchEntryPoint\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"renderedContent\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;32m\"\\n
\\n
\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n
\\n
\\n \\n
\\n\"\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"groundingChunks\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m[\n", + " \u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"web\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"uri\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;32m\"https://vertexaisearch.cloud.google.com/grounding-api-redirect/AUBnsYuL7uWJtwjgAuTWt0Z9-cX_i256U2016-lBn4JJqf8yBiiQI7ud9yezJolzudSPsN2fLyV8z-JhIoPA40yAv5PZ832kQYiuHELQrSKu8Yf5kQRWbn-ES_uIBXIkFoixlfYgCtA=\"\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"title\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;32m\"yahoo.com\"\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m,\n", + " \u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"web\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"uri\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;32m\"https://vertexaisearch.cloud.google.com/grounding-api-redirect/AUBnsYu5ej168MCMQA9ozLLBbiua_1cFvdHBLP0_-xYXEAhckxerQdtYkvShFPBqk9NeAA0MUlMztmyAHNwbS2qNe-lQXBX-4xOQ-khyygzaSq3bjN1PUkJyrbvX6Upy5qTaOzbz48vnEs6v3umO9Q==\"\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"title\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;32m\"tradingview.com\"\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m,\n", + " \u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"web\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"uri\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;32m\"https://vertexaisearch.cloud.google.com/grounding-api-redirect/AUBnsYtHKtN7ya-51rEnLje88PF0MtekqqACoAcRfPPzhrnTnQxfKkT4zWRYrpx7vBlgsxfpSOpWXiwbm3CxS_r4FM01zGHjfJamYQHa8grOaHEX0xKgZv1WI637IlMdMr9k_3mqAVefXNZQOWcNBeQDFyya2o69Nifmq18=\"\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"title\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;32m\"angelone.in\"\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m]\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"groundingSupports\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m[\n", + " \u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"segment\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"startIndex\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;39m160\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"endIndex\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;39m177\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"text\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;32m\"* **Alphabet Inc.\"\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"groundingChunkIndices\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m[\n", + " \u001b[0;39m0\u001b[0m\u001b[1;39m,\n", + " \u001b[0;39m1\u001b[0m\u001b[1;39m,\n", + " \u001b[0;39m2\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m]\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"confidenceScores\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m[\n", + " \u001b[0;39m0.63467747\u001b[0m\u001b[1;39m,\n", + " \u001b[0;39m0.6486053\u001b[0m\u001b[1;39m,\n", + " \u001b[0;39m0.65795654\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m]\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m,\n", + " \u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"segment\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"startIndex\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;39m390\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"endIndex\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;39m444\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"text\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;32m\"71. There is some discrepancy between reported prices.\"\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"groundingChunkIndices\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m[\n", + " \u001b[0;39m0\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m]\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"confidenceScores\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m[\n", + " \u001b[0;39m0.65081346\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m]\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m,\n", + " \u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"segment\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"startIndex\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;39m446\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"endIndex\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;39m463\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"text\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;32m\"* **Alphabet Inc.\"\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"groundingChunkIndices\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m[\n", + " \u001b[0;39m0\u001b[0m\u001b[1;39m,\n", + " \u001b[0;39m1\u001b[0m\u001b[1;39m,\n", + " \u001b[0;39m2\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m]\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"confidenceScores\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m[\n", + " \u001b[0;39m0.63467747\u001b[0m\u001b[1;39m,\n", + " \u001b[0;39m0.6486053\u001b[0m\u001b[1;39m,\n", + " \u001b[0;39m0.65795654\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m]\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m]\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"retrievalMetadata\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m{\n", + " \u001b[0m\u001b[34;1m\"googleSearchDynamicRetrievalScore\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[0;39m0.96872854\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m}\u001b[0m\u001b[1;39m,\n", + " \u001b[0m\u001b[34;1m\"webSearchQueries\"\u001b[0m\u001b[1;39m: \u001b[0m\u001b[1;39m[\n", + " \u001b[0;32m\"what is the current google stock price\"\u001b[0m\u001b[1;39m\n", + " \u001b[1;39m]\u001b[0m\u001b[1;39m\n", + "\u001b[1;39m}\u001b[0m\n" + ] + } + ], "source": [ "!jq -r \".candidates[0].groundingMetadata\" result.json" ] @@ -253,7 +486,145 @@ "metadata": { "id": "tLohvh3DqfSW" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "\n", + "
\n", + "
\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
\n", + "
\n", + " \n", + "
\n", + "\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# Python so you can display it in this notebook\n", "from IPython.display import HTML\n",