From c9bc3c62f863deaa4a672e8325e05e996c6cab2d Mon Sep 17 00:00:00 2001 From: Rohan Dwivedi Date: Thu, 5 Mar 2026 16:57:04 +0530 Subject: [PATCH 1/8] added example for gemini api used to extract insights from github --- examples/GitHub_issue_analyzer.ipynb | 336 +++++++++++++++++++++++++++ examples/README.md | 1 + 2 files changed, 337 insertions(+) create mode 100644 examples/GitHub_issue_analyzer.ipynb diff --git a/examples/GitHub_issue_analyzer.ipynb b/examples/GitHub_issue_analyzer.ipynb new file mode 100644 index 000000000..b8e64f0dc --- /dev/null +++ b/examples/GitHub_issue_analyzer.ipynb @@ -0,0 +1,336 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "Tce3stUlHN0L" + }, + "source": [ + "##### Copyright 2026 Google LLC." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "cellView": "form", + "id": "tuOe1ymfHZPu" + }, + "outputs": [], + "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." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "qFdPvlXBOdUN" + }, + "source": [ + "# Gemini API: Name of your guide" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "MfBg1C5NB3X0" + }, + "source": [ + "" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "r6P32iYYV27b" + }, + "source": [ + "_[remove me] Be sure to update the Colab link!_" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "XCVydW40iixa" + }, + "source": [ + "[If you're adding a new example, use this badge to promote yourself (yes sorry you'll have to write your name a lot of times)]\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
\n", + " \n", + " \"Giom-V's\n", + " \n", + " \n", + "

This notebook was contributed by Giom (use either your GitHub handle or your real name, your choice).

\n", + "
Add a link to you blog, or linkedIn, or something else - See Giom other notebooks here.

\n", + " \n", + " Have a cool Gemini example? Feel free to share it too!\n", + "
" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "6b527162" + }, + "source": [ + "[When the model is a preview one an can potentially change or if it's a paid-only feature, add a disclaimer:]\n", + "> **Note:** Image generation is a paid-only feature and won't work if you are on the free tier. Check the [pricing](https://ai.google.dev/pricing#imagen-4) page for more details.\n", + "\n", + "> **Note:** Image-out is a preview feature. It is free to use for now with quota limitations, but is subject to change.\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "xHxb-dlhMIzW" + }, + "source": [ + "[Include a paragraph or two here explaining what this example demonstrates, who should be interested in it, and what you need to know before you get started.]" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "monLpKy7423V" + }, + "source": [ + "## Setup" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "5mi7BrkD44MF" + }, + "source": [ + "### Install SDK" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "AQJjzmYgH3sX" + }, + "outputs": [], + "source": [ + "%pip install -U -q \"google-genai>=1.0.0\" # Install the Python SDK\n", + "\n", + "# Always set at least 1.0.0 as the minimal version as there were breaking\n", + "# changes through the previous versions\n", + "# Of course, if your notebook uses a new feature and needs a more recent\n", + "# version, set the right minimum version to indicate when the feature was\n", + "# introduced.\n", + "# Always test your notebook with that fixed version (eg. '==1.0.0') to make.\n", + "# sure it's really the minimum version.\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "MUXex9ctTuDB" + }, + "source": [ + "### Set up your API key\n", + "\n", + "To run the following cell, your API key must be stored it in a Colab Secret named `GOOGLE_API_KEY`. If you don't already have an API key, or you're not sure how to create a Colab Secret, see the [Authentication ![image](https://storage.googleapis.com/generativeai-downloads/images/colab_icon16.png)](../quickstarts/Authentication.ipynb) quickstart for an example." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "wltbMJLIIXGk" + }, + "outputs": [], + "source": [ + "from google.colab import userdata\n", + "from google import genai\n", + "\n", + "GOOGLE_API_KEY = userdata.get('GOOGLE_API_KEY')\n", + "client = genai.Client(api_key=GOOGLE_API_KEY)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "hL54YG-kMDVF" + }, + "source": [ + "Now select the model you want to use in this guide, either by selecting one in the list or writing it down. Keep in mind that some models, like the 2.5 ones are thinking models and thus take slightly more time to respond (cf. [thinking notebook](./Get_started_thinking.ipynb) for more details and in particular learn how to switch the thiking off)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "Lf6FamchMDsk" + }, + "outputs": [], + "source": [ + "MODEL_ID = \"gemini-3-flash-preview\" # @param [\"gemini-2.5-flash-lite\", \"gemini-2.5-flash\", \"gemini-2.5-pro\", \"gemini-2.5-flash-preview\", \"gemini-3.1-flash-lite-preview\", \"gemini-3.1-pro-preview\"] {\"allow-input\":true, isTemplate: true}\n", + "\n", + "# Ideally order the model by \"cabability\" ie. generation then within generation\n", + "# 8b/flash-lite then flash then pro" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "w5i8tMZKIeUu" + }, + "source": [ + "## [Write your guide]\n", + "\n", + "[Add as many high level sections as needed to step through your guide. Try to introduce new concepts incrementally, including explanatory text at every step. Remember that notebooks need to be executable from start to finish using `Runtime -> Run all` in Colab.]" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "4677dd58e9b5" + }, + "source": [ + "## Next Steps\n", + "### Useful API references:\n", + "\n", + "[Always end with links to the related doumentation]\n", + "\n", + "### Related examples\n", + "\n", + "[If any, add links to the related examples]\n", + "\n", + "### Continue your discovery of the Gemini API\n", + "\n", + "[Finally, link some other quickstarts that are either related or require the same level of expertise]\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "UhNtHfuxCGVy" + }, + "source": [ + "# Resources (don't forget to delete everything starting from here)\n", + "\n", + "* Follow the [Google developer documentation style guide](https://developers.google.com/style/highlights)\n", + "* The [TensorFlow documentation style guide](https://www.tensorflow.org/community/contribute/docs_style) has useful guidance for notebooks.\n", + "* Read the [Cookbook contributor guide](https://github.com/google-gemini/cookbook/blob/main/CONTRIBUTING.md) and the [Cookbook Examples contributor guide](https://github.com/google-gemini/cookbook/blob/main/examples/CONTRIBUTING.md)." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "2V22fKegUtF9" + }, + "source": [ + "## Notebook style (also check the [Contributing guide](Contributing.mg))\n", + "\n", + "* Include the collapsed license at the top (uses the Colab \"Form\" mode to hide the cells).\n", + "* Save the notebook with the table of contents open.\n", + "* Use one `H1` header for the title.\n", + "* Include the button-bar immediately after the `H1`.\n", + "* Include an overview section before any code.\n", + "* Keep your installs and imports close to the code that first uses them. If they are used throughout (such as the SDK), they can go at the start of the guide.\n", + "* Keep code and text cells as brief as possible.\n", + "* Break text cells at headings\n", + "* Break code cells between \"building\" and \"running\", and between \"printing one result\" and \"printing another result\".\n", + "* Necessary but uninteresting code should be hidden in a toggleable code cell by putting `# @title` as the first line.\n", + "* You can optionally add a byline for content in `examples/` that you wrote, including one link to your GitHub, social, or site of your choice." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "QKp40qS-DGEZ" + }, + "source": [ + "### Code style\n", + "\n", + "* Notebooks are for people. Write code optimized for clarity.\n", + "* Keep examples quick and concise.\n", + "* Use the [Google Python Style Guide](http://google.github.io/styleguide/pyguide.html), where applicable. Code formatted by [`pyink`](https://github.com/google/pyink) will always be accepted.\n", + "* In particular, defining functions and variables takes extra spaces around the `=` sign, while function parameters don't:\n", + "```python\n", + " var = value\n", + " function(\n", + " parameter=value\n", + " )\n", + "```\n", + "* If you define a function, run it and show us what it does before using it in another function.\n", + "* Demonstrate small parts before combining them into something more complex.\n", + "* Keep the code as simple as possible, only use extra parameters like temperature when needed, and in that case, explain why\n", + "* To ensure notebook text remains accurate, present model metadata by executing code.\n", + " * For example, instead of saying \"1M token context\" in the text, display the output of `client.models.get(model='...').input_token_limit`.\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "78HBT9cQXJko" + }, + "source": [ + "### Text\n", + "\n", + "* Use an imperative style. \"Run a prompt using the API.\"\n", + "* Use sentence case in titles/headings.\n", + "* Use short titles/headings: \"Download the data\", \"Call the API\", \"Process the results\".\n", + "* Use the [Google developer documentation style guide](https://developers.google.com/style/highlights).\n", + "* Use [second person](https://developers.google.com/style/person): \"you\" rather than \"we\".\n", + "* When using links between notebooks, use relative ones as they'll work better in IDEs and Colab. Use absolute ones to link to folders or markdown files.\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "YrsKXcPRUvK9" + }, + "source": [ + "## GitHub workflow\n", + "\n", + "* Be consistent about how you save your notebooks, otherwise the JSON diffs are messy. [`nbfmt` and `nblint`](https://github.com/tensorflow/docs/blob/master/tools/tensorflow_docs/tools/README.md) help here.\n", + "* This notebook has the \"Omit code cell output when saving this notebook\" option set. GitHub refuses to diff notebooks with large diffs (inline images).\n", + "* [ReviewNB.com](http://reviewnb.com) can help with diffs. This is linked in a comment on a notebook pull request.\n", + "* Use the [Open in Colab](https://chrome.google.com/webstore/detail/open-in-colab/iogfkhleblhcpcekbiedikdehleodpjo) extension to open a GitHub notebook in Colab.\n", + "* The easiest way to edit a notebook in GitHub is to open it with Colab from the branch you want to edit. Then use File --> Save a copy in GitHub, which will save it back to the branch you opened it from.\n", + "* For PRs it's helpful to post a direct Colab link to the PR head: https://colab.research.google.com/github/{USER}/{REPO}/blob/{BRANCH}/{PATH}.ipynb" + ] + } + ], + "metadata": { + "colab": { + "collapsed_sections": [ + "Tce3stUlHN0L" + ], + "name": "GitHub_issue_analyzer.ipynb", + "toc_visible": true + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/examples/README.md b/examples/README.md index c7563eec7..6b845d9fb 100644 --- a/examples/README.md +++ b/examples/README.md @@ -33,6 +33,7 @@ This is a collection of fun and helpful examples for the Gemini API. | [Talk to documents](./Talk_to_documents_with_embeddings.ipynb) | Use embeddings to search through a custom database. | Embeddings | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/examples/Talk_to_documents_with_embeddings.ipynb) | | [Entity extraction](./Entity_Extraction.ipynb) | Use Gemini API to speed up some of your tasks, such as searching through text to extract needed information. Entity extraction with a Gemini model is a simple query, and you can ask it to retrieve its answer in the form that you prefer. | Embeddings | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/examples/Entity_Extraction.ipynb) | | [Google I/O 2025 Live coding session](./Google_IO2025_Live_Coding.ipynb) | Play with the notebook used during the Google I/O 2025 live coding session delivered by the Google DeepMind DevRel team. Work with the Gemini API SDK, know and practice with the GenMedia models, the thinking capable models, start using the Gemini API tools and more! | Gemini API and its models and features | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/examples/Google_IO2025_Live_Coding.ipynb) | +| [GitHub issue analyzer](./GitHub_issue_analyzer.ipynb) | Use Gemini API to interact with Pygithub API and extract useful insights from this repository | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/examples/GitHub_issue_analyzer.ipynb) | ---
From 00c87c3405432440dee3789f6a4f8b2832542072 Mon Sep 17 00:00:00 2001 From: Rohan Dwivedi Date: Thu, 5 Mar 2026 17:02:32 +0530 Subject: [PATCH 2/8] added example for gemini api used to extract insights from github --- examples/GitHub_issue_analyzer.ipynb | 508 +++++++++++++++++++++------ 1 file changed, 403 insertions(+), 105 deletions(-) diff --git a/examples/GitHub_issue_analyzer.ipynb b/examples/GitHub_issue_analyzer.ipynb index b8e64f0dc..74d89f039 100644 --- a/examples/GitHub_issue_analyzer.ipynb +++ b/examples/GitHub_issue_analyzer.ipynb @@ -11,7 +11,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": { "cellView": "form", "id": "tuOe1ymfHZPu" @@ -37,7 +37,7 @@ "id": "qFdPvlXBOdUN" }, "source": [ - "# Gemini API: Name of your guide" + "# Gemini API: GitHub Issue Analyzer" ] }, { @@ -46,16 +46,7 @@ "id": "MfBg1C5NB3X0" }, "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "r6P32iYYV27b" - }, - "source": [ - "_[remove me] Be sure to update the Colab link!_" + "" ] }, { @@ -64,23 +55,22 @@ "id": "XCVydW40iixa" }, "source": [ - "[If you're adding a new example, use this badge to promote yourself (yes sorry you'll have to write your name a lot of times)]\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", @@ -129,11 +119,28 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": { "id": "AQJjzmYgH3sX" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Note: you may need to restart the kernel to use updated packages.\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "ERROR: Invalid requirement: '#': Expected package name at the start of dependency specifier\n", + " #\n", + " ^\n" + ] + } + ], "source": [ "%pip install -U -q \"google-genai>=1.0.0\" # Install the Python SDK\n", "\n", @@ -183,7 +190,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": { "id": "Lf6FamchMDsk" }, @@ -201,120 +208,398 @@ "id": "w5i8tMZKIeUu" }, "source": [ - "## [Write your guide]\n", - "\n", - "[Add as many high level sections as needed to step through your guide. Try to introduce new concepts incrementally, including explanatory text at every step. Remember that notebooks need to be executable from start to finish using `Runtime -> Run all` in Colab.]" + "## Introduction\n", + "- This notebook demonstrates how to use the Gemini API with function calling to interact with the GitHub API and extract and analyze information about issues in a repository.\n", + "- To achive this goal we will be using the `PyGithub` python library to extract information from github which will later be analyzed by the gemini to present the answers to the queries asked.\n" ] }, { "cell_type": "markdown", - "metadata": { - "id": "4677dd58e9b5" - }, + "metadata": {}, "source": [ - "## Next Steps\n", - "### Useful API references:\n", - "\n", - "[Always end with links to the related doumentation]\n", - "\n", - "### Related examples\n", - "\n", - "[If any, add links to the related examples]\n", - "\n", - "### Continue your discovery of the Gemini API\n", - "\n", - "[Finally, link some other quickstarts that are either related or require the same level of expertise]\n" + "## Why PyGithub?\n", + "PyGitHub is a Python library to access the GitHub REST API. This library enables you to manage GitHub resources such as repositories, user profiles, and organizations in your Python applications." ] }, { "cell_type": "markdown", - "metadata": { - "id": "UhNtHfuxCGVy" - }, + "metadata": {}, "source": [ - "# Resources (don't forget to delete everything starting from here)\n", - "\n", - "* Follow the [Google developer documentation style guide](https://developers.google.com/style/highlights)\n", - "* The [TensorFlow documentation style guide](https://www.tensorflow.org/community/contribute/docs_style) has useful guidance for notebooks.\n", - "* Read the [Cookbook contributor guide](https://github.com/google-gemini/cookbook/blob/main/CONTRIBUTING.md) and the [Cookbook Examples contributor guide](https://github.com/google-gemini/cookbook/blob/main/examples/CONTRIBUTING.md)." + "## Install dependencies" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%pip install -U -q \"PyGithub\" # Install the PyGithub library" ] }, { "cell_type": "markdown", - "metadata": { - "id": "2V22fKegUtF9" - }, + "metadata": {}, "source": [ - "## Notebook style (also check the [Contributing guide](Contributing.mg))\n", - "\n", - "* Include the collapsed license at the top (uses the Colab \"Form\" mode to hide the cells).\n", - "* Save the notebook with the table of contents open.\n", - "* Use one `H1` header for the title.\n", - "* Include the button-bar immediately after the `H1`.\n", - "* Include an overview section before any code.\n", - "* Keep your installs and imports close to the code that first uses them. If they are used throughout (such as the SDK), they can go at the start of the guide.\n", - "* Keep code and text cells as brief as possible.\n", - "* Break text cells at headings\n", - "* Break code cells between \"building\" and \"running\", and between \"printing one result\" and \"printing another result\".\n", - "* Necessary but uninteresting code should be hidden in a toggleable code cell by putting `# @title` as the first line.\n", - "* You can optionally add a byline for content in `examples/` that you wrote, including one link to your GitHub, social, or site of your choice." + "You will need a GitHub Personal Access Token stored as a Colab Secret named **GITHUB_API_KEY**.\n", + "\n", + "1. Navigate to your GitHub account settings, select `Devloper settings`\n", + "2. Then choose Personal access tokens and click on Tokens (classic)\n", + "3. From there, you can generate a new token with the specific scopes (permissions) required for your application" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "GITHUB_API_KEY = userdata.get('GITHUB_API_KEY')" ] }, { "cell_type": "markdown", - "metadata": { - "id": "QKp40qS-DGEZ" - }, + "metadata": {}, "source": [ - "### Code style\n", - "\n", - "* Notebooks are for people. Write code optimized for clarity.\n", - "* Keep examples quick and concise.\n", - "* Use the [Google Python Style Guide](http://google.github.io/styleguide/pyguide.html), where applicable. Code formatted by [`pyink`](https://github.com/google/pyink) will always be accepted.\n", - "* In particular, defining functions and variables takes extra spaces around the `=` sign, while function parameters don't:\n", - "```python\n", - " var = value\n", - " function(\n", - " parameter=value\n", - " )\n", - "```\n", - "* If you define a function, run it and show us what it does before using it in another function.\n", - "* Demonstrate small parts before combining them into something more complex.\n", - "* Keep the code as simple as possible, only use extra parameters like temperature when needed, and in that case, explain why\n", - "* To ensure notebook text remains accurate, present model metadata by executing code.\n", - " * For example, instead of saying \"1M token context\" in the text, display the output of `client.models.get(model='...').input_token_limit`.\n" + "## Define GitHub API functions as tools\n", + "Now, define the Python functions that will be used as tools by the Gemini model. These functions will interact with the GitHub API using the PyGithub library. The docstrings are crucial as they provide the model with the necessary information to understand what each function does and what arguments it expects." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from github import Github\n", + "from datetime import datetime, timezone\n", + "from collections import Counter\n", + "\n", + "g = Github(GITHUB_API_KEY)\n", + "\n", + "def get_github_issues(repository_name: str):\n", + " \"\"\"Get all open issues.\"\"\"\n", + " try:\n", + " repo = g.get_repo(repository_name)\n", + " issues = repo.get_issues(state='open')\n", + " return [{\n", + " 'title': issue.title,\n", + " 'number': issue.number,\n", + " 'url': issue.html_url\n", + " } for issue in issues]\n", + " except Exception as e:\n", + " print(f\"An error occurred: {e}\")\n", + " return []\n", + "\n", + "\n", + "\n", + "\n", + "def get_issues_by_label(repository_name: str, label: str):\n", + " \"\"\"Get all open issues filtered by a specific label (e.g. 'bug', 'enhancement').\"\"\"\n", + " try:\n", + " repo = g.get_repo(repository_name)\n", + " issues = repo.get_issues(state='open', labels=[label])\n", + " return [{\n", + " 'title': issue.title,\n", + " 'number': issue.number,\n", + " 'url': issue.html_url,\n", + " 'created_at': issue.created_at.strftime('%Y-%m-%d'),\n", + " 'author': issue.user.login\n", + " } for issue in issues if not issue.pull_request]\n", + " except Exception as e:\n", + " print(f\"An error occurred: {e}\")\n", + " return []\n", + "\n", + "\n", + "def get_stale_issues(repository_name: str, days_inactive: int = 30):\n", + " \"\"\"Get open issues with no activity for N+ days.\"\"\"\n", + " try:\n", + " repo = g.get_repo(repository_name)\n", + " issues = repo.get_issues(state='open')\n", + " stale = []\n", + "\n", + " for issue in issues:\n", + " if issue.pull_request:\n", + " continue\n", + " last_activity = issue.updated_at\n", + " inactive_days = (datetime.now(timezone.utc) - last_activity).days\n", + "\n", + " if inactive_days >= days_inactive:\n", + " stale.append({\n", + " 'title': issue.title,\n", + " 'number': issue.number,\n", + " 'url': issue.html_url,\n", + " 'inactive_days': inactive_days,\n", + " 'last_updated': last_activity.strftime('%Y-%m-%d')\n", + " })\n", + "\n", + " return sorted(stale, key=lambda x: x['inactive_days'], reverse=True)\n", + "\n", + " except Exception as e:\n", + " print(f\"An error occurred: {e}\")\n", + " return []\n", + "\n", + "\n", + "def get_unassigned_issues(repository_name: str):\n", + " \"\"\"Get all open issues that have no assignee.\"\"\"\n", + " try:\n", + " repo = g.get_repo(repository_name)\n", + " issues = repo.get_issues(state='open')\n", + " return [{\n", + " 'title': issue.title,\n", + " 'number': issue.number,\n", + " 'url': issue.html_url,\n", + " 'labels': [l.name for l in issue.labels],\n", + " 'created_at': issue.created_at.strftime('%Y-%m-%d')\n", + " } for issue in issues if not issue.pull_request and not issue.assignee]\n", + " except Exception as e:\n", + " print(f\"An error occurred: {e}\")\n", + " return []\n", + "\n", + "\n", + "def get_issue_summary(repository_name: str):\n", + " \"\"\"Get a high-level summary: total counts, top labels, most active contributors.\"\"\"\n", + " try:\n", + " repo = g.get_repo(repository_name)\n", + " issues = repo.get_issues(state='open')\n", + " label_counter = Counter()\n", + " author_counter = Counter()\n", + " total = 0\n", + "\n", + " for issue in issues:\n", + " if issue.pull_request:\n", + " continue\n", + " total += 1\n", + " author_counter[issue.user.login] += 1\n", + " for label in issue.labels:\n", + " label_counter[label.name] += 1\n", + "\n", + " return {\n", + " 'total_open_issues': total,\n", + " 'top_labels': label_counter.most_common(5),\n", + " 'top_contributors': author_counter.most_common(5)\n", + " }\n", + "\n", + " except Exception as e:\n", + " print(f\"An error occurred: {e}\")\n", + " return {}\n", + "\n", + "\n", + "def search_issues(repository_name: str, keyword: str):\n", + " \"\"\"Search open issues whose title or body contains a keyword.\"\"\"\n", + " try:\n", + " repo = g.get_repo(repository_name)\n", + " issues = repo.get_issues(state='open')\n", + " keyword_lower = keyword.lower()\n", + " return [{\n", + " 'title': issue.title,\n", + " 'number': issue.number,\n", + " 'url': issue.html_url,\n", + " 'matched_in': 'title' if keyword_lower in issue.title.lower() else 'body'\n", + " } for issue in issues\n", + " if not issue.pull_request\n", + " and (keyword_lower in issue.title.lower()\n", + " or (issue.body and keyword_lower in issue.body.lower()))]\n", + " except Exception as e:\n", + " print(f\"An error occurred: {e}\")\n", + " return []" ] }, { "cell_type": "markdown", - "metadata": { - "id": "78HBT9cQXJko" - }, + "metadata": {}, "source": [ - "### Text\n", - "\n", - "* Use an imperative style. \"Run a prompt using the API.\"\n", - "* Use sentence case in titles/headings.\n", - "* Use short titles/headings: \"Download the data\", \"Call the API\", \"Process the results\".\n", - "* Use the [Google developer documentation style guide](https://developers.google.com/style/highlights).\n", - "* Use [second person](https://developers.google.com/style/person): \"you\" rather than \"we\".\n", - "* When using links between notebooks, use relative ones as they'll work better in IDEs and Colab. Use absolute ones to link to folders or markdown files.\n" + "## Interact with the model\n", + "\n", + "Now it's time to interact with the Gemini model. Start a ChatSession and pass the functions as a tools. The model will automatically call the function with the correct arguments based on the prompt." + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "============================================================\n", + "Q: Show me the open issues in google-gemini/cookbook.\n", + "============================================================\n", + "There are many open issues and pull requests in the [google-gemini/cookbook](https://github.com/google-gemini/cookbook/issues) repository. Here are some of the most recent ones:\n", + "\n", + "### **Open Issues (Recent)**\n", + "* **#1149:** [Linking GCP billing account does not upgrade Gemini API from free-tier quotas](https://github.com/google-gemini/cookbook/issues/1149)\n", + "* **#1144:** [Monthly issue metrics report](https://github.com/google-gemini/cookbook/issues/1144)\n", + "* **#1125:** [Add Example Notebook: Context-Aware Support Ticket Assistant](https://github.com/google-gemini/cookbook/issues/1125)\n", + "* **#1123:** [Live API for just quick transcription? Or is gemini-2.0-flash-lite fastest possible?](https://github.com/google-gemini/cookbook/issues/1123)\n", + "* **#1122:** [API_KEY login not supported for genai.client](https://github.com/google-gemini/cookbook/issues/1122)\n", + "* **#1108:** [Live API does not perceive visual information and hallucinates](https://github.com/google-gemini/cookbook/issues/1108)\n", + "* **#1091:** [Error_handling.ipynb: retry.if_transient_error doesn't catch google-genai errors](https://github.com/google-gemini/cookbook/issues/1091)\n", + "* **#1036:** [File search API not available with Vertex AI](https://github.com/google-gemini/cookbook/issues/1036)\n", + "\n", + "### **Open Pull Requests (Recent Contributions)**\n", + "* **#1148:** [chore: update deprecated models to gemini-1.5/2.0 family](https://github.com/google-gemini/cookbook/pull/1148)\n", + "* **#1146:** [Improved + Fix code logic and reorder notebook cells](https://github.com/google-gemini/cookbook/pull/1146)\n", + "* **#1139:** [Bump qs from 6.12.0 to 6.14.2 in /quickstarts/file-api](https://github.com/google-gemini/cookbook/pull/1139)\n", + "* **#1138:** [Split and add Notebooks to Gemini Robotics](https://github.com/google-gemini/cookbook/pull/1138)\n", + "* **#1136:** [Add self-improving prompts notebook](https://github.com/google-gemini/cookbook/pull/1136)\n", + "* **#1131:** [Customer financial profiler](https://github.com/google-gemini/cookbook/pull/1131)\n", + "* **#1121:** [Fix unused os import in quickstarts/Get_started_LiveAPI.py](https://github.com/google-gemini/cookbook/pull/1121)\n", + "\n", + "Would you like me to filter these by a specific label (like `bug` or `documentation`) or search for a specific topic?\n", + "\n", + "============================================================\n", + "Q: Find any stale issues inactive for 60+ days in google-gemini/cookbook.\n", + "============================================================\n", + "There are **37 open issues** in `google-gemini/cookbook` that have been inactive for 60 or more days.\n", + "\n", + "Here are some of the most notable stale issues:\n", + "\n", + "### **Longest Stale Issues (400+ Days)**\n", + "* **#320:** [Portkey AI cookbook with Gemini](https://github.com/google-gemini/cookbook/issues/320) (Inactive for 457 days)\n", + "* **#156:** [Enhance Function_calling.ipynb cookbook](https://github.com/google-gemini/cookbook/issues/156) (Inactive for 457 days)\n", + "\n", + "### **Feature Proposals & Tutorials (200+ Days)**\n", + "* **#715:** [Proposal: Example Notebook for Async ADK Task Orchestration via GenAI](https://github.com/google-gemini/cookbook/issues/715)\n", + "* **#750:** [Sketch2Paint - A web app demo that converts sketches into beautiful paintings](https://github.com/google-gemini/cookbook/issues/750)\n", + "* **#541:** [Proposal: Migrate Gemini Cookbook Python Examples to JavaScript/TypeScript](https://github.com/google-gemini/cookbook/issues/541)\n", + "* **#545:** [Adding Rust Implementation For Gemini APIs](https://github.com/google-gemini/cookbook/issues/545)\n", + "\n", + "### **Technical Issues & Bug Reports (100+ Days)**\n", + "* **#906:** [Gemini Live API - Websocket Tool Call Response](https://github.com/google-gemini/cookbook/issues/906)\n", + "* **#961:** [Image Segmentation Returning Unusable Results in Spatial_understanding.ipynb](https://github.com/google-gemini/cookbook/issues/961)\n", + "* **#393:** [google.generativeai: tools don't work with JSON mode](https://github.com/google-gemini/cookbook/issues/393)\n", + "\n", + "### **Recently Became Stale (60-90 Days)**\n", + "* **#1091:** [Error_handling.ipynb: retry.if_transient_error doesn't catch google-genai errors](https://github.com/google-gemini/cookbook/issues/1091)\n", + "* **#1090:** [[Proposal] Logit Lens Analysis for Gemma 2B](https://github.com/google-gemini/cookbook/issues/1090)\n", + "* **#1028:** [API doc states model: gemini-2.5-flash-image supports Structured Output, but it doesn't.](https://github.com/google-gemini/cookbook/issues/1028)\n", + "\n", + "Would you like more details on any of these specific issues?\n", + "\n", + "============================================================\n", + "Q: Show me all unassigned issues in google-gemini/cookbook.\n", + "============================================================\n", + "There are several unassigned issues in the `google-gemini/cookbook` repository. Here are some of the most notable ones, categorized by their labels and topics:\n", + "\n", + "### **Bug Reports & Technical Issues**\n", + "* **#1149:** [Linking GCP billing account does not upgrade Gemini API from free-tier quotas](https://github.com/google-gemini/cookbook/issues/1149)\n", + "* **#1091:** [Error_handling.ipynb: retry.if_transient_error doesn't catch google-genai errors](https://github.com/google-gemini/cookbook/issues/1091)\n", + "* **#796:** [activityHandling NO_INTERRUPTION not being respected](https://github.com/google-gemini/cookbook/issues/796)\n", + "* **#449:** [Gemini 2.0 Flash structured output value repetition and missing fields](https://github.com/google-gemini/cookbook/issues/449)\n", + "\n", + "### **Feature Requests & Proposals**\n", + "* **#783:** [Live Stream Support for Gemini TTS](https://github.com/google-gemini/cookbook/issues/783)\n", + "* **#766:** [Suggestion to include Gemini LIVE API Bidirectional Audio in React Native](https://github.com/google-gemini/cookbook/issues/766)\n", + "* **#715:** [Proposal: Example Notebook for Async ADK Task Orchestration via GenAI](https://github.com/google-gemini/cookbook/issues/715)\n", + "* **#545:** [Adding Rust Implementation For Gemini APIs](https://github.com/google-gemini/cookbook/issues/545)\n", + "* **#541:** [Proposal: Migrate Gemini Cookbook Python Examples to JavaScript/TypeScript](https://github.com/google-gemini/cookbook/issues/541)\n", + "* **#47:** [Streaming Function Calls](https://github.com/google-gemini/cookbook/issues/47)\n", + "\n", + "### **New Notebook Ideas**\n", + "* **#690:** [Add Cookbook Example: Scalable Cross-Media Recommendation System (Gemini + Qdrant)](https://github.com/google-gemini/cookbook/issues/690)\n", + "* **#651:** [New Cookbook Example - Outfit Recommendation](https://github.com/google-gemini/cookbook/issues/651)\n", + "* **#581:** [Adding RAG example with LangChain and BigQuery as Vector Store](https://github.com/google-gemini/cookbook/issues/581)\n", + "\n", + "### **Maintenance**\n", + "* **#1144, #1127, #1092, etc.:** Monthly issue metrics reports (Multiple recurring issues)\n", + "* **#872:** [Fix DeprecationWarning](https://github.com/google-gemini/cookbook/issues/872)\n", + "\n", + "Would you like me to find issues with a specific label (e.g., `help wanted`) or focus on a particular component like `quickstarts`?\n", + "\n", + "============================================================\n", + "Q: Search for issues mentioning 'authentication' in google-gemini/cookbook.\n", + "============================================================\n", + "I found **2 open issues** in `google-gemini/cookbook` that mention \"authentication\" in their body:\n", + "\n", + "1. **#1122:** [API_KEY login not supported for genai.client](https://github.com/google-gemini/cookbook/issues/1122)\n", + " * **Description:** This issue discusses problems with using `API_KEY` for authentication with the `genai.client`, which is relevant for users trying to authenticate their sessions.\n", + "\n", + "2. **#1036:** [File search API not available with Vertex AI](https://github.com/google-gemini/cookbook/issues/1036)\n", + " * **Description:** While primarily about the File Search API, the body of this issue mentions authentication differences between Google AI Studio and Vertex AI.\n", + "\n", + "There are also several **pull requests** related to authentication that you might find relevant:\n", + "* **#1021:** [Added `Authentication` notebook for JS](https://github.com/google-gemini/cookbook/pull/1021)\n", + "* **#990:** [Migrating OAuth notebook](https://github.com/google-gemini/cookbook/pull/990)\n", + "\n", + "Would you like more details on any of these?\n", + "\n", + "============================================================\n", + "Q: Give me a summary of issues in google-gemini/cookbook.\n", + "============================================================\n", + "There are currently **69 open issues** in the [google-gemini/cookbook](https://github.com/google-gemini/cookbook/issues) repository. Here’s a high-level summary:\n", + "\n", + "### **Top Labels**\n", + "The repository issues are primarily focused on:\n", + "* **Feature Requests (36 issues):** The most common label, indicating a strong community interest in new notebook examples, SDK ports, and API features.\n", + "* **Bugs (14 issues):** Focused on notebook errors, API inconsistencies (especially with Gemini 2.0/2.5), and documentation gaps.\n", + "* **Quickstarts (8 issues):** Related to maintaining and improving the basic onboarding examples.\n", + "\n", + "### **Most Active Contributors**\n", + "* **`github-actions[bot]`:** Handles recurring reports like monthly issue metrics.\n", + "* **`MarkDaoust` & `andycandy`:** Key maintainers/contributors frequently involved in triaging and discussing new proposals.\n", + "\n", + "### **Common Themes**\n", + "Based on recent activity, the key areas of focus include:\n", + "1. **Gemini 2.0/2.5 Integration:** Many issues discuss the new model families, structured output inconsistencies, and Live API behavior.\n", + "2. **SDK Migrations:** There is an ongoing effort to migrate older notebooks to the new `google-genai` SDK and port Python examples to JavaScript/TypeScript.\n", + "3. **Authentication & Quotas:** Users are frequently reporting issues with API key usage, Vertex AI vs. AI Studio differences, and billing-related quota upgrades.\n", + "4. **Community-Driven Notebooks:** A significant portion of open issues are proposals for new use cases, such as \"Smart Contract Auditing,\" \"Financial Profiler,\" and \"RAG with BigQuery.\"\n", + "\n", + "Would you like me to dive deeper into any of these specific areas, such as the `type:bug` issues or proposals for new notebooks?\n" + ] + } + ], + "source": [ + "client = genai.Client(api_key=GOOGLE_API_KEY)\n", + "chat = client.chats.create(\n", + " model=MODEL_ID,\n", + " config={\n", + " \"tools\": [\n", + " get_github_issues,\n", + " get_issues_by_label,\n", + " get_stale_issues,\n", + " get_unassigned_issues,\n", + " get_issue_summary,\n", + " search_issues\n", + " ]\n", + " }\n", + ")\n", + "\n", + "# ── Now just ask naturally — model picks the right tool automatically ─────────\n", + "questions = [\n", + " \"Show me the open issues in google-gemini/cookbook.\",\n", + " \"Find any stale issues inactive for 60+ days in google-gemini/cookbook.\",\n", + " \"Show me all unassigned issues in google-gemini/cookbook.\",\n", + " \"Search for issues mentioning 'authentication' in google-gemini/cookbook.\",\n", + " \"Give me a summary of issues in google-gemini/cookbook.\",\n", + "]\n", + "\n", + "for question in questions:\n", + " print(f\"\\n{'='*60}\")\n", + " print(f\"Q: {question}\")\n", + " print(f\"{'='*60}\")\n", + " response = chat.send_message(question)\n", + " print(response.text)\n" ] }, { "cell_type": "markdown", "metadata": { - "id": "YrsKXcPRUvK9" + "id": "4677dd58e9b5" }, "source": [ - "## GitHub workflow\n", - "\n", - "* Be consistent about how you save your notebooks, otherwise the JSON diffs are messy. [`nbfmt` and `nblint`](https://github.com/tensorflow/docs/blob/master/tools/tensorflow_docs/tools/README.md) help here.\n", - "* This notebook has the \"Omit code cell output when saving this notebook\" option set. GitHub refuses to diff notebooks with large diffs (inline images).\n", - "* [ReviewNB.com](http://reviewnb.com) can help with diffs. This is linked in a comment on a notebook pull request.\n", - "* Use the [Open in Colab](https://chrome.google.com/webstore/detail/open-in-colab/iogfkhleblhcpcekbiedikdehleodpjo) extension to open a GitHub notebook in Colab.\n", - "* The easiest way to edit a notebook in GitHub is to open it with Colab from the branch you want to edit. Then use File --> Save a copy in GitHub, which will save it back to the branch you opened it from.\n", - "* For PRs it's helpful to post a direct Colab link to the PR head: https://colab.research.google.com/github/{USER}/{REPO}/blob/{BRANCH}/{PATH}.ipynb" + "## Next Steps\n", + "### Useful API references:\n", + "- [Pygithub](https://pygithub.readthedocs.io/en/latest/apis.html)\n", + "- [GeminiAPI](https://ai.google.dev/gemini-api/docs)\n", + "\n", + "### Continue your discovery of the Gemini API\n", + "\n", + " - [Apollo_11](https://github.com/google-gemini/cookbook/blob/main/examples/Apollo_11.ipynb)\n", + " - [Guess_the_shape](https://github.com/google-gemini/cookbook/blob/main/examples/Guess_the_shape.ipynb)\n" ] } ], @@ -323,12 +608,25 @@ "collapsed_sections": [ "Tce3stUlHN0L" ], - "name": "GitHub_issue_analyzer.ipynb", + "name": "Template.ipynb", "toc_visible": true }, "kernelspec": { - "display_name": "Python 3", + "display_name": "venv", + "language": "python", "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.9" } }, "nbformat": 4, From e1b19b614534d33c46d97c8118eb92f2e89767a7 Mon Sep 17 00:00:00 2001 From: Rohan Dwivedi Date: Thu, 5 Mar 2026 17:05:22 +0530 Subject: [PATCH 3/8] updated readme --- examples/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/README.md b/examples/README.md index 6b845d9fb..fae04d420 100644 --- a/examples/README.md +++ b/examples/README.md @@ -33,8 +33,7 @@ This is a collection of fun and helpful examples for the Gemini API. | [Talk to documents](./Talk_to_documents_with_embeddings.ipynb) | Use embeddings to search through a custom database. | Embeddings | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/examples/Talk_to_documents_with_embeddings.ipynb) | | [Entity extraction](./Entity_Extraction.ipynb) | Use Gemini API to speed up some of your tasks, such as searching through text to extract needed information. Entity extraction with a Gemini model is a simple query, and you can ask it to retrieve its answer in the form that you prefer. | Embeddings | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/examples/Entity_Extraction.ipynb) | | [Google I/O 2025 Live coding session](./Google_IO2025_Live_Coding.ipynb) | Play with the notebook used during the Google I/O 2025 live coding session delivered by the Google DeepMind DevRel team. Work with the Gemini API SDK, know and practice with the GenMedia models, the thinking capable models, start using the Gemini API tools and more! | Gemini API and its models and features | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/examples/Google_IO2025_Live_Coding.ipynb) | -| [GitHub issue analyzer](./GitHub_issue_analyzer.ipynb) | Use Gemini API to interact with Pygithub API and extract useful insights from this repository | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/examples/GitHub_issue_analyzer.ipynb) | - +| [GitHub issue analyzer](./GitHub_issue_analyzer.ipynb) | Use Gemini API to interact with Pygithub API and extract useful insights from this repository | Gemini API, Tools | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/examples/GitHub_issue_analyzer.ipynb) | ---
Some old examples are still using the legacy SDK, they should still work and are still worth checking to get ideas: From 549905a8f38bbd63ee307e4b89f344f00bce6b0d Mon Sep 17 00:00:00 2001 From: Rohan Dwivedi Date: Thu, 5 Mar 2026 17:10:55 +0530 Subject: [PATCH 4/8] updated-text --- examples/GitHub_issue_analyzer.ipynb | 78 +++++++++++----------------- 1 file changed, 31 insertions(+), 47 deletions(-) diff --git a/examples/GitHub_issue_analyzer.ipynb b/examples/GitHub_issue_analyzer.ipynb index 74d89f039..8a7ed6569 100644 --- a/examples/GitHub_issue_analyzer.ipynb +++ b/examples/GitHub_issue_analyzer.ipynb @@ -81,22 +81,22 @@ { "cell_type": "markdown", "metadata": { - "id": "6b527162" + "id": "xHxb-dlhMIzW" }, "source": [ - "[When the model is a preview one an can potentially change or if it's a paid-only feature, add a disclaimer:]\n", - "> **Note:** Image generation is a paid-only feature and won't work if you are on the free tier. Check the [pricing](https://ai.google.dev/pricing#imagen-4) page for more details.\n", - "\n", - "> **Note:** Image-out is a preview feature. It is free to use for now with quota limitations, but is subject to change.\n" + "## Introduction\n", + "- This notebook demonstrates how to use the Gemini API with function calling to interact with the GitHub API and extract and analyze information about issues in a repository.\n", + "- To achive this goal we will be using the `PyGithub` python library to extract information from github which will later be analyzed by the gemini to present the answers to the queries asked." ] }, { "cell_type": "markdown", "metadata": { - "id": "xHxb-dlhMIzW" + "id": "22f6f2ae935c" }, "source": [ - "[Include a paragraph or two here explaining what this example demonstrates, who should be interested in it, and what you need to know before you get started.]" + "## Why PyGithub?\n", + "PyGitHub is a Python library to access the GitHub REST API. This library enables you to manage GitHub resources such as repositories, user profiles, and organizations in your Python applications." ] }, { @@ -205,25 +205,8 @@ { "cell_type": "markdown", "metadata": { - "id": "w5i8tMZKIeUu" + "id": "f84379d9142c" }, - "source": [ - "## Introduction\n", - "- This notebook demonstrates how to use the Gemini API with function calling to interact with the GitHub API and extract and analyze information about issues in a repository.\n", - "- To achive this goal we will be using the `PyGithub` python library to extract information from github which will later be analyzed by the gemini to present the answers to the queries asked.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Why PyGithub?\n", - "PyGitHub is a Python library to access the GitHub REST API. This library enables you to manage GitHub resources such as repositories, user profiles, and organizations in your Python applications." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, "source": [ "## Install dependencies" ] @@ -231,7 +214,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "id": "5e0b58a32d1d" + }, "outputs": [], "source": [ "%pip install -U -q \"PyGithub\" # Install the PyGithub library" @@ -239,7 +224,9 @@ }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "id": "341f3de14ff8" + }, "source": [ "You will need a GitHub Personal Access Token stored as a Colab Secret named **GITHUB_API_KEY**.\n", "\n", @@ -251,7 +238,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "id": "da25bab41592" + }, "outputs": [], "source": [ "GITHUB_API_KEY = userdata.get('GITHUB_API_KEY')" @@ -259,7 +248,9 @@ }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "id": "f168cbfec3d2" + }, "source": [ "## Define GitHub API functions as tools\n", "Now, define the Python functions that will be used as tools by the Gemini model. These functions will interact with the GitHub API using the PyGithub library. The docstrings are crucial as they provide the model with the necessary information to understand what each function does and what arguments it expects." @@ -268,7 +259,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "id": "507a3ec11110" + }, "outputs": [], "source": [ "from github import Github\n", @@ -407,7 +400,9 @@ }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "id": "cd21201b9e4e" + }, "source": [ "## Interact with the model\n", "\n", @@ -417,7 +412,9 @@ { "cell_type": "code", "execution_count": 13, - "metadata": {}, + "metadata": { + "id": "2c54ebc2a98d" + }, "outputs": [ { "name": "stdout", @@ -608,25 +605,12 @@ "collapsed_sections": [ "Tce3stUlHN0L" ], - "name": "Template.ipynb", + "name": "GitHub_issue_analyzer.ipynb", "toc_visible": true }, "kernelspec": { - "display_name": "venv", - "language": "python", + "display_name": "Python 3", "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.11.9" } }, "nbformat": 4, From b37fdb5902e47c976a8bb7d889973c106b1815f7 Mon Sep 17 00:00:00 2001 From: Rohan Dwivedi Date: Sat, 28 Mar 2026 16:49:04 +0530 Subject: [PATCH 5/8] updated notebook --- examples/GitHub_issue_analyzer.ipynb | 10 ++++++---- examples/README.md | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/GitHub_issue_analyzer.ipynb b/examples/GitHub_issue_analyzer.ipynb index 8a7ed6569..8829ea242 100644 --- a/examples/GitHub_issue_analyzer.ipynb +++ b/examples/GitHub_issue_analyzer.ipynb @@ -46,7 +46,9 @@ "id": "MfBg1C5NB3X0" }, "source": [ - "" + "\n", + " \n", + "" ] }, { @@ -86,7 +88,7 @@ "source": [ "## Introduction\n", "- This notebook demonstrates how to use the Gemini API with function calling to interact with the GitHub API and extract and analyze information about issues in a repository.\n", - "- To achive this goal we will be using the `PyGithub` python library to extract information from github which will later be analyzed by the gemini to present the answers to the queries asked." + "- To achieve this goal, you will be using the `PyGithub` python library to extract information from GitHub which will later be analyzed by Gemini to present the answers to your queries." ] }, { @@ -185,7 +187,7 @@ "id": "hL54YG-kMDVF" }, "source": [ - "Now select the model you want to use in this guide, either by selecting one in the list or writing it down. Keep in mind that some models, like the 2.5 ones are thinking models and thus take slightly more time to respond (cf. [thinking notebook](./Get_started_thinking.ipynb) for more details and in particular learn how to switch the thiking off)." + "Now select the model you want to use in this guide, either by selecting one in the list or writing it down. Keep in mind that some models, like the 2.5 ones are thinking models and thus take slightly more time to respond (cf. [thinking notebook](./Get_started_thinking.ipynb) for more details and in particular learn how to switch the thinking off)." ] }, { @@ -230,7 +232,7 @@ "source": [ "You will need a GitHub Personal Access Token stored as a Colab Secret named **GITHUB_API_KEY**.\n", "\n", - "1. Navigate to your GitHub account settings, select `Devloper settings`\n", + "1. Navigate to your GitHub account settings, select `Developer settings`\n", "2. Then choose Personal access tokens and click on Tokens (classic)\n", "3. From there, you can generate a new token with the specific scopes (permissions) required for your application" ] diff --git a/examples/README.md b/examples/README.md index 707750313..a99b55492 100644 --- a/examples/README.md +++ b/examples/README.md @@ -34,9 +34,10 @@ This is a collection of fun and helpful examples for the Gemini API. | [Talk to documents](./Talk_to_documents_with_embeddings.ipynb) | Use embeddings to search through a custom database. | Embeddings | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/examples/Talk_to_documents_with_embeddings.ipynb) | | [Entity extraction](./Entity_Extraction.ipynb) | Use Gemini API to speed up some of your tasks, such as searching through text to extract needed information. Entity extraction with a Gemini model is a simple query, and you can ask it to retrieve its answer in the form that you prefer. | Embeddings | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/examples/Entity_Extraction.ipynb) | | [Google I/O 2025 Live coding session](./Google_IO2025_Live_Coding.ipynb) | Play with the notebook used during the Google I/O 2025 live coding session delivered by the Google DeepMind DevRel team. Work with the Gemini API SDK, know and practice with the GenMedia models, the thinking capable models, start using the Gemini API tools and more! | Gemini API and its models and features | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/examples/Google_IO2025_Live_Coding.ipynb) | -| [GitHub issue analyzer](./GitHub_issue_analyzer.ipynb) | Use Gemini API to interact with Pygithub API and extract useful insights from this repository | Gemini API, Tools | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/examples/GitHub_issue_analyzer.ipynb) | + | [Gemini MultimodalBot Text & Image Tutorial](./Gemini_MultimodalBot_Text_Image_Tutorial.ipynb) | Learn how to use Gemini's multimodal capabilities to process both text and image inputs. | Multimodal | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/examples/Gemini_MultimodalBot_Text_Image_Tutorial.ipynb) | +| [GitHub issue analyzer](./GitHub_issue_analyzer.ipynb) | Use Gemini API to interact with PyGitHub API and extract useful insights from this repository | Gemini API, Tools | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/examples/GitHub_issue_analyzer.ipynb) | ---
Some old examples are still using the legacy SDK, they should still work and are still worth checking to get ideas: From 4f58b9cd9fb202b8a29f38b60f015b525d7c1664 Mon Sep 17 00:00:00 2001 From: kkorpal Date: Tue, 21 Apr 2026 20:31:51 +0530 Subject: [PATCH 6/8] Update Colab link in GitHub_issue_analyzer notebook --- examples/GitHub_issue_analyzer.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/GitHub_issue_analyzer.ipynb b/examples/GitHub_issue_analyzer.ipynb index 8829ea242..e38f30e78 100644 --- a/examples/GitHub_issue_analyzer.ipynb +++ b/examples/GitHub_issue_analyzer.ipynb @@ -45,8 +45,8 @@ "metadata": { "id": "MfBg1C5NB3X0" }, - "source": [ - "\n", + "source":[ + "\n", " \n", "" ] From e4381a80aaf6d33ce703ecef7a262e22422db7a0 Mon Sep 17 00:00:00 2001 From: kkorpal Date: Tue, 21 Apr 2026 20:51:24 +0530 Subject: [PATCH 7/8] Update Colab link in GitHub_issue_analyzer notebook --- examples/GitHub_issue_analyzer.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/GitHub_issue_analyzer.ipynb b/examples/GitHub_issue_analyzer.ipynb index e38f30e78..4a154a841 100644 --- a/examples/GitHub_issue_analyzer.ipynb +++ b/examples/GitHub_issue_analyzer.ipynb @@ -46,7 +46,7 @@ "id": "MfBg1C5NB3X0" }, "source":[ - "\n", + "\n", " \n", "" ] From f8df514fdf2f5ce319d5d8dfc2d2f1a16d1bfd9a Mon Sep 17 00:00:00 2001 From: Rohan Dwivedi Date: Wed, 22 Apr 2026 14:51:37 +0530 Subject: [PATCH 8/8] updated format --- examples/GitHub_issue_analyzer.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/GitHub_issue_analyzer.ipynb b/examples/GitHub_issue_analyzer.ipynb index 4a154a841..8829ea242 100644 --- a/examples/GitHub_issue_analyzer.ipynb +++ b/examples/GitHub_issue_analyzer.ipynb @@ -45,7 +45,7 @@ "metadata": { "id": "MfBg1C5NB3X0" }, - "source":[ + "source": [ "\n", " \n", ""
\n", - " \n", - " \"Giom-V's\n", + " \"Rohan\n", " \n", " \n", - "

This notebook was contributed by Giom (use either your GitHub handle or your real name, your choice).

\n", - "
Add a link to you blog, or linkedIn, or something else - See Giom other notebooks here.

\n", + "

This notebook was contributed by Rohan Dwivedi.

\n", + "
Find me at linked-in - See Rohan other notebooks here.

\n", " \n", " Have a cool Gemini example? Feel free to share it too!\n", "