Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Point gemini-1.5-flash-latest as default model for all quickstart notebooks #173

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 3 additions & 39 deletions quickstarts/Audio.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -161,35 +161,10 @@
"metadata": {
"id": "YmISEsqpafRb"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"## Summary of President John F. Kennedy's 1961 State of the Union Address:\n",
"\n",
"**Main Theme:** The address focuses on the challenges and opportunities facing the United States both domestically and internationally, emphasizing the need for unity and action in the face of the Cold War and economic difficulties.\n",
"\n",
"**Key Points:**\n",
"\n",
"* **Economic Concerns:** Kennedy highlights the country's economic troubles, including a recession, high unemployment, and falling farm income. He proposes measures to address these issues, such as increased unemployment compensation, minimum wage increases, and tax incentives for investment.\n",
"* **Balance of Payments Deficit:** Kennedy acknowledges the growing deficit but assures the nation that the dollar remains strong and pledges not to devalue it. He outlines steps to attract foreign investment, promote exports, and curb spending abroad.\n",
"* **Unfinished Domestic Tasks:** Kennedy addresses several domestic issues needing attention, including urban decay, education, healthcare, and juvenile crime. He proposes programs for housing, education funding, and healthcare for the elderly.\n",
"* **Foreign Policy and the Cold War:** Kennedy outlines the global challenges posed by the Cold War and the threat of communist expansion, particularly in Asia, Africa, and Latin America. He emphasizes the need to strengthen military capabilities and alliances while seeking peaceful competition with the Soviet Union and China. \n",
"* **Alliance for Progress:** Kennedy proposes a new program to assist the economic and social development of Latin American countries, aiming for a \"free and prosperous Latin America.\"\n",
"* **National Peace Corps:** Kennedy advocates for the creation of a National Peace Corps to utilize the skills of dedicated citizens to assist developing nations.\n",
"* **Focus on Science and Diplomacy:** Kennedy calls for increased emphasis on science and diplomacy, proposing collaborations with other nations, including the Soviet Union, on projects like weather prediction, communication satellites, and space exploration.\n",
"* **Strengthening the United Nations:** Kennedy emphasizes the importance of supporting and strengthening the United Nations as an instrument for peace and international cooperation.\n",
"* **Call to Action:** Kennedy concludes by urging unity, dedication, and perseverance from all citizens to overcome the challenges facing the nation. He emphasizes the responsibility of the United States to lead the fight for freedom and world order. \n",
"\n",
"**Overall Tone:** The address conveys a sense of urgency and determination while remaining optimistic about the nation's ability to overcome its challenges. Kennedy's call to action emphasizes shared responsibility and the need for collective effort in facing both domestic and international difficulties. \n",
"\n"
]
}
],
"outputs": [],
"source": [
"prompt = \"Listen carefully to the following audio file. Provide a brief summary.\"\n",
"model = genai.GenerativeModel('models/gemini-1.5-pro-latest')\n",
"model = genai.GenerativeModel('models/gemini-1.5-flash-latest')\n",
"response = model.generate_content([prompt, your_file])\n",
"print(response.text)"
]
Expand All @@ -211,18 +186,7 @@
"metadata": {
"id": "O0xk2-6CWLfC"
},
"outputs": [
{
"data": {
"text/plain": [
"total_tokens: 78330"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"model.count_tokens([your_file])"
]
Expand Down
10 changes: 5 additions & 5 deletions quickstarts/Authentication.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@
"\n",
"Remember to treat your API key like a password. Do not accidentally save it in a notebook or source file you later commit to GitHub. This notebook shows you two ways you can securely store your API key.\n",
"\n",
"* If you are using Google Colab, we recommend you store your key in Colab Secrets.\n",
"* If you are using Google Colab, it is recommended to store your key in Colab Secrets.\n",
"\n",
"* If you are using a different development environment (or calling the Gemini API through `cURL` in your terminal), we recommend you store your key in an environment variable.\n",
"* If you are using a different development environment (or calling the Gemini API through `cURL` in your terminal), it is recommended to store your key in an environment variable.\n",
"\n",
"Let's start with Colab Secrets."
]
Expand Down Expand Up @@ -163,7 +163,7 @@
},
"outputs": [],
"source": [
"model = genai.GenerativeModel('gemini-1.0-pro')\n",
"model = genai.GenerativeModel('models/gemini-1.5-flash-latest')\n",
"response = model.generate_content(\"Please give me python code to sort a list.\")\n",
"print(response.text)"
]
Expand All @@ -183,7 +183,7 @@
"id": "gZDX51Y27pN4"
},
"source": [
"If you are using a different development environment (or calling the Gemini API through `cURL` in your terminal), we recommend you store your key in an environment variable.\n",
"If you are using a different development environment (or calling the Gemini API through `cURL` in your terminal), it is recommended to store your key in an environment variable.\n",
"\n",
"To store your key in an environment variable, open your terminal and run:\n",
"\n",
Expand Down Expand Up @@ -217,7 +217,7 @@
"source": [
"## Learning more\n",
"\n",
"The Gemini API uses API keys for most types of authentication, and that’s all you need to get started. We use OAuth for more advanced authentication when tuning models. You can learn more about that in the [OAuth quickstart](https://github.com/google-gemini/cookbook/blob/main/quickstarts/Authentication_with_OAuth.ipynb)."
"The Gemini API uses API keys for most types of authentication, and that’s all you need to get started. You can use OAuth for more advanced authentication when tuning models. You can learn more about that in the [OAuth quickstart](https://github.com/google-gemini/cookbook/blob/main/quickstarts/Authentication_with_OAuth.ipynb)."
]
}
],
Expand Down
4 changes: 1 addition & 3 deletions quickstarts/Authentication_with_OAuth.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[?25l \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m0.0/137.4 kB\u001b[0m \u001b[31m?\u001b[0m eta \u001b[36m-:--:--\u001b[0m\r",
"\u001b[2K \u001b[91m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[91m╸\u001b[0m\u001b[90m━\u001b[0m \u001b[32m133.1/137.4 kB\u001b[0m \u001b[31m3.8 MB/s\u001b[0m eta \u001b[36m0:00:01\u001b[0m\r",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m137.4/137.4 kB\u001b[0m \u001b[31m2.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m137.4/137.4 kB\u001b[0m \u001b[31m2.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n",
"\u001b[?25h"
]
}
Expand Down
326 changes: 50 additions & 276 deletions quickstarts/Counting_Tokens.ipynb

Large diffs are not rendered by default.

142 changes: 13 additions & 129 deletions quickstarts/File_API.ipynb

Large diffs are not rendered by default.

141 changes: 12 additions & 129 deletions quickstarts/Function_calling.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -137,23 +137,7 @@
"metadata": {
"id": "42b27b02d2f5"
},
"outputs": [
{
"data": {
"text/plain": [
"genai.GenerativeModel(\n",
" model_name='models/gemini-1.0-pro',\n",
" generation_config={},\n",
" safety_settings={},\n",
" tools=<google.generativeai.types.content_types.FunctionLibrary object at 0x7a99071b61d0>,\n",
")"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"def add(a: float, b: float):\n",
" \"\"\"returns a + b.\"\"\"\n",
Expand All @@ -176,7 +160,7 @@
"\n",
"\n",
"model = genai.GenerativeModel(\n",
" model_name=\"gemini-1.0-pro\", tools=[add, subtract, multiply, divide]\n",
" model_name=\"gemini-1.5-flash-latest\", tools=[add, subtract, multiply, divide]\n",
")\n",
"\n",
"model"
Expand Down Expand Up @@ -228,18 +212,7 @@
"metadata": {
"id": "81d8def3d865"
},
"outputs": [
{
"data": {
"text/plain": [
"'There are 2508 mittens in total.'"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"response = chat.send_message(\n",
" \"I have 57 cats, each owns 44 mittens, how many mittens is that in total?\"\n",
Expand All @@ -253,18 +226,7 @@
"metadata": {
"id": "951c0f83f72e"
},
"outputs": [
{
"data": {
"text/plain": [
"2508"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"57 * 44"
]
Expand Down Expand Up @@ -299,22 +261,7 @@
"metadata": {
"id": "9f7eff1e8e60"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"user -> [{'text': 'I have 57 cats, each owns 44 mittens, how many mittens is that in total?'}]\n",
"--------------------------------------------------------------------------------\n",
"model -> [{'function_call': {'name': 'multiply', 'args': {'a': 57.0, 'b': 44.0}}}]\n",
"--------------------------------------------------------------------------------\n",
"user -> [{'function_response': {'name': 'multiply', 'response': {'result': 2508.0}}}]\n",
"--------------------------------------------------------------------------------\n",
"model -> [{'text': 'There are 2508 mittens in total.'}]\n",
"--------------------------------------------------------------------------------\n"
]
}
],
"outputs": [],
"source": [
"for content in chat.history:\n",
" print(content.role, \"->\", [type(part).to_dict(part) for part in content.parts])\n",
Expand Down Expand Up @@ -428,7 +375,7 @@
" \"get_showtimes\": get_showtimes,\n",
"}\n",
"\n",
"model = genai.GenerativeModel(model_name=\"gemini-1.0-pro\", tools=functions.values())"
"model = genai.GenerativeModel(model_name=\"gemini-1.5-flash-latest\", tools=functions.values())"
]
},
{
Expand All @@ -446,35 +393,7 @@
"metadata": {
"id": "5e3b9c84d883"
},
"outputs": [
{
"data": {
"text/plain": [
"[function_call {\n",
" name: \"find_theaters\"\n",
" args {\n",
" fields {\n",
" key: \"location\"\n",
" value {\n",
" string_value: \"Mountain View, CA\"\n",
" }\n",
" }\n",
" fields {\n",
" key: \"movie\"\n",
" value {\n",
" string_value: \"Barbie\"\n",
" }\n",
" }\n",
" }\n",
"}\n",
"]"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"response = model.generate_content(\n",
" \"Which theaters in Mountain View show the Barbie movie?\"\n",
Expand Down Expand Up @@ -507,15 +426,7 @@
"metadata": {
"id": "rjkZ8MA00Coc"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['Googleplex 16', 'Android Theatre']\n"
]
}
],
"outputs": [],
"source": [
"def call_function(function_call, functions):\n",
" function_name = function_call.name\n",
Expand Down Expand Up @@ -548,15 +459,7 @@
"metadata": {
"id": "gdb62GstAD_3"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Theaters showing Barbie in Mountain View, CA are: Googleplex 16, Android Theatre\n"
]
}
],
"outputs": [],
"source": [
"import google.ai.generativelanguage as glm\n",
"from google.protobuf.struct_pb2 import Struct\n",
Expand Down Expand Up @@ -653,22 +556,12 @@
"metadata": {
"id": "21ecYHLgIsCl"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"power_disco_ball(power=True)\n",
"start_music(energetic=True, loud=True, bpm=120.0)\n",
"dim_lights(brightness=0.3)\n"
]
}
],
"outputs": [],
"source": [
"# Set the model up with tools.\n",
"house_fns = [power_disco_ball, start_music, dim_lights]\n",
"# Try this out with Pro and Flash...\n",
"model = genai.GenerativeModel(model_name=\"gemini-1.5-pro-latest\", tools=house_fns)\n",
"model = genai.GenerativeModel(model_name=\"gemini-1.5-flash-latest\", tools=house_fns)\n",
"\n",
"# Call the API.\n",
"chat = model.start_chat()\n",
Expand Down Expand Up @@ -696,17 +589,7 @@
"metadata": {
"id": "L7RxoiR3foBR"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Let's get this party started! I've turned on the disco ball, started playing some upbeat music, and dimmed the lights. 🎶✨ Get ready to dance! 🕺💃 \n",
"\n",
"\n"
]
}
],
"outputs": [],
"source": [
"import google.ai.generativelanguage as glm\n",
"\n",
Expand Down
Loading
Loading