From 581d32209983d301424736a84adf2424c48ccf71 Mon Sep 17 00:00:00 2001 From: ROHAN DWIVEDI Date: Fri, 29 Aug 2025 19:15:48 +0530 Subject: [PATCH 1/5] Added example for GitHub_issues_analyzer --- examples/GitHub_issues_analyzer.ipynb | 417 ++++++++++++++++++++++++++ 1 file changed, 417 insertions(+) create mode 100644 examples/GitHub_issues_analyzer.ipynb diff --git a/examples/GitHub_issues_analyzer.ipynb b/examples/GitHub_issues_analyzer.ipynb new file mode 100644 index 000000000..52fda7b5f --- /dev/null +++ b/examples/GitHub_issues_analyzer.ipynb @@ -0,0 +1,417 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "da69634f", + "metadata": { + "id": "3c5dbcc9ae0c" + }, + "source": [ + "##### Copyright 2025 Google LLC." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "83592f4e", + "metadata": { + "cellView": "form", + "id": "ca23c3f523a7" + }, + "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", + "id": "e1bc87ec", + "metadata": { + "id": "76c76c0c1940" + }, + "source": [ + "# Github issues analyzer" + ] + }, + { + "cell_type": "markdown", + "id": "4b02acee", + "metadata": { + "id": "f89c4874965e" + }, + "source": [ + "" + ] + }, + { + "cell_type": "markdown", + "id": "6a790031", + "metadata": { + "id": "fa27202f4f9f" + }, + "source": [ + "This notebook demonstrates how to use the Gemini API with function calling to interact with the GitHub API and display information about issues in a repository." + ] + }, + { + "cell_type": "markdown", + "id": "77ef0bda", + "metadata": { + "id": "5ad23b6eff6c" + }, + "source": [ + "### What is 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", + "id": "cd79e50f", + "metadata": { + "id": "46d25fe73955" + }, + "source": [ + "### Install dependencies" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "b331031f", + "metadata": { + "id": "c185431b6892" + }, + "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": [ + "\n", + "[notice] A new release of pip is available: 25.1.1 -> 25.2\n", + "[notice] To update, run: python.exe -m pip install --upgrade pip\n" + ] + } + ], + "source": [ + "%pip install -qU \"google-genai>=1.0.0\" \"PyGithub\"" + ] + }, + { + "cell_type": "markdown", + "id": "1a12c380", + "metadata": { + "id": "02d1b126d613" + }, + "source": [ + "### Setup up yout API key\n", + "To run the following cell, your API key must be stored 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** quickstart for an example.\n", + "\n", + "You will also need a GitHub Personal Access Token stored as a Colab Secret named **GITHUB_API_KEY**. \n", + "\n", + "To get the **GITHUB_API_KEY** follow these instructions:\n", + "\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\n", + "\n", + "check [GitHub documentation](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) for more information\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "133fd47c", + "metadata": { + "id": "7b291e5dc3cc" + }, + "outputs": [], + "source": [ + "from google import genai\n", + "from google.colab import userdata\n", + "\n", + "\n", + "GOOGLE_API_KEY=userdata.get('GOOGLE_API_KEY')\n", + "GITHUB_API_KEY = userdata.get(\"GITHUB_API_KEY\")\n", + "\n", + "client = genai.Client(api_key=GOOGLE_API_KEY)" + ] + }, + { + "cell_type": "markdown", + "id": "fd6b01dc", + "metadata": { + "id": "818203a4ea04" + }, + "source": [ + "### Choose a model" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "5131ed0c", + "metadata": { + "id": "32888183d345" + }, + "outputs": [], + "source": [ + "MODEL_ID=\"gemini-2.5-flash\" # @param [\"gemini-2.5-flash-lite\",\"gemini-2.5-flash\",\"gemini-2.5-pro\"] {\"allow-input\":true, isTemplate: true}" + ] + }, + { + "cell_type": "markdown", + "id": "532b14a1", + "metadata": { + "id": "82ad9a91ee3b" + }, + "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.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "480565c7", + "metadata": { + "id": "8a81587cb225" + }, + "outputs": [], + "source": [ + "from github import Github\n", + "\n", + "g = Github(GITHUB_API_KEY)\n", + "\n", + "\n", + "def get_github_issues(repository_name: str):\n", + " \"\"\"\n", + " Gets the open issues for a given GitHub repository.\n", + "\n", + " Args:\n", + " repository_name: The name of the repository in the format 'owner/repo'.\n", + " \n", + " Returns:\n", + " A list of dictionaries, where each dictionary represents an issue and contains its title, number, and URL.\n", + " \"\"\"\n", + " try:\n", + " repo = g.get_repo(repository_name)\n", + " issues = repo.get_issues(state='open')\n", + " \n", + " issue_list = []\n", + " for issue in issues:\n", + " issue_list.append({\n", + " 'title': issue.title,\n", + " 'number': issue.number,\n", + " 'url': issue.html_url\n", + " })\n", + " return issue_list\n", + "\n", + " except Exception as e:\n", + " return {\"error\": f\"An error occurred: {e}\"}" + ] + }, + { + "cell_type": "markdown", + "id": "b09e8720", + "metadata": { + "id": "f25c6ce11a41" + }, + "source": [ + "### Interact with the model\n", + "Now it's time to interact with the Gemini model. We'll create a ChatSession and pass the get_github_issues function as a tool. The model will automatically call the function with the correct arguments based on the user's prompt.\n" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "0707b493", + "metadata": { + "id": "59fdc301959b" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Here are the open issues in the google-gemini/cookbook repository:\n", + "\n", + "* **922**: Legal Retrieval Pipeline Cookbook with Gemini Embeddings using MLR & … (Pull Request) - https://github.com/google-gemini/cookbook/pull/922\n", + "* **915**: added example of github actions (Pull Request) - https://github.com/google-gemini/cookbook/pull/915\n", + "* **912**: Added batching_and_chunking.ipynb notebook (Pull Request) - https://github.com/google-gemini/cookbook/pull/912\n", + "* **911**: AI-powered GitHub Action - https://github.com/google-gemini/cookbook/issues/911\n", + "* **908**: quickstarts/Get_started_LiveAPI.py script doesn't work if using vertexai=True - https://github.com/google-gemini/cookbook/issues/908\n", + "* **907**: Gemini 2.5 Flash Model Inconsistency Between API and Online Interface (Spatial Understanding) - https://github.com/google-gemini/cookbook/issues/907\n", + "* **906**: Gemini Live API - Websocket Tool Call Response - BidiGenerateContentToolResponse - https://github.com/google-gemini/cookbook/issues/906\n", + "* **898**: Security Policy violation Branch Protection - https://github.com/google-gemini/cookbook/issues/898\n", + "* **887**: I've added a new example notebook that demonstrates how you can use t… (Pull Request) - https://github.com/google-gemini/cookbook/pull/887\n", + "* **883**: Monthly issue metrics report - https://github.com/google-gemini/cookbook/issues/883\n", + "* **878**: Added `Video_understanding` notebook for JavaScript (Pull Request) - https://github.com/google-gemini/cookbook/pull/878\n", + "* **877**: Added `PDF_Files` notebook for JavaScript (Pull Request) - https://github.com/google-gemini/cookbook/pull/877\n", + "* **876**: Added `Get_started_imagen` notebook for JavaScript (Pull Request) - https://github.com/google-gemini/cookbook/pull/876\n", + "* **875**: Added `Enum` notebook for JavaScript (Pull Request) - https://github.com/google-gemini/cookbook/pull/875\n", + "* **872**: Fix DeprecationWarning - https://github.com/google-gemini/cookbook/issues/872\n", + "* **862**: Added `Grounding` notebook for JavaScript (Pull Request) - https://github.com/google-gemini/cookbook/pull/862\n", + "* **861**: Added `File_API` notebook for JS (Pull Request) - https://github.com/google-gemini/cookbook/pull/861\n", + "* **860**: Added `LearnLM` notebook for JS (Pull Request) - https://github.com/google-gemini/cookbook/pull/860\n", + "* **859**: Added `Audio.js` notebook for JS (Pull Request) - https://github.com/google-gemini/cookbook/pull/859\n", + "* **858**: Added `Counting tokens` notebook for JS (Pull Request) - https://github.com/google-gemini/cookbook/pull/858\n", + "* **857**: Added `Get_started_thinking` notebook for JS (Pull Request) - https://github.com/google-gemini/cookbook/pull/857\n", + "* **854**: Added \"JSON_mode\" notebook for javascript (Pull Request) - https://github.com/google-gemini/cookbook/pull/854\n", + "* **848**: Missing Batch Jobs Monitoring Interface in Google AI Studio - https://github.com/google-gemini/cookbook/issues/848\n", + "* **828**: Created conversation_agents_livekit_gemini.py (Pull Request) - https://github.com/google-gemini/cookbook/pull/828\n", + "* **824**: Modifications to led controller example (Pull Request) - https://github.com/google-gemini/cookbook/pull/824\n", + "* **823**: Monthly issue metrics report - https://github.com/google-gemini/cookbook/issues/823\n", + "* **820**: ValidationError when using img.thumbnail() in Spatial Understanding notebook - https://github.com/google-gemini/cookbook/issues/820\n", + "* **812**: Deep research (Pull Request) - https://github.com/google-gemini/cookbook/pull/812\n", + "* **810**: Add a quick multi-file example (Pull Request) - https://github.com/google-gemini/cookbook/pull/810\n", + "* **808**: Testing a PR with an unformatted file (Pull Request) - https://github.com/google-gemini/cookbook/pull/808\n", + "* **802**: I've added a new JavaScript function called `parseQueryString` to `ex… (Pull Request) - https://github.com/google-gemini/cookbook/pull/802\n", + "* **799**: Summarization example that uses FlashLite - https://github.com/google-gemini/cookbook/issues/799\n", + "* **798**: image segmentation Not Working in quickstarts/Spatial_understanding.ipynb - https://github.com/google-gemini/cookbook/issues/798\n", + "* **796**: activityHandling NO_INTERRUPTION not being respected. - https://github.com/google-gemini/cookbook/issues/796\n", + "* **795**: Add notebooks for recent features: Live, Ephemeral tokens, Multispeaker - https://github.com/google-gemini/cookbook/issues/795\n", + "* **792**: Create jekyll-gh-pages.yml (Pull Request) - https://github.com/google-gemini/cookbook/pull/792\n", + "* **790**: Sketch2Paint using Gemini (Pull Request) - https://github.com/google-gemini/cookbook/pull/790\n", + "* **787**: set custom fps not working? - https://github.com/google-gemini/cookbook/issues/787\n", + "* **783**: Live Stream Support for Gemini TTS - https://github.com/google-gemini/cookbook/issues/783\n", + "* **778**: Streaming in speech generation is not working - https://github.com/google-gemini/cookbook/issues/778\n", + "* **766**: Suggestion to include Gemini LIVE API Bidirectional Audio in React Native - https://github.com/google-gemini/cookbook/issues/766\n", + "* **763**: Update devcontainer.json (Pull Request) - https://github.com/google-gemini/cookbook/pull/763\n", + "* **760**: Audio_Music_code_analyst.ipynb examples (Pull Request) - https://github.com/google-gemini/cookbook/pull/760\n", + "* **759**: [example] Fast Multi-document rag using Qdrant Binary Quantization and Gemini 2.5 flash (Pull Request) - https://github.com/google-gemini/cookbook/pull/759\n", + "* **750**: Sketch2Paint - A web app demo that converts sketches into beautiful paintings - https://github.com/google-gemini/cookbook/issues/750\n", + "* **749**: Enhancing the Gemini Cookbook examples folder to improve developers comprehension - https://github.com/google-gemini/cookbook/issues/749\n", + "* **745**: Inconsistent Use of Contracted and Non-Contracted Verb Forms - https://github.com/google-gemini/cookbook/issues/745\n", + "* **738**: Add complex Json Example (Pull Request) - https://github.com/google-gemini/cookbook/pull/738\n", + "* **736**: 📘 Request to explore Gemini Example - GSoC 2025 - https://github.com/google-gemini/cookbook/issues/736\n", + "* **735**: Offering assistance - https://github.com/google-gemini/cookbook/issues/735\n", + "* **733**: Refer to timestamps audio feature is wildly inaccurate for Gemini 2.0 models - https://github.com/google-gemini/cookbook/issues/733\n", + "* **728**: Add `Add_prefixes.ipynb` into examples/prompting (Pull Request) - https://github.com/google-gemini/cookbook/pull/728\n", + "* **722**: thinking_budget=0 does not work, - https://github.com/google-gemini/cookbook/issues/722\n", + "* **715**: Proposal: Example Notebook for Async ADK Task Orchestration via GenAI - https://github.com/google-gemini/cookbook/issues/715\n", + "* **707**: PR Update: Addressed Feedback - Gemini Multimodal Chatbot Tutorial (Issue #549) (Pull Request) - https://github.com/google-gemini/cookbook/pull/707\n", + "* **704**: Feat: Add basic error handling to Barista Bot chat loop (Pull Request) - https://github.com/google-gemini/cookbook/pull/704\n", + "* **701**: BatchPredictor: Efficient Long-Context Processing with Parallel Chunk Processing and Answer Synthesis - https://github.com/google-gemini/cookbook/issues/701\n", + "* **690**: Add Cookbook Example: Scalable Cross-Media Recommendation System using Gemini + Qdrant - https://github.com/google-gemini/cookbook/issues/690\n", + "* **689**: Added new notebook Basic_Code_Review to examples (Pull Request) - https://github.com/google-gemini/cookbook/pull/689\n", + "* **686**: Added Langchain_With_Gemini_And_Build_RAG (Pull Request) - https://github.com/google-gemini/cookbook/pull/686\n", + "* **684**: Add example Extract_Information_From_INVOICE (Pull Request) - https://github.com/google-gemini/cookbook/pull/684\n", + "* **680**: Live examples should use the interrupted message to clear the audio buffer, not turn_complete. - https://github.com/google-gemini/cookbook/issues/680\n", + "* **667**: New example ( Plant Health Diagnosis System ) (Pull Request) - https://github.com/google-gemini/cookbook/pull/667\n", + "* **666**: Add new Example (Social Media Caption Generator) (Pull Request) - https://github.com/google-gemini/cookbook/pull/666\n", + "* **665**: Added example Podcast_and_Audio_Transcription (Pull Request) - https://github.com/google-gemini/cookbook/pull/665\n", + "* **651**: New Cookbook Example - Outfit Recommendation - https://github.com/google-gemini/cookbook/issues/651\n", + "* **650**: Add new example (Pull Request) - https://github.com/google-gemini/cookbook/pull/650\n", + "* **643**: Updated Providing_base_cases.ipynb to use google-genai (Pull Request) - https://github.com/google-gemini/cookbook/pull/643\n", + "* **637**: Update package to google-genai in examples/Search_reranking_using_embeddings.ipynb (Pull Request) - https://github.com/google-gemini/cookbook/pull/637\n", + "* **635**: How to save a model with the new Google GenAI SDK? - https://github.com/google-gemini/cookbook/issues/635\n", + "* **614**: Add Cookbook Notebook for Function Calling and Text Embeddings Demonstration (Pull Request) - https://github.com/google-gemini/cookbook/pull/614\n", + "* **608**: Gemini Chatbot Tutorial – Interactive Chat with Streaming & History #547 (Pull Request) - https://github.com/google-gemini/cookbook/pull/608\n", + "* **604**: feat: Update Search_Wikipedia_using_ReAct.ipynb notebook to use google-genai SDK (Pull Request) - https://github.com/google-gemini/cookbook/pull/604\n", + "* **603**: Challenges in Running a Fine-Tuned Gemini Model with Multi-Agent Frameworks - https://github.com/google-gemini/cookbook/issues/603\n", + "* **602**: Batch Prediction with Long Context and Context Caching using Google Gemini API in Colab - #550 (Pull Request) - https://github.com/google-gemini/cookbook/pull/602\n", + "* **593**: Updated examples/Voice_memos.ipynb to use google-genai SDK (Pull Request) - https://github.com/google-gemini/cookbook/pull/593\n", + "* **581**: Adding RAG example with LangChain and BigQuery as Vector Store - https://github.com/google-gemini/cookbook/issues/581\n", + "* **574**: poem generation and qa bot using gemini function calling (Pull Request) - https://github.com/google-gemini/cookbook/pull/574\n", + "* **569**: Enhance Error Handling in callGemini and other Functions - https://github.com/google-gemini/cookbook/issues/569\n", + "* **565**: Cannot send cached content to a batch job. - https://github.com/google-gemini/cookbook/issues/565\n", + "* **561**: Expand Browser_as_a_tool.ipynb to a Multi-Tool Agent Workflow Framework using Gemini API - https://github.com/google-gemini/cookbook/issues/561\n", + "* **552**: Added text image multimodal bot - ISSUE 549 (Pull Request) - https://github.com/google-gemini/cookbook/pull/552\n", + "* **550**: [New Tutorial] Batch Prediction with Long Context and Context Caching using Google Gemini API in Colab - https://github.com/google-gemini/cookbook/issues/550\n", + "* **549**: [New Tutorial] End-to-End Multimodal Chatbot with Gemini API: Combined Vision and Text Processing - https://github.com/google-gemini/cookbook/issues/549\n", + "* **547**: Add New Tutorials for Gemini API Use Cases - https://github.com/google-gemini/cookbook/issues/547\n", + "* **545**: Adding Rust Implimentation 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", + "* **449**: Gemini 2.0 Flash structured output value repetition and missing fields - https://github.com/google-gemini/cookbook/issues/449\n", + "* **446**: Update everything to use google-genai SDK - https://github.com/google-gemini/cookbook/issues/446\n", + "* **393**: google.generativeai: tools don't work with JSON mode - https://github.com/google-gemini/cookbook/issues/393\n", + "* **391**: Auto format notebooks (Pull Request) - https://github.com/google-gemini/cookbook/pull/391\n", + "* **386**: I get Error with CONFIG = {\"generation_config\": {\"response_modalities\": [\"AUDIO\",\"TEXT\"]}} in gemini-2/live_api_starter.py - https://github.com/google-gemini/cookbook/issues/386\n", + "* **368**: Bug Report: The model frequently generates repetitive token sequences. - https://github.com/google-gemini/cookbook/issues/368\n", + "* **356**: live_api_starter.py under gemini-2 directory, keeps interrupting itself without getting interrupted - https://github.com/google-gemini/cookbook/issues/356\n", + "* **354**: Structured JSON output key ordering issue causes incorrect reasoning steps - https://github.com/google-gemini/cookbook/issues/354\n", + "* **331**: Blank responses via API with BLOCK_NONE set on all categories - https://github.com/google-gemini/cookbook/issues/331\n", + "* **321**: Portkey AI integration with Gemini (Pull Request) - https://github.com/google-gemini/cookbook/pull/321\n", + "* **320**: Portkey AI cookbook with Gemini - https://github.com/google-gemini/cookbook/issues/320\n", + "* **319**: Using tuning model in Nodejs Cloud Function - https://github.com/google-gemini/cookbook/issues/319\n", + "* **318**: Add Project IDX support (Pull Request) - https://github.com/google-gemini/cookbook/pull/318\n", + "* **292**: Add Data Commons example. (Pull Request) - https://github.com/google-gemini/cookbook/pull/292\n", + "* **279**: Use `path.join` for File API JS sample (Pull Request) - https://github.com/google-gemini/cookbook/pull/279\n", + "* **469**: Lets get a sample of standard retry logic with exponential backoff, etc. - https://github.com/google-gemini/cookbook/issues/469\n", + "* **220**: Bug Report the model often starts creating repetitive sequences of tokens - https://github.com/google-gemini/cookbook/issues/220\n", + "* **187**: Add a notebook test script. (Pull Request) - https://github.com/google-gemini/cookbook/pull/187\n", + "* **156**: Enhance Function_calling.ipynb cookbook - https://github.com/google-gemini/cookbook/issues/156\n", + "* **100**: Security Policy violation Branch Protection - https://github.com/google-gemini/cookbook/issues/100\n", + "* **47**: Streaming Function Calls - https://github.com/google-gemini/cookbook/issues/47\n", + "* **45**: Example demonstrating how to resume an upload - https://github.com/google-gemini/cookbook/issues/45\n" + ] + } + ], + "source": [ + "chat = client.chats.create(\n", + " model=MODEL_ID,\n", + " config={\n", + " \"tools\": [get_github_issues]\n", + " }\n", + ")\n", + "\n", + "response = chat.send_message(\"Show me the open issues in the google-gemini/cookbook.\")\n", + "\n", + "print(response.text)" + ] + }, + { + "cell_type": "markdown", + "id": "fa9bc6a4", + "metadata": { + "id": "fe59bdc48c66" + }, + "source": [ + "You can ask the model for other types of analysis such as what are the best issues to start from as a beginner,what are the most pressing issues I should look at. " + ] + }, + { + "cell_type": "markdown", + "id": "72b6ef37", + "metadata": { + "id": "705ca619f832" + }, + "source": [ + "### Next Steps\n", + "\n", + "- Learn more about PyGithub from the [PyGithub Docs](https://pygithub.readthedocs.io/en/stable/).\n", + "- You some of your own tools the GitHub API has a vast range of functionalities such a as create_github_issue(),List_pll_requests(),get_issues_comments. " + ] + } + ], + "metadata": { + "colab": { + "name": "GitHub_issues_analyzer.ipynb", + "toc_visible": true + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} From 380224e5a7b2c00b569ffd36e913c13662ae87eb Mon Sep 17 00:00:00 2001 From: ROHAN DWIVEDI Date: Fri, 29 Aug 2025 19:29:47 +0530 Subject: [PATCH 2/5] Updated notebook --- examples/GitHub_issues_analyzer.ipynb | 34 ++++++++++----------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/examples/GitHub_issues_analyzer.ipynb b/examples/GitHub_issues_analyzer.ipynb index 52fda7b5f..b0b583520 100644 --- a/examples/GitHub_issues_analyzer.ipynb +++ b/examples/GitHub_issues_analyzer.ipynb @@ -120,7 +120,7 @@ "id": "02d1b126d613" }, "source": [ - "### Setup up yout API key\n", + "### Setup up your API key\n", "To run the following cell, your API key must be stored 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** quickstart for an example.\n", "\n", "You will also need a GitHub Personal Access Token stored as a Colab Secret named **GITHUB_API_KEY**. \n", @@ -148,7 +148,7 @@ "from google.colab import userdata\n", "\n", "\n", - "GOOGLE_API_KEY=userdata.get('GOOGLE_API_KEY')\n", + "GOOGLE_API_KEY = userdata.get('GOOGLE_API_KEY')\n", "GITHUB_API_KEY = userdata.get(\"GITHUB_API_KEY\")\n", "\n", "client = genai.Client(api_key=GOOGLE_API_KEY)" @@ -202,30 +202,20 @@ "\n", "\n", "def get_github_issues(repository_name: str):\n", - " \"\"\"\n", - " Gets the open issues for a given GitHub repository.\n", - "\n", - " Args:\n", - " repository_name: The name of the repository in the format 'owner/repo'.\n", " \n", - " Returns:\n", - " A list of dictionaries, where each dictionary represents an issue and contains its title, number, and URL.\n", - " \"\"\"\n", " try:\n", " repo = g.get_repo(repository_name)\n", " issues = repo.get_issues(state='open')\n", - " \n", - " issue_list = []\n", - " for issue in issues:\n", - " issue_list.append({\n", - " 'title': issue.title,\n", - " 'number': issue.number,\n", - " 'url': issue.html_url\n", - " })\n", - " return issue_list\n", + " return [{\n", + " 'title': issue.title,\n", + " 'number': issue.number,\n", + " 'url': issue.html_url\n", + " } for issue in issues]\n", + "\n", "\n", " except Exception as e:\n", - " return {\"error\": f\"An error occurred: {e}\"}" + " print(f\"An error occurred: {e}\")\n", + " return []" ] }, { @@ -385,7 +375,7 @@ "id": "fe59bdc48c66" }, "source": [ - "You can ask the model for other types of analysis such as what are the best issues to start from as a beginner,what are the most pressing issues I should look at. " + "You can ask the model for other types of analysis, such as what are the best issues to start from as a beginner, or what are the most pressing issues you should look at. " ] }, { @@ -398,7 +388,7 @@ "### Next Steps\n", "\n", "- Learn more about PyGithub from the [PyGithub Docs](https://pygithub.readthedocs.io/en/stable/).\n", - "- You some of your own tools the GitHub API has a vast range of functionalities such a as create_github_issue(),List_pll_requests(),get_issues_comments. " + "- You can add some of your own tools. The GitHub API has a vast range of functionalities such as `create_github_issue()`, `list_pull_requests()`, and `get_issues_comments()`. " ] } ], From fabe7c20d00820e66a96caffa7da5c8b879ec3da Mon Sep 17 00:00:00 2001 From: Rohan Dwivedi <165134541+ROHANDWIVEDI2005@users.noreply.github.com> Date: Sat, 6 Sep 2025 19:47:23 +0530 Subject: [PATCH 3/5] Update README.md --- examples/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/README.md b/examples/README.md index 8eaf856b7..feb5c75f6 100644 --- a/examples/README.md +++ b/examples/README.md @@ -30,6 +30,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 issues analyzer](./GitHub_issues_analyzer.ipynb) | Use Gemini API function calling to interact with the GitHub API to analyze GitHub issues | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/examples/GitHub_issues_analyzer.ipynb) | ---
@@ -67,3 +68,4 @@ Some old examples are still using the legacy SDK, they should still work and are * [JSON Capabilities](./json_capabilities/): A directory with guides containing different types of tasks you can do with JSON schemas. * [Automate Google Workspace tasks with the Gemini API](./Apps_script_and_Workspace_codelab/): This codelabs shows you how to connect to the Gemini API using Apps Script, and uses the function calling, vision and text capabilities to automate Google Workspace tasks - summarizing a document, analyzing a chart, sending an email and generating some slides directly. All of this is done from a free text input. * [Langchain examples](./langchain/): A directory with multiple examples using Gemini with Langchain. + From 4e60c4d99d508745019655f4ad4606a94dd39e11 Mon Sep 17 00:00:00 2001 From: Rohan Dwivedi <165134541+ROHANDWIVEDI2005@users.noreply.github.com> Date: Sat, 6 Sep 2025 19:51:49 +0530 Subject: [PATCH 4/5] Update README.md --- examples/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/README.md b/examples/README.md index feb5c75f6..41baf82b3 100644 --- a/examples/README.md +++ b/examples/README.md @@ -30,7 +30,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 issues analyzer](./GitHub_issues_analyzer.ipynb) | Use Gemini API function calling to interact with the GitHub API to analyze GitHub issues | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/examples/GitHub_issues_analyzer.ipynb) | +| [GitHub issues analyzer](./GitHub_issues_analyzer.ipynb) | Use Gemini API function calling to interact with the GitHub API to analyze GitHub issues | Function Calling | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/examples/GitHub_issues_analyzer.ipynb) | ---
@@ -69,3 +69,4 @@ Some old examples are still using the legacy SDK, they should still work and are * [Automate Google Workspace tasks with the Gemini API](./Apps_script_and_Workspace_codelab/): This codelabs shows you how to connect to the Gemini API using Apps Script, and uses the function calling, vision and text capabilities to automate Google Workspace tasks - summarizing a document, analyzing a chart, sending an email and generating some slides directly. All of this is done from a free text input. * [Langchain examples](./langchain/): A directory with multiple examples using Gemini with Langchain. + From 4d1fa6067a033e9cdda48e95245d1aeabb5a2dbe Mon Sep 17 00:00:00 2001 From: ROHAN DWIVEDI Date: Thu, 18 Sep 2025 15:56:05 +0530 Subject: [PATCH 5/5] update --- examples/GitHub_issues_analyzer.ipynb | 4 ++++ examples/README.md | 1 + 2 files changed, 5 insertions(+) diff --git a/examples/GitHub_issues_analyzer.ipynb b/examples/GitHub_issues_analyzer.ipynb index b0b583520..95b160b19 100644 --- a/examples/GitHub_issues_analyzer.ipynb +++ b/examples/GitHub_issues_analyzer.ipynb @@ -400,6 +400,10 @@ "kernelspec": { "display_name": "Python 3", "name": "python3" + }, + "language_info": { + "name": "python", + "version": "3.13.3" } }, "nbformat": 4, diff --git a/examples/README.md b/examples/README.md index 8eaf856b7..6572a485f 100644 --- a/examples/README.md +++ b/examples/README.md @@ -51,6 +51,7 @@ Some old examples are still using the legacy SDK, they should still work and are * [Translate a public domain](./Translate_a_Public_Domain_Book.ipynb): In this notebook, you will explore Gemini model as a translation tool, demonstrating how to prepare data, create effective prompts, and save results into a `.txt` file. * [Working with Charts, Graphs, and Slide Decks](./Working_with_Charts_Graphs_and_Slide_Decks.ipynb): Gemini models are powerful multimodal LLMs that can process both text and image inputs. This notebook shows how Gemini Flash model is capable of extracting data from various images. * [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. +* [GitHub issues analyzer](./GitHub_issues_analyzer.ipynb):In this notebook you will use the PyGithub library to analyze issues in a repository with the help of the gemini api.

### Integrations