Skip to content

Conversation

ROHANDWIVEDI2005
Copy link
Contributor

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@github-actions github-actions bot added status:awaiting review PR awaiting review from a maintainer component:examples Issues/PR referencing examples folder labels Aug 29, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @ROHANDWIVEDI2005, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new, fully functional example notebook that showcases a practical application of the Gemini API's function calling feature by integrating it with the GitHub API. The example simplifies the process of querying GitHub issues programmatically, providing a clear and runnable demonstration for users.

Highlights

  • New Example Notebook Added: A new Jupyter notebook, GitHub_issues_analyzer.ipynb, has been added to the examples directory.
  • Gemini API and GitHub API Integration: The notebook demonstrates how to use the Gemini API with function calling to interact with the GitHub API, specifically to retrieve open issues from a repository.
  • Improved API Key Setup Instructions: Enhanced explanations and steps are provided for setting up the GITHUB_API_KEY as a Colab Secret, including guidance on generating a GitHub Personal Access Token.
  • Notebook Validation: The entire notebook has been run and verified, and it has passed nbfmt checks, ensuring its functionality and adherence to formatting standards.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new example notebook, GitHub_issues_analyzer.ipynb, which is a great demonstration of using the Gemini API with function calling to interact with the GitHub API. The notebook is well-structured and provides a practical use case. My review includes feedback on several points to enhance code quality, correctness, and readability. I've pointed out some violations of the project's style guide, such as non-null execution counts and minor formatting inconsistencies. I've also suggested improvements to error handling and code conciseness in the Python tool function, and corrections for typos and grammatical errors in the markdown text.

Comment on lines 214 to 228
" 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}\"}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This function can be improved in a few ways:

  • Inconsistent return types: It returns a list on success but a dict on failure. This can cause runtime errors and confuse the model. It's better to return an empty list on error.
  • Use list comprehension: The for loop can be replaced with a more concise list comprehension, which is more Pythonic and aligns with the style guide's preference for brevity.1
  • Broad exception: The except Exception clause is too broad. While the suggestion below keeps it for simplicity, for a more robust implementation, you should consider catching specific exceptions from the PyGithub library (e.g., github.UnknownObjectException).

I've provided a suggestion that addresses the return type and uses a list comprehension.

    try:
        repo = g.get_repo(repository_name)
        issues = repo.get_issues(state='open')
        return [{
            'title': issue.title,
            'number': issue.number,
            'url': issue.html_url
        } for issue in issues]
    except Exception as e:
        print(f"An error occurred: {e}")
        return []

Style Guide References

Footnotes

},
{
"cell_type": "code",
"execution_count": 1,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The execution_count for this cell is 1, not null. According to the style guide, this indicates that the notebook formatting script (nbfmt) may not have been run before submission. Please run the formatter to reset all execution counts to null.1 I've noticed this in other cells as well, but am only commenting once per the style guide.

Style Guide References

Footnotes

"id": "02d1b126d613"
},
"source": [
"### Setup up yout API key\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This heading contains a typo ("yout" instead of "your"), is redundant ("Setup up"), and does not follow the sentence case convention from the style guide.1

Suggested change
"### Setup up yout API key\n",
### Set up your API key\n

Style Guide References

Footnotes

Comment on lines 151 to 152
"GOOGLE_API_KEY=userdata.get('GOOGLE_API_KEY')\n",
"GITHUB_API_KEY = userdata.get(\"GITHUB_API_KEY\")\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The code style here is inconsistent. Line 151 uses single quotes and no spaces around =, while line 152 uses double quotes and spaces. For consistency and adherence to PEP 8, please use the same quote style and include spaces around the assignment operator.1

GOOGLE_API_KEY = userdata.get('GOOGLE_API_KEY')
GITHUB_API_KEY = userdata.get('GITHUB_API_KEY')

Style Guide References

Footnotes

"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. "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This sentence has some grammatical and punctuation issues that make it hard to read. It should be broken up for clarity.

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. 

"### 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. "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This sentence has several typos and grammatical errors. "You some" should be "You can add", "such a as" should be "such as", and "List_pll_requests" seems to be a typo. Also, function names should be formatted as code for better readability.1

- 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()`. 

Style Guide References

Footnotes

Copy link
Contributor

Thanks for tagging me! I've reviewed the changes in examples/GitHub_issues_analyzer.ipynb. The new notebook looks good and the added explanation for GITHUB_API_KEY is a helpful improvement.

Let me know if you have any further questions or if there's anything else I can assist with regarding this pull request!

@ROHANDWIVEDI2005
Copy link
Contributor Author

@gemini-code-assist review this notebook

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a new example notebook, GitHub_issues_analyzer.ipynb, demonstrating how to use the Gemini API with function calling to interact with the GitHub API. The notebook is well-structured and provides a clear example. My feedback includes suggestions to align with the project's style guide, such as running the notebook formatter to clear execution counts and fixing a typo in a heading. I've also recommended improvements for code quality and robustness, like adding a docstring and return type hints to the function, and using more specific exception handling. These changes will enhance the notebook's clarity, maintainability, and adherence to best practices.

Comment on lines +204 to +205
"def get_github_issues(repository_name: str):\n",
" \n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This function is missing a docstring and a return type hint. For function calling, a descriptive docstring is crucial for the model to understand the function's purpose and arguments.[^1] Adding a return type hint also improves code clarity.[^2]

Suggested change
"def get_github_issues(repository_name: str):\n",
" \n",
"def get_github_issues(repository_name: str) -> list[dict]:\n",
" \"\"\"Gets the open issues for a given GitHub repository.\"\"\"\n",

},
{
"cell_type": "code",
"execution_count": 1,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The execution_count for this cell is non-null. According to the style guide, this indicates that the notebook formatting script (nbfmt) may not have been run. Please run the formatter to clear execution counts and ensure consistency.1

Style Guide References

Footnotes

"id": "02d1b126d613"
},
"source": [
"### Setup up your API key\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There is a typo in this heading. It should be "Set up" instead of "Setup up".

Suggested change
"### Setup up your API key\n",
"### Set up your API key\n",

},
"outputs": [],
"source": [
"from github import Github\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To handle GitHub-specific errors gracefully in the get_github_issues function, it's best to import and catch GithubException.

Suggested change
"from github import Github\n",
"from github import Github, GithubException\n",

" } for issue in issues]\n",
"\n",
"\n",
" except Exception as e:\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Catching a broad Exception can hide bugs and make debugging harder. It's better to catch a more specific exception, like GithubException, which you can import from the PyGithub library.

Suggested change
" except Exception as e:\n",
" except GithubException as e:\n",

@ROHANDWIVEDI2005
Copy link
Contributor Author

Added link in the readme

…01424736a84adf2424c48ccf71/?path=a424e687&cell_index=3&sha=52fda7b5f43b33d6e3a0eef1530492a4a1f3b85ahttps://app.reviewnb.com/google-gemini/cookbook/commit/581d32209983d301424736a84adf2424c48ccf71/?path=a424e687&cell_index=3&sha=52fda7b5f43b33d6e3a0eef1530492a4a1f3b85a

Merge branch 'PyGithub-Example' of https://github.com/ROHANDWIVEDI2005/cookbook into PyGithub-Example
"TO resolve a conflict"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:examples Issues/PR referencing examples folder status:awaiting review PR awaiting review from a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant