-
Notifications
You must be signed in to change notification settings - Fork 1
/
Day 1 - Prompting
1 lines (1 loc) · 85.2 KB
/
Day 1 - Prompting
1
{"metadata":{"kernelspec":{"name":"python3","display_name":"Python 3","language":"python"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"colab":{"name":"day-1-prompting.ipynb","toc_visible":true},"kaggle":{"accelerator":"none","dataSources":[],"dockerImageVersionId":30786,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"##### Copyright 2024 Google LLC.","metadata":{"id":"jkxRSYjzA1oX"}},{"cell_type":"code","source":"# @title Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# https://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.","metadata":{"cellView":"form","id":"5u5OZ2ShA3BA","jupyter":{"source_hidden":true},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Day 1 - Prompting\n\nWelcome to the Kaggle 5-day Generative AI course!\n\nThis notebook will show you how to get started with the Gemini API and walk you through some of the example prompts and techniques that you can also read about in the Prompting whitepaper. You don't need to read the whitepaper to use this notebook, but the papers will give you some theoretical context and background to complement this interactive notebook.\n\n\n## Before you begin\n\nIn this notebook, you'll start exploring prompts and prompt parameters using the Python SDK and AI Studio. For some inspiration, you might enjoy exploring some apps that have been built using the Gemini family of models. Here are a few that we like, and we think you will too.\n\n* [TextFX](https://textfx.withgoogle.com/) is a suite of AI-powered tools for rappers, made in collaboration with Lupe Fiasco,\n* [SQL Talk](https://sql-talk-r5gdynozbq-uc.a.run.app/) shows how you can talk directly to a database using the Gemini API,\n* [NotebookLM](https://notebooklm.google/) uses Gemini models to build your own personal AI research assistant.\n\n\n## For help\n\n**Common issues are covered in the [FAQ and troubleshooting guide](https://www.kaggle.com/code/markishere/day-0-troubleshooting-and-faqs).**\n\n### A note on the Gemini API and Vertex AI\n\nIn the whitepapers, most of the example code uses the Enterprise [Vertex AI platform](https://cloud.google.com/vertex-ai). In contrast, this notebook, along with the others in this series, will use the [Gemini Developer API](https://ai.google.dev/gemini-api/) and [AI Studio](https://aistudio.google.com/).\n\nBoth APIs provide access to the Gemini family of models, and the code to interact with the models is very similar. Vertex provides a world-class platform for enterprises, governments and advanced users that need powerful features like data governance, ML ops and deep Google Cloud integration.\n\nAI Studio is free to use and only requires a compatible Google account to log in and get started. It is deeply integrated with the Gemini API, which comes with a generous [free tier](https://ai.google.dev/pricing) that you can use to run the code in these exercises.\n\nIf you are already set up with Google Cloud, you can check out the [Enterprise Gemini API](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/inference) through Vertex AI, and run the samples directly from the supplied whitepapers.","metadata":{"id":"csNPnkuCobmG"}},{"cell_type":"markdown","source":"## Get started with Kaggle notebooks\n\nIf this is your first time using a Kaggle notebook, welcome! You can read about how to use Kaggle notebooks [in the docs](https://www.kaggle.com/docs/notebooks).\n\nFirst, you will need to phone verify your account at kaggle.com/settings.\n\n![](https://storage.googleapis.com/kaggle-media/Images/5dgai_0.png)","metadata":{"id":"f00ea7c99e44"},"attachments":{"d8299597-f771-4195-ac94-1d6f658ef2bd.png":{"image/png":"iVBORw0KGgoAAAANSUhEUgAAATEAAABgCAYAAAB1wEWOAAAABHNCSVQICAgIfAhkiAAAEn5JREFUeF7tnQd4VFUahn8iSIAUMASIwUWkSC8JuktTUFCw64oFlCLEgogVdR9BWRQp9lVBwLWsKII0UZRQVTQoVaWFFqqAtBBpQQH3fGeYMIMzSSZz7uXeyfc/Tx6GW055z73fPec/rcSfyoRGAiRAAi4lEOXSdDPZJ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RIBIoUy/kdYyIkCkkBFcEq1MBIgUyvQbaS0jAkQKGcEl0cpEgEihTL+R1jIiIAkp+NmtlAgBtSAgCSn4f275cfhqTvUVenKImn0il22SkIKf9GZj8+4UN7kU1bdcMzMTvH71Wt9qUPs1gIAkpOB6OjjY14C6+mvCoqE5smvgzCH9WUgtaxCQjBRO7GRru/dnl6oRXhMTY5ixq6iwSI3mkU3FEJCMFJaWlvjkk0nsRLey5+ioBfEWzZui6OUrIoZaHPoBOyQjBZc/YcJ44VCr9u3bfaA55T9u29pKONby2fMsmmMo353lWiDZaR7FpcfFXWRHHJ5H0vXruHXrJyFL6YehlUavkIVR2Tm57BjGQuEIS0rqQUAWUqgHHrLEEBGQNHwyRADJZvUhQKRQn0/JomoiQKSoJoBUXX0I/B/sqXumoizqmgAAAABJRU5ErkJggg=="}}},{"cell_type":"markdown","source":"To run this notebook, as well as the others in this course, you will need to make a copy, or fork, the notebook. Look for the `Copy and Edit` button in the top-right, and **click it** to make an editable, private copy of the notebook. It should look like this one:\n\n![Copy and Edit button](https://storage.googleapis.com/kaggle-media/Images/5gdai_sc_1.png)\n\nYour copy will now have a ▶️ **Run** button next to each code cell that you can press to execute that cell. These notebooks are expected to be run in order from top-to-bottom, but you are encouraged to add new cells, run your own code and explore. If you get stuck, you can try the `Factory reset` option in the `Run` menu, or head back to the original notebook and make a fresh copy.\n\n![Run cell button](https://storage.googleapis.com/kaggle-media/Images/5gdai_sc_2.png)\n\n### Problems?\n\nIf you have any problems, head over to the [Kaggle Discord](https://discord.com/invite/kaggle), find the [`#5dgai-q-and-a` channel](https://discord.com/channels/1101210829807956100/1303438695143178251) and ask for help.","metadata":{}},{"cell_type":"markdown","source":"## Get started with the Gemini API\n\nAll of the exercises in this notebook will use the [Gemini API](https://ai.google.dev/gemini-api/) by way of the [Python SDK](https://pypi.org/project/google-generativeai/). Each of these prompts can be accessed directly in [Google AI Studio](https://aistudio.google.com/) too, so if you would rather use a web interface and skip the code for this activity, look for the <img src=\"https://ai.google.dev/site-assets/images/marketing/home/icon-ais.png\" style=\"height: 24px\" height=24/> AI Studio link on each prompt.","metadata":{"id":"ExkOXcPxtTb5"}},{"cell_type":"markdown","source":"Next, you will need to add your API key to your Kaggle Notebook as a Kaggle User Secret.\n\n![](https://storage.googleapis.com/kaggle-media/Images/5dgai_1.png)\n![](https://storage.googleapis.com/kaggle-media/Images/5dgai_2.png)\n![](https://storage.googleapis.com/kaggle-media/Images/5dgai_3.png)\n![](https://storage.googleapis.com/kaggle-media/Images/5dgai_4.png)","metadata":{}},{"cell_type":"markdown","source":"### Install the SDK","metadata":{"id":"UAjUV3BsvFXQ"}},{"cell_type":"code","source":"%pip install -U -q \"google-generativeai>=0.8.3\"","metadata":{"id":"NzwzJFU9LqkJ","trusted":true,"execution":{"iopub.status.busy":"2024-11-12T14:53:50.392114Z","iopub.execute_input":"2024-11-12T14:53:50.392718Z","iopub.status.idle":"2024-11-12T14:54:22.224840Z","shell.execute_reply.started":"2024-11-12T14:53:50.392656Z","shell.execute_reply":"2024-11-12T14:54:22.223461Z"}},"outputs":[{"name":"stdout","text":"Note: you may need to restart the kernel to use updated packages.\n","output_type":"stream"}],"execution_count":1},{"cell_type":"code","source":"import google.generativeai as genai\nfrom IPython.display import HTML, Markdown, display","metadata":{"id":"5DwxYIRavMST","trusted":true,"execution":{"iopub.status.busy":"2024-11-12T14:54:46.970203Z","iopub.execute_input":"2024-11-12T14:54:46.971463Z","iopub.status.idle":"2024-11-12T14:54:48.247061Z","shell.execute_reply.started":"2024-11-12T14:54:46.971403Z","shell.execute_reply":"2024-11-12T14:54:48.245545Z"}},"outputs":[],"execution_count":2},{"cell_type":"markdown","source":"### Set up your API key\n\nTo run the following cell, your API key must be stored it in a [Kaggle secret](https://www.kaggle.com/discussions/product-feedback/114053) named `GOOGLE_API_KEY`.\n\nIf you don't already have an API key, you can grab one from [AI Studio](https://aistudio.google.com/app/apikey). You can find [detailed instructions in the docs](https://ai.google.dev/gemini-api/docs/api-key).\n\nTo make the key available through Kaggle secrets, choose `Secrets` from the `Add-ons` menu and follow the instructions to add your key or enable it for this notebook.","metadata":{"id":"DNEt2BCOvOJ1"}},{"cell_type":"code","source":"from kaggle_secrets import UserSecretsClient\n\nGOOGLE_API_KEY = UserSecretsClient().get_secret(\"GEN AI\")\ngenai.configure(api_key=GOOGLE_API_KEY)","metadata":{"id":"SHl0bkPCvayd","trusted":true,"execution":{"iopub.status.busy":"2024-11-12T14:54:52.749588Z","iopub.execute_input":"2024-11-12T14:54:52.750782Z","iopub.status.idle":"2024-11-12T14:54:53.053073Z","shell.execute_reply.started":"2024-11-12T14:54:52.750732Z","shell.execute_reply":"2024-11-12T14:54:53.051886Z"}},"outputs":[],"execution_count":3},{"cell_type":"markdown","source":"If you received an error response along the lines of `No user secrets exist for kernel id ...`, then you need to add your API key via `Add-ons`, `Secrets` **and** enable it.\n\n![Screenshot of the checkbox to enable GOOGLE_API_KEY secret](https://storage.googleapis.com/kaggle-media/Images/5gdai_sc_3.png)","metadata":{"id":"4e720472fd86"},"attachments":{"d2be9aab-2527-48af-b6cf-1f06cdd7c3a7.png":{"image/png":"iVBORw0KGgoAAAANSUhEUgAAAZ0AAAEcCAYAAAAcM2nfAAAAAXNSR0IArs4c6QAAIABJREFUeAHtnYVbHEnXxfOnvCvJxl2Ju+vG3Xfj7rJxYht3d3d3JR5ixCAESEggEAgQt839vlNJTZphGoaZnmGA08/T6aGnuuTXN3X6Vt3qyZHDbhNuJEACJEACJOAhAnaSkyOHh8phtiRAAiRAAiQgFB0aAQmQAAmQgNcIUHS8hpoFkQAJkAAJUHRoAyRAAiRAAl4jQNHxGmoWRAIkQAIkQNGhDZAACZAACXiNAEXHa6hZEAmQAAmQAEWHNkACJEACJOA1AhQdr6FmQSRAAiRAAhQd2gAJkAAJkIDXCFB0vIaaBZEACZAACVB0aAMkQAIkQAJeI0DR8RpqFkQCJEACJEDRoQ2QAAmQAAl4jQBFx2uoWRAJkAAJkABFhzZAAiRAAiTgNQIUHa+hZk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LMjwRIgARIwJQARccUDb8gARIgARKwmgBFx2qizI8ESIAESMCUAEXHFA2/IAESIAESsJoARcdqosyPBEiABEjAlABFxxQNvyABEiABErCagMuiExefICGhEdzJgDZAG6ANZHMbgB44u7ksOs4WwHQkQAIkQAIkoAlQdDQJHkmABEiABDxOgKLjccQsgARIgARIQBOg6GgSPJIACZAACXicwP8BSlZtIfGtyBAAAAAASUVORK5CYII="}}},{"cell_type":"markdown","source":"### Run your first prompt\n\nIn this step, you will test that your API key is set up correctly by making a request. The `gemini-1.5-flash` model has been selected here.","metadata":{"id":"H_YXCYIKvyZJ"}},{"cell_type":"code","source":"flash = genai.GenerativeModel('gemini-1.5-flash')\nresponse = flash.generate_content(\"Explain AI to me like I'm a kid.\")\nprint(response.text)","metadata":{"id":"BV1o0PmcvyJF","trusted":true,"execution":{"iopub.status.busy":"2024-11-12T14:54:58.870229Z","iopub.execute_input":"2024-11-12T14:54:58.870700Z","iopub.status.idle":"2024-11-12T14:55:00.960643Z","shell.execute_reply.started":"2024-11-12T14:54:58.870654Z","shell.execute_reply":"2024-11-12T14:55:00.959227Z"}},"outputs":[{"name":"stdout","text":"Imagine you have a really smart robot friend. It can learn things just like you do, but much faster! It can learn from pictures, videos, and even stories you tell it. \n\nThis robot friend, that's what AI (Artificial Intelligence) is like. It's a computer program that can think and learn like a person, but much faster and better at some things. \n\nHere are some things AI can do:\n\n* **Play games:** AI can play games like chess or even video games better than humans!\n* **Answer questions:** You can ask AI questions, and it will try to answer them based on all the information it has learned.\n* **Make pictures and music:** AI can create beautiful art and music just like a human artist.\n* **Help you with tasks:** AI can help you write emails, translate languages, and even drive your car. \n\nIt's still learning and getting better every day! \n\n","output_type":"stream"}],"execution_count":4},{"cell_type":"markdown","source":"The response often comes back in markdown format, which you can render directly in this notebook.","metadata":{"id":"f60ed9d8ae41"}},{"cell_type":"code","source":"Markdown(response.text)","metadata":{"id":"c933e5e460a5","trusted":true,"execution":{"iopub.status.busy":"2024-11-12T14:55:04.475968Z","iopub.execute_input":"2024-11-12T14:55:04.476451Z","iopub.status.idle":"2024-11-12T14:55:04.486402Z","shell.execute_reply.started":"2024-11-12T14:55:04.476378Z","shell.execute_reply":"2024-11-12T14:55:04.485217Z"}},"outputs":[{"execution_count":5,"output_type":"execute_result","data":{"text/plain":"<IPython.core.display.Markdown object>","text/markdown":"Imagine you have a really smart robot friend. It can learn things just like you do, but much faster! It can learn from pictures, videos, and even stories you tell it. \n\nThis robot friend, that's what AI (Artificial Intelligence) is like. It's a computer program that can think and learn like a person, but much faster and better at some things. \n\nHere are some things AI can do:\n\n* **Play games:** AI can play games like chess or even video games better than humans!\n* **Answer questions:** You can ask AI questions, and it will try to answer them based on all the information it has learned.\n* **Make pictures and music:** AI can create beautiful art and music just like a human artist.\n* **Help you with tasks:** AI can help you write emails, translate languages, and even drive your car. \n\nIt's still learning and getting better every day! \n"},"metadata":{}}],"execution_count":5},{"cell_type":"markdown","source":"### Start a chat\n\nThe previous example uses a single-turn, text-in/text-out structure, but you can also set up a multi-turn chat structure too.","metadata":{"id":"byx0pT9ZMW2Q"}},{"cell_type":"code","source":"chat = flash.start_chat(history=[])\nresponse = chat.send_message('Hello! My name is Zlork.')\nprint(response.text)","metadata":{"id":"lV_S5ZL5MidD","trusted":true,"execution":{"iopub.status.busy":"2024-11-12T14:55:09.161148Z","iopub.execute_input":"2024-11-12T14:55:09.161608Z","iopub.status.idle":"2024-11-12T14:55:10.269656Z","shell.execute_reply.started":"2024-11-12T14:55:09.161563Z","shell.execute_reply":"2024-11-12T14:55:10.268446Z"}},"outputs":[{"name":"stdout","text":"Hello Zlork! It's nice to meet you. What can I do for you today? 😊 \n\n","output_type":"stream"}],"execution_count":6},{"cell_type":"code","source":"response = chat.send_message('Can you tell something interesting about dinosaurs?')\nprint(response.text)","metadata":{"id":"7b0372c3c64a","trusted":true,"execution":{"iopub.status.busy":"2024-11-12T14:55:13.793917Z","iopub.execute_input":"2024-11-12T14:55:13.794367Z","iopub.status.idle":"2024-11-12T14:55:15.518448Z","shell.execute_reply.started":"2024-11-12T14:55:13.794323Z","shell.execute_reply":"2024-11-12T14:55:15.517300Z"}},"outputs":[{"name":"stdout","text":"Okay, Zlork! Dinosaurs are fascinating, aren't they? Here's something interesting: \n\n**Did you know that some dinosaurs were actually feathered?** \n\nWhile we often picture dinosaurs as scaly beasts, many species, especially smaller ones, had feathers! Scientists have found evidence of feathers on a wide range of dinosaur species, including the famous velociraptors. This discovery has changed our understanding of dinosaurs and their evolution, suggesting that birds are actually the direct descendants of these feathered dinosaurs. \n\n Isn't that cool? What else would you like to know about dinosaurs? 🦖\n\n","output_type":"stream"}],"execution_count":7},{"cell_type":"code","source":"# While you have the `chat` object around, the conversation state\n# persists. Confirm that by asking if it knows my name.\nresponse = chat.send_message('Do you remember what my name is?')\nprint(response.text)","metadata":{"id":"d3f9591392a7","trusted":true,"execution":{"iopub.status.busy":"2024-11-12T14:55:21.243295Z","iopub.execute_input":"2024-11-12T14:55:21.243762Z","iopub.status.idle":"2024-11-12T14:55:22.508480Z","shell.execute_reply.started":"2024-11-12T14:55:21.243717Z","shell.execute_reply":"2024-11-12T14:55:22.507225Z"}},"outputs":[{"name":"stdout","text":"Of course I do, Zlork! I have a great memory, especially for names. 😊 \n\nWhat else can I help you with today? \n\n","output_type":"stream"}],"execution_count":8},{"cell_type":"markdown","source":"### Choose a model\n\nThe Gemini API provides access to a number of models from the Gemini model family. Read about the available models and their capabilities on the [model overview page](https://ai.google.dev/gemini-api/docs/models/gemini).\n\nIn this step you'll use the API to list all of the available models.","metadata":{"id":"2KAjpr1200sW"}},{"cell_type":"code","source":"for model in genai.list_models():\n print(model.name)","metadata":{"id":"uUUZa2uq2jDm","trusted":true,"execution":{"iopub.status.busy":"2024-11-12T14:55:26.977974Z","iopub.execute_input":"2024-11-12T14:55:26.978411Z","iopub.status.idle":"2024-11-12T14:55:27.759785Z","shell.execute_reply.started":"2024-11-12T14:55:26.978356Z","shell.execute_reply":"2024-11-12T14:55:27.758479Z"}},"outputs":[{"name":"stdout","text":"models/chat-bison-001\nmodels/text-bison-001\nmodels/embedding-gecko-001\nmodels/gemini-1.0-pro-latest\nmodels/gemini-1.0-pro\nmodels/gemini-pro\nmodels/gemini-1.0-pro-001\nmodels/gemini-1.0-pro-vision-latest\nmodels/gemini-pro-vision\nmodels/gemini-1.5-pro-latest\nmodels/gemini-1.5-pro-001\nmodels/gemini-1.5-pro-002\nmodels/gemini-1.5-pro\nmodels/gemini-1.5-pro-exp-0801\nmodels/gemini-1.5-pro-exp-0827\nmodels/gemini-1.5-flash-latest\nmodels/gemini-1.5-flash-001\nmodels/gemini-1.5-flash-001-tuning\nmodels/gemini-1.5-flash\nmodels/gemini-1.5-flash-exp-0827\nmodels/gemini-1.5-flash-002\nmodels/gemini-1.5-flash-8b\nmodels/gemini-1.5-flash-8b-001\nmodels/gemini-1.5-flash-8b-latest\nmodels/gemini-1.5-flash-8b-exp-0827\nmodels/gemini-1.5-flash-8b-exp-0924\nmodels/embedding-001\nmodels/text-embedding-004\nmodels/aqa\n","output_type":"stream"}],"execution_count":9},{"cell_type":"markdown","source":"The [`models.list`](https://ai.google.dev/api/models#method:-models.list) response also returns additional information about the model's capabilities, like the token limits and supported parameters.","metadata":{"id":"rN49kSI54R1v"}},{"cell_type":"code","source":"for model in genai.list_models():\n if model.name == 'models/gemini-1.5-flash':\n print(model)\n break","metadata":{"id":"k7JJ1K6j4Rl8","trusted":true,"execution":{"iopub.status.busy":"2024-11-12T14:55:33.641673Z","iopub.execute_input":"2024-11-12T14:55:33.642670Z","iopub.status.idle":"2024-11-12T14:55:34.485591Z","shell.execute_reply.started":"2024-11-12T14:55:33.642624Z","shell.execute_reply":"2024-11-12T14:55:34.484319Z"}},"outputs":[{"name":"stdout","text":"Model(name='models/gemini-1.5-flash',\n base_model_id='',\n version='001',\n display_name='Gemini 1.5 Flash',\n description='Fast and versatile multimodal model for scaling across diverse tasks',\n input_token_limit=1000000,\n output_token_limit=8192,\n supported_generation_methods=['generateContent', 'countTokens'],\n temperature=1.0,\n max_temperature=2.0,\n top_p=0.95,\n top_k=40)\n","output_type":"stream"}],"execution_count":10},{"cell_type":"markdown","source":"## Explore generation parameters\n\n","metadata":{"id":"5rU_UBlZdooM"}},{"cell_type":"markdown","source":"### Output length\n\nWhen generating text with an LLM, the output length affects cost and performance. Generating more tokens increases computation, leading to higher energy consumption, latency, and cost.\n\nTo stop the model from generating tokens past a limit, you can specify the `max_output_length` parameter when using the Gemini API. Specifying this parameter does not influence the generation of the output tokens, so the output will not become more stylistically or textually succinct, but it will stop generating tokens once the specified length is reached. Prompt engineering may be required to generate a more complete output for your given limit.","metadata":{"id":"G7NfEizeipbW"}},{"cell_type":"code","source":"short_model = genai.GenerativeModel(\n 'gemini-1.5-flash',\n generation_config=genai.GenerationConfig(max_output_tokens=200))\n\nresponse = short_model.generate_content('Write a 1000 word essay on the importance of olives in modern society.')\nprint(response.text)","metadata":{"id":"qVf23JsIi9ma","trusted":true,"execution":{"iopub.status.busy":"2024-11-12T14:56:00.339164Z","iopub.execute_input":"2024-11-12T14:56:00.340130Z","iopub.status.idle":"2024-11-12T14:56:02.448230Z","shell.execute_reply.started":"2024-11-12T14:56:00.340080Z","shell.execute_reply":"2024-11-12T14:56:02.446621Z"}},"outputs":[{"name":"stdout","text":"## The Enduring Essence of Olives: From Antiquity to the Modern Plate\n\nThe olive, a symbol of peace, prosperity, and longevity, has woven its way through millennia, leaving an indelible mark on human history and culture. From the ancient olive groves of the Mediterranean to the bustling markets of today, the olive has transcended its role as a mere food source, becoming a cornerstone of culinary traditions, a vital contributor to economies, and a symbol of cultural identity. \n\nThe olive's story is deeply intertwined with the emergence of civilization itself. Its cultivation, dating back to the Bronze Age, gave rise to prosperous societies across the Mediterranean basin. Ancient Greeks, revered the olive tree as a gift from Athena, the goddess of wisdom and agriculture, associating it with peace, fertility, and the triumph of intellect. Romans, too, held the olive in high regard, utilizing its oil for both cooking and lighting, and employing its wood in construction and shipbuilding. The olive, therefore, served not only\n","output_type":"stream"}],"execution_count":11},{"cell_type":"code","source":"response = short_model.generate_content('Write a short poem on the importance of olives in modern society.')\nprint(response.text)","metadata":{"id":"W-3kR2F5kdMR","trusted":true,"execution":{"iopub.status.busy":"2024-11-12T14:56:05.695365Z","iopub.execute_input":"2024-11-12T14:56:05.695794Z","iopub.status.idle":"2024-11-12T14:56:07.289471Z","shell.execute_reply.started":"2024-11-12T14:56:05.695754Z","shell.execute_reply":"2024-11-12T14:56:07.288214Z"}},"outputs":[{"name":"stdout","text":"A tiny fruit, a verdant hue,\nFrom ancient lands, a taste so true.\nThe olive tree, a steadfast friend,\nIts bounty shared, till time's end.\n\nFrom savory spreads to vibrant oils,\nIt graces tables, fills our toils.\nA symbol of peace, a calming grace,\nIn every dish, its flavor embraced.\n\nFrom ancient Greece to modern days,\nA gift of nature, in many ways.\nThe olive stands, a timeless prize,\nA treasure for the human eyes. \n\n","output_type":"stream"}],"execution_count":12},{"cell_type":"markdown","source":"Explore with your own prompts. Try a prompt with a restrictive output limit and then adjust the prompt to work within that limit.","metadata":{"id":"3ZhDSLB6lqqB"}},{"cell_type":"markdown","source":"### Temperature\n\nTemperature controls the degree of randomness in token selection. Higher temperatures result in a higher number of candidate tokens from which the next output token is selected, and can produce more diverse results, while lower temperatures have the opposite effect, such that a temperature of 0 results in greedy decoding, selecting the most probable token at each step.\n\nTemperature doesn't provide any guarantees of randomness, but it can be used to \"nudge\" the output somewhat.","metadata":{"id":"alx-WaAvir_9"}},{"cell_type":"code","source":"import time\n\nhigh_temp_model = genai.GenerativeModel(\n 'gemini-1.5-flash',\n generation_config=genai.GenerationConfig(temperature=2.0))\n\nfor _ in range(3):\n response = high_temp_model.generate_content('Pick a random colour... (answer in a single word)')\n if response.parts:\n print(response.text, '-' * 25)\n\n # Slow down a bit so we don't get Resource Exhausted errors.\n time.sleep(20)","metadata":{"id":"SHraGMzqnZqt","trusted":true,"execution":{"iopub.status.busy":"2024-11-12T14:58:39.139590Z","iopub.execute_input":"2024-11-12T14:58:39.140825Z","iopub.status.idle":"2024-11-12T14:59:40.642301Z","shell.execute_reply.started":"2024-11-12T14:58:39.140775Z","shell.execute_reply":"2024-11-12T14:59:40.641276Z"}},"outputs":[{"name":"stdout","text":"Green. \n -------------------------\nPurple \n -------------------------\nPurple. \n -------------------------\n","output_type":"stream"}],"execution_count":13},{"cell_type":"markdown","source":"Now try the same prompt with temperature set to zero. Note that the output is not completely deterministic, as other parameters affect token selection, but the results will tend to be more stable.","metadata":{"id":"z3J4pCTuof7e"}},{"cell_type":"code","source":"low_temp_model = genai.GenerativeModel(\n 'gemini-1.5-flash',\n generation_config=genai.GenerationConfig(temperature=0.0))\n\nfor _ in range(4):\n response = low_temp_model.generate_content('Pick a random colour... (answer in a single word)')\n if response.parts:\n print(response.text, '-' * 25)\n\n time.sleep(20)","metadata":{"id":"clymkWv-PfUZ","trusted":true,"execution":{"iopub.status.busy":"2024-11-12T15:02:44.742617Z","iopub.execute_input":"2024-11-12T15:02:44.743068Z","iopub.status.idle":"2024-11-12T15:04:07.798958Z","shell.execute_reply.started":"2024-11-12T15:02:44.743025Z","shell.execute_reply":"2024-11-12T15:04:07.797880Z"}},"outputs":[{"name":"stdout","text":"Purple \n -------------------------\nPurple \n -------------------------\nPurple \n -------------------------\nPurple \n -------------------------\n","output_type":"stream"}],"execution_count":14},{"cell_type":"markdown","source":"### Top-K and top-P\n\nLike temperature, top-K and top-P parameters are also used to control the diversity of the model's output.\n\nTop-K is a positive integer that defines the number of most probable tokens from which to select the output token. A top-K of 1 selects a single token, performing greedy decoding.\n\nTop-P defines the probability threshold that, once cumulatively exceeded, tokens stop being selected as candidates. A top-P of 0 is typically equivalent to greedy decoding, and a top-P of 1 typically selects every token in the model's vocabulary.\n\nWhen both are supplied, the Gemini API will filter top-K tokens first, then top-P and then finally sample from the candidate tokens using the supplied temperature.\n\nRun this example a number of times, change the settings and observe the change in output.","metadata":{"id":"St5nt3vzitsZ"}},{"cell_type":"code","source":"model = genai.GenerativeModel(\n 'gemini-1.5-flash-001',\n generation_config=genai.GenerationConfig(\n # These are the default values for gemini-1.5-flash-001.\n temperature=1.0,\n top_k=64,\n top_p=0.95,\n ))\n\nstory_prompt = \"You are a creative writer. Write a short story about a cat who goes on an adventure.\"\nresponse = model.generate_content(story_prompt)\nprint(response.text)","metadata":{"id":"lPlzpEavUV8F","trusted":true,"execution":{"iopub.status.busy":"2024-11-12T15:11:47.546972Z","iopub.execute_input":"2024-11-12T15:11:47.547485Z","iopub.status.idle":"2024-11-12T15:11:50.435514Z","shell.execute_reply.started":"2024-11-12T15:11:47.547442Z","shell.execute_reply":"2024-11-12T15:11:50.434319Z"}},"outputs":[{"name":"stdout","text":"Bartholomew, a ginger cat with a penchant for sunbeams and existential contemplation, was bored. The usual routine of chasing dust bunnies and batting at dangling toys was, frankly, tiresome. One day, as he lounged on the windowsill, a curious sight caught his eye: a plump, juicy robin perched on the feeder outside. It was a chance encounter, but Bartholomew knew it was destiny.\n\nA daring plan formed in his mind. He would follow the robin, leaving the confines of his human’s house for the first time. The backyard beckoned with its mysteries – whispering trees, rustling leaves, and an endless expanse of green.\n\nHe crept down the trellis, his emerald eyes focused on the robin. The bird, oblivious to the feline pursuit, hopped from branch to branch, chirping merrily. Bartholomew followed, his tail swishing with anticipation. He navigated a maze of garden gnomes, dodging startled squirrels and curious chipmunks. The world was a sensory feast, filled with the scent of blooming honeysuckle and the buzzing of bees.\n\nSuddenly, the robin landed on a low-hanging branch, close enough for Bartholomew to pounce. But just as he was about to spring, a monstrous shadow engulfed him. He froze, his heart hammering in his chest. It was a dog, a hulking beast with a wagging tail and a friendly smile.\n\nBartholomew, remembering his mother's warnings about dogs, let out a hiss. The dog, taken aback, retreated. The robin, sensing the tension, chirped encouragingly.\n\nBartholomew, emboldened by the bird’s support, continued his journey. He crossed a rickety wooden bridge, his whiskers brushing against the water lilies below. He even managed to catch a grasshopper, which he devoured with gusto.\n\nAs the sun began to set, casting long shadows across the lawn, Bartholomew knew it was time to return home. He bid farewell to his feathered friend, promising to meet again the next day. \n\nHe climbed back onto the trellis, feeling a strange mixture of exhaustion and exhilaration. He had seen the world beyond his windowsill, experienced a thrilling adventure, and discovered a new friend. \n\nBartholomew, the once bored house cat, now had stories to tell. He curled up on his favorite cushion, purring contentedly as his human scratched his ears. The world, he realized, was a vast and wondrous place, full of endless possibilities. And he, Bartholomew, was ready to explore it all, one robin-led adventure at a time. \n\n","output_type":"stream"}],"execution_count":15},{"cell_type":"markdown","source":"## Prompting\n\nThis section contains some prompts from the chapter for you to try out directly in the API. Try changing the text here to see how each prompt performs with different instructions, more examples, or any other changes you can think of.","metadata":{"id":"rMrYs1koY6DX"}},{"cell_type":"markdown","source":"### Zero-shot\n\nZero-shot prompts are prompts that describe the request for the model directly.\n\n<table align=left>\n <td>\n <a target=\"_blank\" href=\"https://aistudio.google.com/prompts/1gzKKgDHwkAvexG5Up0LMtl1-6jKMKe4g\"><img src=\"https://ai.google.dev/site-assets/images/marketing/home/icon-ais.png\" style=\"height: 24px\" height=24/> Open in AI Studio</a>\n </td>\n</table>","metadata":{"id":"hhj_tQidZJP7"}},{"cell_type":"code","source":"model = genai.GenerativeModel(\n 'gemini-1.5-flash-001',\n generation_config=genai.GenerationConfig(\n temperature=0.1,\n top_p=1,\n max_output_tokens=5,\n ))\n\nzero_shot_prompt = \"\"\"Classify movie reviews as POSITIVE, NEUTRAL or NEGATIVE.\nReview: \"Her\" is a disturbing study revealing the direction\nhumanity is headed if AI is allowed to keep evolving,\nunchecked. I wish there were more movies like this masterpiece.\nSentiment: \"\"\"\n\nresponse = model.generate_content(zero_shot_prompt)\nprint(response.text)","metadata":{"id":"1_t-cwnDZzbH","trusted":true,"execution":{"iopub.status.busy":"2024-11-12T15:11:57.619078Z","iopub.execute_input":"2024-11-12T15:11:57.619552Z","iopub.status.idle":"2024-11-12T15:11:58.112720Z","shell.execute_reply.started":"2024-11-12T15:11:57.619505Z","shell.execute_reply":"2024-11-12T15:11:58.111353Z"}},"outputs":[{"name":"stdout","text":"Sentiment: **POSITIVE**\n","output_type":"stream"}],"execution_count":16},{"cell_type":"markdown","source":"#### Enum mode\n\nThe models are trained to generate text, and can sometimes produce more text than you may wish for. In the preceding example, the model will output the label, sometimes it can include a preceding \"Sentiment\" label, and without an output token limit, it may also add explanatory text afterwards.\n\nThe Gemini API has an [Enum mode](https://github.com/google-gemini/cookbook/blob/main/quickstarts/Enum.ipynb) feature that allows you to constrain the output to a fixed set of values.","metadata":{"id":"3b5568bdeb11"}},{"cell_type":"code","source":"import enum\n\nclass Sentiment(enum.Enum):\n POSITIVE = \"positive\"\n NEUTRAL = \"neutral\"\n NEGATIVE = \"negative\"\n\n\nmodel = genai.GenerativeModel(\n 'gemini-1.5-flash-001',\n generation_config=genai.GenerationConfig(\n response_mime_type=\"text/x.enum\",\n response_schema=Sentiment\n ))\n\nresponse = model.generate_content(zero_shot_prompt)\nprint(response.text)","metadata":{"id":"ad118a56c598","trusted":true,"execution":{"iopub.status.busy":"2024-11-12T15:12:14.269700Z","iopub.execute_input":"2024-11-12T15:12:14.270132Z","iopub.status.idle":"2024-11-12T15:12:14.962454Z","shell.execute_reply.started":"2024-11-12T15:12:14.270092Z","shell.execute_reply":"2024-11-12T15:12:14.961323Z"}},"outputs":[{"name":"stdout","text":"positive\n","output_type":"stream"}],"execution_count":17},{"cell_type":"markdown","source":"### One-shot and few-shot\n\nProviding an example of the expected response is known as a \"one-shot\" prompt. When you provide multiple examples, it is a \"few-shot\" prompt.\n\n<table align=left>\n <td>\n <a target=\"_blank\" href=\"https://aistudio.google.com/prompts/1jjWkjUSoMXmLvMJ7IzADr_GxHPJVV2bg\"><img src=\"https://ai.google.dev/site-assets/images/marketing/home/icon-ais.png\" style=\"height: 24px\" height=24/> Open in AI Studio</a>\n </td>\n</table>\n","metadata":{"id":"0udiSwNbv45W"}},{"cell_type":"code","source":"model = genai.GenerativeModel(\n 'gemini-1.5-flash-latest',\n generation_config=genai.GenerationConfig(\n temperature=0.1,\n top_p=1,\n max_output_tokens=250,\n ))\n\nfew_shot_prompt = \"\"\"Parse a customer's pizza order into valid JSON:\n\nEXAMPLE:\nI want a small pizza with cheese, tomato sauce, and pepperoni.\nJSON Response:\n```\n{\n\"size\": \"small\",\n\"type\": \"normal\",\n\"ingredients\": [\"cheese\", \"tomato sauce\", \"peperoni\"]\n}\n```\n\nEXAMPLE:\nCan I get a large pizza with tomato sauce, basil and mozzarella\nJSON Response:\n```\n{\n\"size\": \"large\",\n\"type\": \"normal\",\n\"ingredients\": [\"tomato sauce\", \"basil\", \"mozzarella\"]\n}\n\nORDER:\n\"\"\"\n\ncustomer_order = \"Give me a large with cheese & pineapple\"\n\n\nresponse = model.generate_content([few_shot_prompt, customer_order])\nprint(response.text)","metadata":{"id":"hd4mVUukwOKZ","trusted":true,"execution":{"iopub.status.busy":"2024-11-12T15:12:25.273315Z","iopub.execute_input":"2024-11-12T15:12:25.274333Z","iopub.status.idle":"2024-11-12T15:12:25.831732Z","shell.execute_reply.started":"2024-11-12T15:12:25.274282Z","shell.execute_reply":"2024-11-12T15:12:25.830571Z"}},"outputs":[{"name":"stdout","text":"```json\n{\n\"size\": \"large\",\n\"type\": \"normal\",\n\"ingredients\": [\"cheese\", \"pineapple\"]\n}\n``` \n\n","output_type":"stream"}],"execution_count":18},{"cell_type":"markdown","source":"#### JSON mode\n\nTo provide control over the schema, and to ensure that you only receive JSON (with no other text or markdown), you can use the Gemini API's [JSON mode](https://github.com/google-gemini/cookbook/blob/main/quickstarts/JSON_mode.ipynb). This forces the model to constrain decoding, such that token selection is guided by the supplied schema.","metadata":{"id":"021293096f08"}},{"cell_type":"code","source":"import typing_extensions as typing\n\nclass PizzaOrder(typing.TypedDict):\n size: str\n ingredients: list[str]\n type: str\n\n\nmodel = genai.GenerativeModel(\n 'gemini-1.5-flash-latest',\n generation_config=genai.GenerationConfig(\n temperature=0.1,\n response_mime_type=\"application/json\",\n response_schema=PizzaOrder,\n ))\n\nresponse = model.generate_content(\"Can I have a large dessert pizza with apple and chocolate\")\nprint(response.text)","metadata":{"id":"50fbf0260912","trusted":true,"execution":{"iopub.status.busy":"2024-11-12T15:12:36.398223Z","iopub.execute_input":"2024-11-12T15:12:36.398699Z","iopub.status.idle":"2024-11-12T15:12:36.945179Z","shell.execute_reply.started":"2024-11-12T15:12:36.398656Z","shell.execute_reply":"2024-11-12T15:12:36.944142Z"}},"outputs":[{"name":"stdout","text":"{\"ingredients\": [\"apple\", \"chocolate\"], \"size\": \"large\", \"type\": \"dessert\"}\n\n","output_type":"stream"}],"execution_count":19},{"cell_type":"markdown","source":"### Chain of Thought (CoT)\n\nDirect prompting on LLMs can return answers quickly and (in terms of output token usage) efficiently, but they can be prone to hallucination. The answer may \"look\" correct (in terms of language and syntax) but is incorrect in terms of factuality and reasoning.\n\nChain-of-Thought prompting is a technique where you instruct the model to output intermediate reasoning steps, and it typically gets better results, especially when combined with few-shot examples. It is worth noting that this technique doesn't completely eliminate hallucinations, and that it tends to cost more to run, due to the increased token count.\n\nAs models like the Gemini family are trained to be \"chatty\" and provide reasoning steps, you can ask the model to be more direct in the prompt.","metadata":{"id":"4a93e338e57c"}},{"cell_type":"code","source":"prompt = \"\"\"When I was 4 years old, my partner was 3 times my age. Now, I\nam 20 years old. How old is my partner? Return the answer immediately.\"\"\"\n\nmodel = genai.GenerativeModel('gemini-1.5-flash-latest')\nresponse = model.generate_content(prompt)\n\nprint(response.text)","metadata":{"id":"5715555db1c1","trusted":true,"execution":{"iopub.status.busy":"2024-11-12T15:13:02.932861Z","iopub.execute_input":"2024-11-12T15:13:02.933631Z","iopub.status.idle":"2024-11-12T15:13:03.442045Z","shell.execute_reply.started":"2024-11-12T15:13:02.933585Z","shell.execute_reply":"2024-11-12T15:13:03.440799Z"}},"outputs":[{"name":"stdout","text":"33 \n\n","output_type":"stream"}],"execution_count":20},{"cell_type":"markdown","source":"Now try the same approach, but indicate to the model that it should \"think step by step\".","metadata":{"id":"e12b19677bfd"}},{"cell_type":"code","source":"prompt = \"\"\"When I was 4 years old, my partner was 3 times my age. Now,\nI am 20 years old. How old is my partner? Let's think step by step.\"\"\"\n\nresponse = model.generate_content(prompt)\nprint(response.text)","metadata":{"id":"ffd7536a481f","trusted":true,"execution":{"iopub.status.busy":"2024-11-12T15:13:13.673598Z","iopub.execute_input":"2024-11-12T15:13:13.674036Z","iopub.status.idle":"2024-11-12T15:13:14.459615Z","shell.execute_reply.started":"2024-11-12T15:13:13.673991Z","shell.execute_reply":"2024-11-12T15:13:14.458369Z"}},"outputs":[{"name":"stdout","text":"Here's how to solve this:\n\n* **When you were 4:** Your partner was 3 times your age, meaning they were 4 * 3 = 12 years old.\n* **Age difference:** Your partner is 12 - 4 = 8 years older than you.\n* **Current age:** Since you are now 20, your partner is 20 + 8 = **28 years old**. \n\n","output_type":"stream"}],"execution_count":21},{"cell_type":"markdown","source":"### ReAct: Reason and act\n\nIn this example you will run a ReAct prompt directly in the Gemini API and perform the searching steps yourself. As this prompt follows a well-defined structure, there are frameworks available that wrap the prompt into easier-to-use APIs that make tool calls automatically, such as the LangChain example from the chapter.\n\nTo try this out with the Wikipedia search engine, check out the [Searching Wikipedia with ReAct](https://github.com/google-gemini/cookbook/blob/main/examples/Search_Wikipedia_using_ReAct.ipynb) cookbook example.\n\n\n> Note: The prompt and in-context examples used here are from [https://github.com/ysymyth/ReAct](https://github.com/ysymyth/ReAct) which is published under a [MIT license](https://opensource.org/licenses/MIT), Copyright (c) 2023 Shunyu Yao.\n\n<table align=left>\n <td>\n <a target=\"_blank\" href=\"https://aistudio.google.com/prompts/18oo63Lwosd-bQ6Ay51uGogB3Wk3H8XMO\"><img src=\"https://ai.google.dev/site-assets/images/marketing/home/icon-ais.png\" style=\"height: 24px\" height=24/> Open in AI Studio</a>\n </td>\n</table>\n","metadata":{"id":"oiLgBQJj0V53"}},{"cell_type":"code","source":"model_instructions = \"\"\"\nSolve a question answering task with interleaving Thought, Action, Observation steps. Thought can reason about the current situation,\nObservation is understanding relevant information from an Action's output and Action can be one of three types:\n (1) <search>entity</search>, which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it\n will return some similar entities to search and you can try to search the information from those topics.\n (2) <lookup>keyword</lookup>, which returns the next sentence containing keyword in the current context. This only does exact matches,\n so keep your searches short.\n (3) <finish>answer</finish>, which returns the answer and finishes the task.\n\"\"\"\n\nexample1 = \"\"\"Question\nMusician and satirist Allie Goertz wrote a song about the \"The Simpsons\" character Milhouse, who Matt Groening named after who?\n\nThought 1\nThe question simplifies to \"The Simpsons\" character Milhouse is named after who. I only need to search Milhouse and find who it is named after.\n\nAction 1\n<search>Milhouse</search>\n\nObservation 1\nMilhouse Mussolini Van Houten is a recurring character in the Fox animated television series The Simpsons voiced by Pamela Hayden and created by Matt Groening.\n\nThought 2\nThe paragraph does not tell who Milhouse is named after, maybe I can look up \"named after\".\n\nAction 2\n<lookup>named after</lookup>\n\nObservation 2\nMilhouse was named after U.S. president Richard Nixon, whose middle name was Milhous.\n\nThought 3\nMilhouse was named after U.S. president Richard Nixon, so the answer is Richard Nixon.\n\nAction 3\n<finish>Richard Nixon</finish>\n\"\"\"\n\nexample2 = \"\"\"Question\nWhat is the elevation range for the area that the eastern sector of the Colorado orogeny extends into?\n\nThought 1\nI need to search Colorado orogeny, find the area that the eastern sector of the Colorado orogeny extends into, then find the elevation range of the area.\n\nAction 1\n<search>Colorado orogeny</search>\n\nObservation 1\nThe Colorado orogeny was an episode of mountain building (an orogeny) in Colorado and surrounding areas.\n\nThought 2\nIt does not mention the eastern sector. So I need to look up eastern sector.\n\nAction 2\n<lookup>eastern sector</lookup>\n\nObservation 2\nThe eastern sector extends into the High Plains and is called the Central Plains orogeny.\n\nThought 3\nThe eastern sector of Colorado orogeny extends into the High Plains. So I need to search High Plains and find its elevation range.\n\nAction 3\n<search>High Plains</search>\n\nObservation 3\nHigh Plains refers to one of two distinct land regions\n\nThought 4\nI need to instead search High Plains (United States).\n\nAction 4\n<search>High Plains (United States)</search>\n\nObservation 4\nThe High Plains are a subregion of the Great Plains. From east to west, the High Plains rise in elevation from around 1,800 to 7,000 ft (550 to 2,130m).\n\nThought 5\nHigh Plains rise in elevation from around 1,800 to 7,000 ft, so the answer is 1,800 to 7,000 ft.\n\nAction 5\n<finish>1,800 to 7,000 ft</finish>\n\"\"\"\n\n# Come up with more examples yourself, or take a look through https://github.com/ysymyth/ReAct/","metadata":{"id":"cBgyNJ5z0VSs","trusted":true,"execution":{"iopub.status.busy":"2024-11-12T15:14:55.791355Z","iopub.execute_input":"2024-11-12T15:14:55.792352Z","iopub.status.idle":"2024-11-12T15:14:55.802880Z","shell.execute_reply.started":"2024-11-12T15:14:55.792297Z","shell.execute_reply":"2024-11-12T15:14:55.801224Z"}},"outputs":[],"execution_count":22},{"cell_type":"markdown","source":"To capture a single step at a time, while ignoring any hallucinated Observation steps, you will use `stop_sequences` to end the generation process. The steps are `Thought`, `Action`, `Observation`, in that order.","metadata":{"id":"C3wbfstjTgey"}},{"cell_type":"code","source":"question = \"\"\"Question\nWho was the youngest author listed on the transformers NLP paper?\n\"\"\"\n\nmodel = genai.GenerativeModel('gemini-1.5-flash-latest')\nreact_chat = model.start_chat()\n\n# You will perform the Action, so generate up to, but not including, the Observation.\nconfig = genai.GenerationConfig(stop_sequences=[\"\\nObservation\"])\n\nresp = react_chat.send_message(\n [model_instructions, example1, example2, question],\n generation_config=config)\nprint(resp.text)","metadata":{"id":"8mxrXRkRTdXm","trusted":true,"execution":{"iopub.status.busy":"2024-11-12T15:15:42.328618Z","iopub.execute_input":"2024-11-12T15:15:42.329063Z","iopub.status.idle":"2024-11-12T15:15:45.688179Z","shell.execute_reply.started":"2024-11-12T15:15:42.329016Z","shell.execute_reply":"2024-11-12T15:15:45.687007Z"}},"outputs":[{"name":"stdout","text":"Thought 1\nI need to find the Transformers paper and locate the authors list to find the youngest author. \n\nAction 1\n<search>Transformers NLP paper</search>\n\n","output_type":"stream"}],"execution_count":23},{"cell_type":"markdown","source":"Now you can perform this research yourself and supply it back to the model.","metadata":{"id":"aW2PIdLbVv3l"}},{"cell_type":"code","source":"observation = \"\"\"Observation 1\n[1706.03762] Attention Is All You Need\nAshish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, Illia Polosukhin\nWe propose a new simple network architecture, the Transformer, based solely on attention mechanisms, dispensing with recurrence and convolutions entirely.\n\"\"\"\nresp = react_chat.send_message(observation, generation_config=config)\nprint(resp.text)","metadata":{"id":"mLMc0DZaV9g2","trusted":true,"execution":{"iopub.status.busy":"2024-11-12T15:15:59.561319Z","iopub.execute_input":"2024-11-12T15:15:59.562268Z","iopub.status.idle":"2024-11-12T15:16:00.308877Z","shell.execute_reply.started":"2024-11-12T15:15:59.562217Z","shell.execute_reply":"2024-11-12T15:16:00.307695Z"}},"outputs":[{"name":"stdout","text":"Thought 2\nThe observation provides the authors list, but it doesn't tell which author is the youngest. I can't search for youngest here. I need to find individual author information. \n\nAction 2\n<search>Ashish Vaswani</search> \n\n","output_type":"stream"}],"execution_count":24},{"cell_type":"markdown","source":"This process repeats until the `<finish>` action is reached. You can continue running this yourself if you like, or try the [Wikipedia example](https://github.com/google-gemini/cookbook/blob/main/examples/Search_Wikipedia_using_ReAct.ipynb) to see a fully automated ReAct system at work.","metadata":{"id":"bo0tzf4nX6dA"}},{"cell_type":"markdown","source":"## Code prompting","metadata":{"id":"jPiZ_eIIaVPt"}},{"cell_type":"markdown","source":"### Generating code\n\nThe Gemini family of models can be used to generate code, configuration and scripts. Generating code can be helpful when learning to code, learning a new language or for rapidly generating a first draft.\n\nIt's important to be aware that since LLMs can't reason, and can repeat training data, it's essential to read and test your code first, and comply with any relevant licenses.\n\n<table align=left>\n <td>\n <a target=\"_blank\" href=\"https://aistudio.google.com/prompts/1YX71JGtzDjXQkgdes8bP6i3oH5lCRKxv\"><img src=\"https://ai.google.dev/site-assets/images/marketing/home/icon-ais.png\" style=\"height: 24px\" height=24/> Open in AI Studio</a>\n </td>\n</table>","metadata":{"id":"ZinKamwXeR6C"}},{"cell_type":"code","source":"model = genai.GenerativeModel(\n 'gemini-1.5-flash-latest',\n generation_config=genai.GenerationConfig(\n temperature=1,\n top_p=1,\n max_output_tokens=1024,\n ))\n\n# Gemini 1.5 models are very chatty, so it helps to specify they stick to the code.\ncode_prompt = \"\"\"\nWrite a Python function to calculate the factorial of a number. No explanation, provide only the code.\n\"\"\"\n\nresponse = model.generate_content(code_prompt)\nMarkdown(response.text)","metadata":{"id":"fOQP9pqmeUO1","trusted":true,"execution":{"iopub.status.busy":"2024-11-12T15:16:14.747048Z","iopub.execute_input":"2024-11-12T15:16:14.747513Z","iopub.status.idle":"2024-11-12T15:16:15.301669Z","shell.execute_reply.started":"2024-11-12T15:16:14.747468Z","shell.execute_reply":"2024-11-12T15:16:15.300491Z"}},"outputs":[{"execution_count":25,"output_type":"execute_result","data":{"text/plain":"<IPython.core.display.Markdown object>","text/markdown":"```python\ndef factorial(n):\n if n == 0:\n return 1\n else:\n return n * factorial(n-1)\n```"},"metadata":{}}],"execution_count":25},{"cell_type":"markdown","source":"### Code execution\n\nThe Gemini API can automatically run generated code too, and will return the output.\n\n<table align=left>\n <td>\n <a target=\"_blank\" href=\"https://aistudio.google.com/prompts/11veFr_VYEwBWcLkhNLr-maCG0G8sS_7Z\"><img src=\"https://ai.google.dev/site-assets/images/marketing/home/icon-ais.png\" style=\"height: 24px\" height=24/> Open in AI Studio</a>\n </td>\n</table>","metadata":{"id":"wlBMWSFhgVRQ"}},{"cell_type":"code","source":"model = genai.GenerativeModel(\n 'gemini-1.5-flash-latest',\n tools='code_execution')\n\ncode_exec_prompt = \"\"\"\nCalculate the sum of the first 14 prime numbers. Only consider the odd primes, and make sure you get them all.\n\"\"\"\n\nresponse = model.generate_content(code_exec_prompt)\nMarkdown(response.text)","metadata":{"id":"jT3OfWYfhjRL","trusted":true,"execution":{"iopub.status.busy":"2024-11-12T15:16:24.675693Z","iopub.execute_input":"2024-11-12T15:16:24.676177Z","iopub.status.idle":"2024-11-12T15:16:30.119954Z","shell.execute_reply.started":"2024-11-12T15:16:24.676130Z","shell.execute_reply":"2024-11-12T15:16:30.118810Z"}},"outputs":[{"execution_count":26,"output_type":"execute_result","data":{"text/plain":"<IPython.core.display.Markdown object>","text/markdown":"\n``` python\nimport sympy\n\nprimes = list(sympy.primerange(0, 50))\nprimes = [prime for prime in primes if prime % 2 != 0]\nprimes = primes[:14]\nprint(f'{sum(primes)=}')\n\n```\n```\nsum(primes)=326\n\n```\nThe sum of the first 14 odd prime numbers is 326. \n\nHere's how I arrived at the answer:\n\n1. **Generate Prime Numbers:** I used the `sympy.primerange` function to generate a list of all prime numbers between 0 and 50.\n2. **Filter for Odd Primes:** I then filtered the list to include only the odd primes. This is because the question specifies only odd primes.\n3. **Select First 14:** The question asks for the sum of the first 14 odd primes, so I took the first 14 elements of the filtered list.\n4. **Calculate the Sum:** Finally, I used the built-in `sum` function to calculate the sum of the first 14 odd primes.\n\nTherefore, the answer is 326. \n"},"metadata":{}}],"execution_count":26},{"cell_type":"markdown","source":"While this looks like a single-part response, you can inspect the response to see the each of the steps: initial text, code generation, execution results, and final text summary.","metadata":{"id":"ZspT1GSkjG6d"}},{"cell_type":"code","source":"for part in response.candidates[0].content.parts:\n print(part)\n print(\"-----\")","metadata":{"id":"j4gQVzcRjRX-","trusted":true,"execution":{"iopub.status.busy":"2024-11-12T15:16:43.168065Z","iopub.execute_input":"2024-11-12T15:16:43.168565Z","iopub.status.idle":"2024-11-12T15:16:43.175481Z","shell.execute_reply.started":"2024-11-12T15:16:43.168520Z","shell.execute_reply":"2024-11-12T15:16:43.174053Z"}},"outputs":[{"name":"stdout","text":"text: \"\"\n\n-----\nexecutable_code {\n language: PYTHON\n code: \"\\nimport sympy\\n\\nprimes = list(sympy.primerange(0, 50))\\nprimes = [prime for prime in primes if prime % 2 != 0]\\nprimes = primes[:14]\\nprint(f\\'{sum(primes)=}\\')\\n\"\n}\n\n-----\ncode_execution_result {\n outcome: OUTCOME_OK\n output: \"sum(primes)=326\\n\"\n}\n\n-----\ntext: \"The sum of the first 14 odd prime numbers is 326. \\n\\nHere\\'s how I arrived at the answer:\\n\\n1. **Generate Prime Numbers:** I used the `sympy.primerange` function to generate a list of all prime numbers between 0 and 50.\\n2. **Filter for Odd Primes:** I then filtered the list to include only the odd primes. This is because the question specifies only odd primes.\\n3. **Select First 14:** The question asks for the sum of the first 14 odd primes, so I took the first 14 elements of the filtered list.\\n4. **Calculate the Sum:** Finally, I used the built-in `sum` function to calculate the sum of the first 14 odd primes.\\n\\nTherefore, the answer is 326. \\n\"\n\n-----\n","output_type":"stream"}],"execution_count":27},{"cell_type":"markdown","source":"### Explaining code\n\nThe Gemini family of models can explain code to you too.\n\n<table align=left>\n <td>\n <a target=\"_blank\" href=\"https://aistudio.google.com/prompts/1N7LGzWzCYieyOf_7bAG4plrmkpDNmUyb\"><img src=\"https://ai.google.dev/site-assets/images/marketing/home/icon-ais.png\" style=\"height: 24px\" height=24/> Open in AI Studio</a>\n </td>\n</table>","metadata":{"id":"1gUX8QzCj4d5"}},{"cell_type":"code","source":"file_contents = !curl https://raw.githubusercontent.com/magicmonty/bash-git-prompt/refs/heads/master/gitprompt.sh\n\nexplain_prompt = f\"\"\"\nPlease explain what this file does at a very high level. What is it, and why would I use it?\n\n```\n{file_contents}\n```\n\"\"\"\n\nmodel = genai.GenerativeModel('gemini-1.5-flash-latest')\n\nresponse = model.generate_content(explain_prompt)\nMarkdown(response.text)","metadata":{"id":"7_jPMMoxkIEb","trusted":true,"execution":{"iopub.status.busy":"2024-11-12T15:16:49.481363Z","iopub.execute_input":"2024-11-12T15:16:49.481820Z","iopub.status.idle":"2024-11-12T15:16:52.728237Z","shell.execute_reply.started":"2024-11-12T15:16:49.481777Z","shell.execute_reply":"2024-11-12T15:16:52.726940Z"}},"outputs":[{"execution_count":28,"output_type":"execute_result","data":{"text/plain":"<IPython.core.display.Markdown object>","text/markdown":"This file is a Bash/Zsh script that provides a customizable prompt for your terminal that displays information about your current Git repository. It's designed to be user-friendly and highly configurable. \n\nHere's why you'd use it:\n\n* **Enhanced Git Awareness:** The prompt displays the current branch, status (clean, staged, modified, etc.), upstream status (ahead/behind), and even the username/repository name.\n* **Visual Clarity:** By providing visual cues within your prompt, you can quickly grasp the state of your Git repository without needing to run separate Git commands.\n* **Customizability:** The script allows you to customize the colors, symbols, format, and even the content displayed in your prompt. \n* **Integration with Other Tools:** The script integrates with other commonly used tools like virtual environments (virtualenv, conda, node virtualenv) and can provide visual clues for these as well. \n\n**Essentially, this script transforms your basic terminal prompt into a more informative and aesthetically pleasing one, specifically tailored to Git users.** \n\n**How to Use It:**\n\n1. **Save the script:** Save the code provided as a file, for example, `bash-git-prompt.sh`.\n2. **Make it executable:** Use `chmod +x bash-git-prompt.sh`.\n3. **Source the script:** Add the following line to your `.bashrc` or `.zshrc` file, depending on your shell: `source /path/to/bash-git-prompt.sh` (replace `/path/to/bash-git-prompt.sh` with the actual location).\n4. **Restart your terminal:** Open a new terminal or source your `.bashrc` or `.zshrc` file for the changes to take effect.\n\nYou'll now have a Git-aware prompt in your terminal! You can further customize the script by exploring the numerous configuration options it provides.\n"},"metadata":{}}],"execution_count":28},{"cell_type":"markdown","source":"## Learn more\n\nTo learn more about prompting in depth:\n\n* Check out the whitepaper issued with today's content,\n* Try out the apps listed at the top of this notebook ([TextFX](https://textfx.withgoogle.com/), [SQL Talk](https://sql-talk-r5gdynozbq-uc.a.run.app/) and [NotebookLM](https://notebooklm.google/)),\n* Read the [Introduction to Prompting](https://ai.google.dev/gemini-api/docs/prompting-intro) from the Gemini API docs,\n* Explore the Gemini API's [prompt gallery](https://ai.google.dev/gemini-api/prompts) and try them out in AI Studio,\n* Check out the Gemini API cookbook for [inspirational examples](https://github.com/google-gemini/cookbook/blob/main/examples/) and [educational quickstarts](https://github.com/google-gemini/cookbook/blob/main/quickstarts/).\n\nAnd please share anything exciting you have tried in the Discord!","metadata":{"id":"2a8266d97ce5"}}]}