-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Update syntax for function calling/controlled generation in intro to Gemini 2.0 notebook #1621
Conversation
…tro to Gemini 2.0 notebook
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi team,
I'm currently reviewing this pull request and will provide feedback shortly. In the meantime, here's a summary for you and other reviewers to quickly get up to speed:
This pull request, "chore: Update syntax for function calling/controlled generation in intro to Gemini 2.0 notebook", focuses on updating the syntax for function calling and controlled generation within the intro_gemini_2_0_flash.ipynb
notebook. The changes aim to improve clarity and efficiency in the examples provided.
Here's a breakdown of the changes:
- Improved Documentation Links: Several links to relevant documentation have been updated or clarified to ensure users can easily find additional information.
- Simplified Response Handling: The code for handling API responses has been streamlined. Instead of manually parsing JSON responses, the code now leverages the
parsed
field for a more direct and efficient approach. This is evident in changes around lines 886-890, 964-968, and 1229-1232. - Enhanced Function Call Output: The way function calls are printed has been modified for better readability and consistency. The change on lines 1229-1232 showcases this improvement.
- Added Additional Notebook Reference: A link to a supplementary notebook (
intro_multimodal_live_api_genai_sdk.ipynb
) has been added to provide users with more examples of the Multimodal Live API (lines 833-837).
The specific file impacted is gemini/getting-started/intro_gemini_2_0_flash.ipynb
. The changes are primarily focused on improving the user experience of the notebook by making the code cleaner and the documentation more accessible.
I'll have a more detailed review shortly, but this should give everyone a good overview of the changes.
And now, a little haiku to lighten the mood:
Code flows like a stream,
Clean syntax, a gentle breeze,
Bugs flee in the night.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR updates the syntax for function calling and controlled generation in the "Intro to Gemini 2.0" notebook, aligning it with the updated GenAI SDK. The changes improve clarity and demonstrate the preferred way to access structured outputs. The added explanations and resources are also valuable.
"For more examples with the Multimodal Live API, refer to the [documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/multimodal-live) or this notebook: [Getting Started with the Multimodal Live API using Gen AI SDK\n", | ||
"](https://github.com/GoogleCloudPlatform/generative-ai/blob/main/gemini/multimodal-live-api/intro_multimodal_live_api_genai_sdk.ipynb)." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line break within the markdown link makes the link broken. It's better to keep the link text and URL together on a single line for markdown links. Also, consider rephrasing for better flow.
"For more examples with the Multimodal Live API, refer to the [documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/multimodal-live) or this notebook: [Getting Started with the Multimodal Live API using Gen AI SDK\n", | |
"](https://github.com/GoogleCloudPlatform/generative-ai/blob/main/gemini/multimodal-live-api/intro_multimodal_live_api_genai_sdk.ipynb)." | |
For more examples with the Multimodal Live API, refer to the [documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/multimodal-live) or the [Getting Started with the Multimodal Live API using Gen AI SDK](https://github.com/GoogleCloudPlatform/generative-ai/blob/main/gemini/multimodal-live-api/intro_multimodal_live_api_genai_sdk.ipynb) notebook. |
"parsed_response: Recipe = response.parsed\n", | ||
"print(parsed_response)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the response is now parsed directly into an object, demonstrating manual JSON parsing might be less relevant here. Consider removing the example or moving it to a separate section dedicated to handling raw JSON responses.
"parsed_response: Recipe = response.parsed\n", | |
"print(parsed_response)" | |
parsed_response: Recipe = response.parsed | |
print(parsed_response) |
@@ -298,7 +298,7 @@ | |||
"source": [ | |||
"### Load the Gemini 2.0 Flash model\n", | |||
"\n", | |||
"To learn more about all [Gemini models on Vertex AI](https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#gemini-models)." | |||
"Learn more about all [Gemini models on Vertex AI](https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#gemini-models)." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor suggestion: This sentence could be slightly more concise. Consider "Learn more about all Gemini models on Vertex AI."
"Learn more about all [Gemini models on Vertex AI](https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#gemini-models)." | |
Learn more about all [Gemini models on Vertex AI](https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#gemini-models). |
"response_dict = response.parsed\n", | ||
"print(response_dict)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -1229,7 +1229,7 @@ | |||
" ),\n", | |||
")\n", | |||
"\n", | |||
"print(response.candidates[0].content.parts[0].function_call)" | |||
"print(response.function_calls[0])" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No description provided.