Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Summary of ChangesHello, 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 Jupyter Notebook that functions as an interactive onboarding guide for the Gemini API. It provides a practical, step-by-step approach to understanding and utilizing various Gemini API capabilities by developing a children's storybook generator. The guide covers essential concepts from basic text generation to advanced multimodal outputs and structured data handling, offering a hands-on learning experience. Highlights
Using Gemini Code AssistThe 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 by creating a comment using either
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 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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new onboarding guide notebook for the Gemini API, focusing on building a children's storybook generator. The notebook effectively demonstrates basic prompting, error handling with retries, structured outputs using Pydantic, search grounding, and multimodal generation with Imagen and Veo. The overall structure and progression of the guide are well-conceived and didactic. However, there are several opportunities to improve adherence to the repository's style guide, particularly concerning notebook outputs, import placement, and code formatting for multi-line strings and function arguments.
| "source": [ | ||
| "%pip install -U -q \"google-genai>=1.0.0\" pydantic tenacity" | ||
| ] |
There was a problem hiding this comment.
The code cells in this notebook do not have their outputs saved. The style guide specifies that outputs should ideally be saved in the notebooks so that readers can understand the code's functionality without needing to execute it themselves. Please run the notebook and save the outputs.
References
- Ideally we want the ouputs to be saved in the notebooks so that one can see what the code does without runnning it. (link)
| "import os\n", | ||
| "from google.colab import userdata\n", | ||
| "from google import genai\n", | ||
| "from google.genai import types\n", |
There was a problem hiding this comment.
The style guide recommends placing imports when they are first used, rather than grouping them all in a single cell at the beginning of the notebook. This approach enhances readability by showing dependencies closer to their usage.
References
- Put the imports when they are first used. Try to avoid having a big "import" cell at the beginning. (link)
| "metadata": {}, | ||
| "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}" |
There was a problem hiding this comment.
The MODEL_ID selector list is missing some of the latest models mentioned in the style guide's example. Expanding this list to include gemini-3.1-flash-lite-preview and gemini-3.1-pro-preview would provide users with more current options.
MODEL_ID = "gemini-2.5-flash" # @param ["gemini-2.5-flash-lite", "gemini-2.5-flash", "gemini-2.5-pro", "gemini-3.1-flash-lite-preview", "gemini-3-flash-preview", "gemini-3.1-pro-preview"] {"allow-input":true, isTemplate: true}
References
- When selecting a model, use a colab selector for easier maintainability: MODEL_ID="gemini-2.5-flash" # @param ["gemini-2.5-flash-lite", "gemini-2.5-flash", "gemini-2.5-pro", "gemini-3.1-flash-lite-preview", "gemini-3-flash-preview", "gemini-3.1-pro-preview"] {"allow-input":true, isTemplate: true} (link)
| "story_prompt = f\"\"\"\n", | ||
| " Create a 3-chapter story outline about this character:\n", | ||
| " {character_data['name']}, the {character_data['species']}.\n", | ||
| " Persona: {character_data['persona']}\n", | ||
| " \n", | ||
| " Chapter 3 should involve a trip to Paris during the Olympic Games.\n", |
There was a problem hiding this comment.
The indentation for triple-quoted strings does not fully adhere to the style guide. For improved readability, the closing triple quotes should be on a new, unindented line.
story_prompt = f"""
Create a 3-chapter story outline about this character:
{character_data['name']}, the {character_data['species']}.
Persona: {character_data['persona']}
Chapter 3 should involve a trip to Paris during the Olympic Games.
"""
References
- Long text variables should use triple double quotes and proper indentation for better readability: Notice the line break on the first and last lines. (link)
| " config=types.GenerateContentConfig(\n", | ||
| " response_mime_type=\"application/json\",\n", | ||
| " response_schema=Character,\n", | ||
| " temperature=0.7\n", | ||
| " )\n", |
There was a problem hiding this comment.
The indentation for multi-parameter function calls, specifically for the config dictionary, does not fully align with the style guide. The closing parenthesis of the function call should be on a new, unindented line for better readability.
config=types.GenerateContentConfig(
response_mime_type="application/json",
response_schema=Character,
temperature=0.7
)
References
- When a function has multiple parameters, expend it on multiple lines with proper indentation for better readability: Notice the line break on the first and last lines. (link)
No description provided.