diff --git a/quickstarts/rest/Prompting_REST.ipynb b/quickstarts/rest/Prompting_REST.ipynb index 3ada441c3..2ca6500a0 100644 --- a/quickstarts/rest/Prompting_REST.ipynb +++ b/quickstarts/rest/Prompting_REST.ipynb @@ -110,7 +110,7 @@ " \"content\": {\n", " \"parts\": [\n", " {\n", - " \"text\": \"```python\\n# Example list to be sorted\\nlist1 = [5, 3, 1, 2, 4]\\n\\n# Sort the list in ascending order\\nlist1.sort()\\n\\n# Print the sorted list\\nprint(list1)\\n```\"\n", + " \"text\": \"```python\\n# Example list to be sorted\\nmy_list = [5, 3, 1, 2, 4]\\n\\n# Sort the list in ascending order using the sort() method\\nmy_list.sort()\\n\\n# Print the sorted list\\nprint(my_list)\\n```\\n\\nOutput:\\n\\n```\\n[1, 2, 3, 4, 5]\\n```\"\n", " }\n", " ],\n", " \"role\": \"model\"\n", @@ -137,25 +137,10 @@ " ]\n", " }\n", " ],\n", - " \"promptFeedback\": {\n", - " \"safetyRatings\": [\n", - " {\n", - " \"category\": \"HARM_CATEGORY_SEXUALLY_EXPLICIT\",\n", - " \"probability\": \"NEGLIGIBLE\"\n", - " },\n", - " {\n", - " \"category\": \"HARM_CATEGORY_HATE_SPEECH\",\n", - " \"probability\": \"NEGLIGIBLE\"\n", - " },\n", - " {\n", - " \"category\": \"HARM_CATEGORY_HARASSMENT\",\n", - " \"probability\": \"NEGLIGIBLE\"\n", - " },\n", - " {\n", - " \"category\": \"HARM_CATEGORY_DANGEROUS_CONTENT\",\n", - " \"probability\": \"NEGLIGIBLE\"\n", - " }\n", - " ]\n", + " \"usageMetadata\": {\n", + " \"promptTokenCount\": 9,\n", + " \"candidatesTokenCount\": 87,\n", + " \"totalTokenCount\": 96\n", " }\n", "}\n" ] @@ -182,9 +167,7 @@ "source": [ "### Use images in your prompt\n", "\n", - "Here we download an image from a URL and pass that image in our prompt.\n", - "\n", - "First, we download the image and load it with PIL:" + "Here you will download an image from a URL and pass that image in the prompt." ] }, { @@ -200,9 +183,7 @@ "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\r", - "100 349k 100 349k 0 0 1430k 0 --:--:-- --:--:-- --:--:-- 1436k\n" + "\r 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\r100 349k 100 349k 0 0 1548k 0 --:--:-- --:--:-- --:--:-- 1551k\n" ] } ], @@ -244,9 +225,9 @@ "id": "ZZenFznXQvJF" }, "source": [ - "Now we will base64 encode the image, and include it in our prompt.\n", + "Now you will base64 encode the image, and include it in the prompt.\n", "\n", - "There are slight output differences of different base64 encoding tools, so we have written two examples for you.\n", + "There are slight output differences of different base64 encoding tools, so you will need to pick the right one.\n", "\n", "The following will work in Google Colab." ] @@ -287,7 +268,7 @@ "id": "qFG3q7tJY2NW" }, "source": [ - "Then we can include the image in our prompt by just passing in the `request.json` created to `generateContent`." + "Then you can include the image in the prompt by just passing in the `request.json` created to `generateContent`." ] }, { @@ -307,7 +288,7 @@ " \"content\": {\n", " \"parts\": [\n", " {\n", - " \"text\": \" {\\n \\\"description\\\": \\\"The Jetpack Backpack is a lightweight backpack that looks like a normal backpack but has a number of features that make it perfect for travel. It has a built-in USB-C charging port, so you can charge your devices on the go. It also has a 15-minute battery life, so you can use it for short trips without having to worry about running out of power. The backpack also has retractable boosters that can be used to give you a boost of speed when you need it. The boosters are powered by steam, so they are green and clean.\\\",\\n \\\"features\\\": [\\n \\\"Fits 18\\\\\\\" laptop\\\",\\n \\\"Padded strap support\\\",\\n \\\"Lightweight\\\",\\n \\\"Retractable boosters\\\",\\n \\\"USB-C charging\\\",\\n \\\"15-minute battery life\\\",\\n \\\"Steam-powered, green/clean\\\"\\n ]\\n}\"\n", + " \"text\": \"```json\\n{\\n \\\"description\\\": \\\"The Jetpack Backpack is a backpack that allows the user to fly. It looks and functions like a normal backpack, but has retractable boosters that are powered by steam. The backpack has a 15-minute battery life and is charged via USB-C. The backpack is also lightweight and has padded strap support.\\\",\\n \\\"features\\\": [\\n \\\"retractable boosters\\\",\\n \\\"steam-powered\\\",\\n \\\"green/clean\\\",\\n \\\"15-min battery life\\\",\\n \\\"USB-C charging\\\",\\n \\\"padded strap support\\\",\\n \\\"lightweight\\\",\\n \\\"looks like a normal backpack\\\",\\n \\\"fits 18\\\\\\\" laptop\\\"\\n ]\\n}\\n```\"\n", " }\n", " ],\n", " \"role\": \"model\"\n", @@ -334,25 +315,10 @@ " ]\n", " }\n", " ],\n", - " \"promptFeedback\": {\n", - " \"safetyRatings\": [\n", - " {\n", - " \"category\": \"HARM_CATEGORY_SEXUALLY_EXPLICIT\",\n", - " \"probability\": \"NEGLIGIBLE\"\n", - " },\n", - " {\n", - " \"category\": \"HARM_CATEGORY_HATE_SPEECH\",\n", - " \"probability\": \"NEGLIGIBLE\"\n", - " },\n", - " {\n", - " \"category\": \"HARM_CATEGORY_HARASSMENT\",\n", - " \"probability\": \"NEGLIGIBLE\"\n", - " },\n", - " {\n", - " \"category\": \"HARM_CATEGORY_DANGEROUS_CONTENT\",\n", - " \"probability\": \"NEGLIGIBLE\"\n", - " }\n", - " ]\n", + " \"usageMetadata\": {\n", + " \"promptTokenCount\": 331,\n", + " \"candidatesTokenCount\": 154,\n", + " \"totalTokenCount\": 485\n", " }\n", "}\n" ] @@ -363,16 +329,7 @@ "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\r", - "100 466k 0 0 100 466k 0 2187k --:--:-- --:--:-- --:--:-- 2188k\r", - "100 466k 0 0 100 466k 0 367k 0:00:01 0:00:01 --:--:-- 367k\r", - "100 466k 0 0 100 466k 0 205k 0:00:02 0:00:02 --:--:-- 205k\r", - "100 466k 0 0 100 466k 0 142k 0:00:03 0:00:03 --:--:-- 142k\r", - "100 466k 0 0 100 466k 0 109k 0:00:04 0:00:04 --:--:-- 109k\r", - "100 466k 0 0 100 466k 0 90514 0:00:05 0:00:05 --:--:-- 0\r", - "100 468k 0 1952 100 466k 311 76249 0:00:06 0:00:06 --:--:-- 391\r", - "100 468k 0 1952 100 466k 311 76248 0:00:06 0:00:06 --:--:-- 489\n" + "\r 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\r 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\r100 466k 0 0 100 466k 0 298k 0:00:01 0:00:01 --:--:-- 298k\r100 467k 0 1410 100 466k 727 240k 0:00:01 0:00:01 --:--:-- 240k\n" ] } ], @@ -426,7 +383,7 @@ "id": "gpMssqFdNRDS" }, "source": [ - "Here we are `base64` encoding the image, and saving the curl request with the image data in a JSON file. Run this cell to see which version of `base64` you have. Based on the output, you may need to run this request on either a Mac or on Colab." + "Here image is being `base64` encoded, then savie the curl request with the image data in a JSON file. Run this cell to see which version of `base64` you have. Based on the output, you may need to run this request on either a Mac or on Colab." ] }, {