Skip to content

Commit

Permalink
Point gemini-1.5-flash-latest as default model for all quickstart not…
Browse files Browse the repository at this point in the history
…ebooks (google-gemini#180)

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

* Addressing review feedbacks for quickstart notebooks

* Addressing review feedbacks for quickstart notebooks

* removing contrib.md file from quickstarts folder
  • Loading branch information
lucianommartins authored Jun 4, 2024
1 parent fa6fbf0 commit e594795
Show file tree
Hide file tree
Showing 16 changed files with 1,099 additions and 580 deletions.
35 changes: 9 additions & 26 deletions quickstarts/Audio.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {
"id": "OHvNLws4RRjx"
},
Expand All @@ -126,7 +126,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {
"id": "Cxq31LDwSFH6"
},
Expand All @@ -137,7 +137,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {
"id": "MAObE0BpaAwG"
},
Expand All @@ -157,7 +157,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {
"id": "YmISEsqpafRb"
},
Expand All @@ -166,30 +166,13 @@
"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"
"President John F. Kennedy delivers his State of the Union address to the United States Congress on January 30th, 1961. He addresses issues concerning the nation's economy, foreign policy, and the state of the executive branch. The President acknowledges the nation's economic struggles, including high unemployment and a failing agricultural market, but he remains optimistic. He emphasizes the importance of maintaining a strong military, working with allies, and bolstering the United Nations. He suggests expanding a \"Food for Peace\" program to help alleviate hunger and malnutrition, and he urges collaboration with the Soviet Union on scientific endeavors. The President concludes his speech by acknowledging the challenges ahead and urging Americans to work together to overcome them. \n"
]
}
],
"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')\n",
"response = model.generate_content([prompt, your_file])\n",
"print(response.text)"
]
Expand All @@ -207,18 +190,18 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {
"id": "O0xk2-6CWLfC"
},
"outputs": [
{
"data": {
"text/plain": [
"total_tokens: 78330"
"total_tokens: 83552"
]
},
"execution_count": 9,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
Expand Down
80 changes: 73 additions & 7 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 @@ -157,13 +157,79 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {
"id": "n6sXnWrJoKoo"
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"```python\n",
"def sort_list(list_to_sort):\n",
" \"\"\"\n",
" Sorts a list using the built-in sort method.\n",
"\n",
" Args:\n",
" list_to_sort: The list to be sorted.\n",
"\n",
" Returns:\n",
" The sorted list.\n",
" \"\"\"\n",
"\n",
" list_to_sort.sort()\n",
" return list_to_sort\n",
"\n",
"# Example usage:\n",
"my_list = [5, 2, 8, 1, 9]\n",
"\n",
"sorted_list = sort_list(my_list)\n",
"\n",
"print(f\"Original list: {my_list}\")\n",
"print(f\"Sorted list: {sorted_list}\")\n",
"```\n",
"\n",
"**Explanation:**\n",
"\n",
"* **`sort_list(list_to_sort)` function:**\n",
" * Takes a list as input (`list_to_sort`).\n",
" * Uses the built-in `sort()` method to sort the list in ascending order.\n",
" * Returns the sorted list.\n",
"\n",
"* **Example usage:**\n",
" * Creates a sample list `my_list`.\n",
" * Calls `sort_list()` to sort the list and store the result in `sorted_list`.\n",
" * Prints both the original and sorted lists.\n",
"\n",
"**Output:**\n",
"\n",
"```\n",
"Original list: [5, 2, 8, 1, 9]\n",
"Sorted list: [1, 2, 5, 8, 9]\n",
"```\n",
"\n",
"**Other sorting methods:**\n",
"\n",
"* **`sorted()` function:** This function creates a new sorted list without modifying the original list.\n",
"\n",
"```python\n",
"sorted_list = sorted(my_list)\n",
"```\n",
"\n",
"* **Custom sorting:** You can use the `sort()` method with a `key` function to specify a custom sorting criteria.\n",
"\n",
"```python\n",
"my_list.sort(key=lambda x: -x) # Sort in descending order\n",
"```\n",
"\n",
"Choose the method that best suits your needs.\n",
"\n"
]
}
],
"source": [
"model = genai.GenerativeModel('gemini-1.0-pro')\n",
"model = genai.GenerativeModel('models/gemini-1.5-flash')\n",
"response = model.generate_content(\"Please give me python code to sort a list.\")\n",
"print(response.text)"
]
Expand All @@ -183,7 +249,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 +283,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
Loading

0 comments on commit e594795

Please sign in to comment.