fix: remaning issues with interactions API across quickstarts#1276
fix: remaning issues with interactions API across quickstarts#1276Giom-V wants to merge 15 commits into
Conversation
…_config across quickstarts
|
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 addresses a breaking change in the API by renaming a configuration parameter across several documentation notebooks. By updating these calls to use the correct 'generation_config' keyword, the notebooks will now execute correctly without encountering keyword argument errors. 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 the 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 counterproductive. 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 modifies the quickstarts/Get_started_thinking.ipynb notebook by renaming the config parameter to generation_config across multiple client.interactions.create() calls. The reviewer correctly notes that this change violates the repository's style guide and will cause a runtime TypeError because the google-genai SDK expects the config parameter. It is recommended to revert these parameter changes back to config as suggested.
| " model=MODEL_ID,\n", | ||
| " input=prompt,\n", | ||
| " config=types.GenerateContentConfig(\n", | ||
| " generation_config=types.GenerateContentConfig(\n", |
There was a problem hiding this comment.
The client.interactions.create() method in the google-genai SDK expects the parameter name config to pass configuration options (such as GenerateContentConfig), not generation_config. Changing this parameter to generation_config will result in a TypeError: create() got an unexpected keyword argument 'generation_config' at runtime.
Please revert this change to use config as specified in the SDK and the repository's style guide.
| " generation_config=types.GenerateContentConfig(\n", | |
| " config=types.GenerateContentConfig(\n", |
References
- The repository style guide specifies that
client.interactions.create()should be called with theconfigparameter. (link)
| " model=MODEL_ID,\n", | ||
| " input=prompt,\n", | ||
| " config=types.GenerateContentConfig(\n", | ||
| " generation_config=types.GenerateContentConfig(\n", |
There was a problem hiding this comment.
| " model=MODEL_ID,\n", | ||
| " input=prompt,\n", | ||
| " config=types.GenerateContentConfig(\n", | ||
| " generation_config=types.GenerateContentConfig(\n", |
There was a problem hiding this comment.
| " model=MODEL_ID,\n", | ||
| " input=[geometry_image, prompt],\n", | ||
| " config=types.GenerateContentConfig(\n", | ||
| " generation_config=types.GenerateContentConfig(\n", |
There was a problem hiding this comment.
| " \"How do I use those three pool balls to sum up to 30?\"\n", | ||
| " ],\n", | ||
| " config=types.GenerateContentConfig(\n", | ||
| " generation_config=types.GenerateContentConfig(\n", |
There was a problem hiding this comment.
| " model=MODEL_ID,\n", | ||
| " input=prompt,\n", | ||
| " config=types.GenerateContentConfig(\n", | ||
| " generation_config=types.GenerateContentConfig(\n", |
There was a problem hiding this comment.
| " model=MODEL_ID,\n", | ||
| " input=prompt,\n", | ||
| " config=types.GenerateContentConfig(\n", | ||
| " generation_config=types.GenerateContentConfig(\n", |
There was a problem hiding this comment.
| " model=MODEL_ID,\n", | ||
| " input=prompt,\n", | ||
| " config=types.GenerateContentConfig(\n", | ||
| " generation_config=types.GenerateContentConfig(\n", |
There was a problem hiding this comment.
| " model=MODEL_ID,\n", | ||
| " input=prompt,\n", | ||
| " config=types.GenerateContentConfig(\n", | ||
| " generation_config=types.GenerateContentConfig(\n", |
There was a problem hiding this comment.
| " model=GEMINI_3_MODEL_ID,\n", | ||
| " input=prompt,\n", | ||
| " config=types.GenerateContentConfig(\n", | ||
| " generation_config=types.GenerateContentConfig(\n", |
There was a problem hiding this comment.
…_started_Lyria.ipynb
…ure robust step iteration in Lyria
…config parameters across quickstarts
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates several quickstart notebooks to align with the new google-genai SDK patterns, including migrating to the interactions API and updating configuration structures. However, the changes introduce numerous critical syntax errors across the notebooks, primarily due to missing closing parentheses in client.interactions.create and types.GenerateContentConfig calls, as well as malformed dictionary syntax in agent_config. Additionally, using locals() to check for variable existence in Get_started_Veo.ipynb is highlighted as an anti-pattern that should be refactored.
| " generation_config=types.GenerateContentConfig(\n", | ||
| " thinking_level=types.ThinkingLevel.HIGH,\n", | ||
| "\n", |
| " generation_config=types.GenerateContentConfig(\n", | ||
| " thinking_level=thinking_level,\n", | ||
| " include_thoughts=True\n", | ||
| " )\n", | ||
| " )\n", | ||
| ")" | ||
| " thinking_summaries=\"auto\"\n" |
| " input=prompt\n", | ||
| ")\n", | ||
| "\n", |
| " generation_config=types.GenerateContentConfig(\n", | ||
| " thinking_level=\"minimal\",\n", | ||
| "\n", |
| " generation_config=types.GenerateContentConfig(\n", | ||
| " thinking_level=\"minimal\",\n", | ||
| "\n", |
| " generation_config=types.GenerateContentConfig(\n", | ||
| " thinking_level=types.ThinkingLevel.HIGH,\n", | ||
| "\n", |
| " generation_config=types.GenerateContentConfig(\n", | ||
| " thinking_summaries=\"auto\"\n" |
| "code_execution_tool = types.Tool(\n", | ||
| " code_execution=types.ToolCodeExecution()\n", | ||
| ")\n", | ||
| "\n", | ||
| "interaction = client.interactions.create(\n", | ||
| " model=MODEL_ID,\n", | ||
| " input=prompt,\n", | ||
| " config=types.GenerateContentConfig(\n", | ||
| " tools=[code_execution_tool],\n", | ||
| " thinking_config=types.ThinkingConfig(\n", | ||
| " generation_config=types.GenerateContentConfig(\n", | ||
| " thinking_level=thinking_level,\n", | ||
| " )\n", | ||
| " ),\n", | ||
| ")" | ||
| " ),\n" |
There was a problem hiding this comment.
The closing parentheses for both types.Tool(...) and client.interactions.create(...) are missing, which will cause a SyntaxError.
code_execution_tool = types.Tool(
code_execution=types.ToolCodeExecution()
)
interaction = client.interactions.create(
model=MODEL_ID,
input=prompt,
generation_config=types.GenerateContentConfig(
thinking_level=thinking_level,
),
)
| " generation_config=types.GenerateContentConfig(\n", | ||
| " thinking_level=types.ThinkingLevel.MINIMAL,\n", | ||
| "\n", |
| " resolution=resolution,\n", | ||
| " negative_prompt=negative_prompt,\n", | ||
| " last_frame=ending_image\n", | ||
| " last_frame=ending_image if 'ending_image' in locals() else None\n", |
There was a problem hiding this comment.
Using 'ending_image' in locals() to check if a variable is defined is generally considered an anti-pattern in Python. It is much cleaner and more maintainable to define ending_image = None at the beginning of the notebook or in the setup section of the cell, and then simply pass last_frame=ending_image.
last_frame=ending_image
…nana, Get_started, PDF_Files, Grounding, Search_Grounding, and Robotics-ER notebooks
…gents, Veo, and Search Grounding quickstarts
…ounding, and Grounding quickstarts
…ol corrections across quickstarts
…cross quickstarts
…g corrections across quickstarts
…ContentConfig corrections across quickstarts
…eContentConfig syntax corrections across quickstarts
…ast syntax pre-checker to test runner
This PR corrects the parameter name from
configtogeneration_configinclient.interactions.create()acrossGet_Started_Nano_Banana.ipynb,Get_started_TTS.ipynb, andGet_started_thinking.ipynb, resolving unexpected keyword argument TypeErrors.