Skip to content
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

feat(genai, generative_ai): Migration of Gemini samples to 2.X models #13267

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

msampathkumar
Copy link
Member

@msampathkumar msampathkumar commented Mar 31, 2025

Migrate the Gemini Samples to 2.X

Majority of the required samples are created in genai folder which uses the latest GenAI SDK. In this PR, we are mostly clearing 1.X samples in generative_ai folder.

bugs: b/407554370
ref: cl/742330022 cl/743584467

@product-auto-label product-auto-label bot added samples Issues that are directly related to samples. api: discoveryengine Issues related to the Discovery Engine API API. labels Mar 31, 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.

Hello @msampathkumar, 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!

Summary of Changes

This pull request updates the Gemini samples by updating the model name from gemini-1.5-pro-001 and gemini-1.5-flash-002 to gemini-2.0-flash-001 in several files. It also removes old content cache samples and related test files.

Highlights

  • Model Name Update: The model name is updated to gemini-2.0-flash-001 in discoveryengine/answer_query_sample.py, discoveryengine/session_sample.py, generative_ai/batch_predict/gemini_batch_predict_bigquery.py, generative_ai/batch_predict/gemini_batch_predict_gcs.py, generative_ai/express_mode/api_key_example.py, and other files.
  • Content Cache Sample Removal: The pull request removes the old content cache samples, including genai/content_cache/contentcache_create_with_txt_gcs_pdf.py, genai/content_cache/contentcache_delete.py, genai/content_cache/contentcache_list.py, genai/content_cache/contentcache_update.py, genai/content_cache/contentcache_use_with_txt.py, genai/content_cache/noxfile_config.py, and genai/content_cache/test_content_cache_examples.py.

Changelog

Click here to see the changelog
  • discoveryengine/answer_query_sample.py
    • Updated model name from gemini-1.5-pro-001 to gemini-2.0-flash-001 in the header comment.
    • Updated model_version from gemini-1.5-flash-001/answer_gen/v2 to gemini-2.0-flash-001/answer_gen/v2.
  • discoveryengine/session_sample.py
    • Updated model name from gemini-1.5-pro-001 to gemini-2.0-flash-001 in the header comment.
  • genai/content_cache/contentcache_create_with_txt_gcs_pdf.py
    • Removed file.
  • genai/content_cache/contentcache_delete.py
    • Removed file.
  • genai/content_cache/contentcache_list.py
    • Removed file.
  • genai/content_cache/contentcache_update.py
    • Removed file.
  • genai/content_cache/contentcache_use_with_txt.py
    • Removed file.
  • genai/content_cache/noxfile_config.py
    • Removed file.
  • genai/content_cache/test_content_cache_examples.py
    • Removed file.
  • generative_ai/batch_predict/gemini_batch_predict_bigquery.py
    • Updated source_model from gemini-1.5-flash-002 to gemini-2.0-flash-001.
  • generative_ai/batch_predict/gemini_batch_predict_gcs.py
    • Updated source_model from gemini-1.5-flash-002 to gemini-2.0-flash-001.
  • generative_ai/context_caching/create_context_cache.py
    • Removed file.
  • generative_ai/context_caching/delete_context_cache.py
    • Removed file.
  • generative_ai/context_caching/get_context_cache.py
    • Removed file.
  • generative_ai/context_caching/list_context_caches.py
    • Removed file.
  • generative_ai/context_caching/noxfile_config.py
    • Removed file.
  • generative_ai/context_caching/requirements-test.txt
    • Removed file.
  • generative_ai/context_caching/requirements.txt
    • Removed file.
  • generative_ai/context_caching/test_context_caching.py
    • Removed file.
  • generative_ai/context_caching/update_context_cache.py
    • Removed file.
  • generative_ai/context_caching/use_context_cache.py
    • Removed file.
  • generative_ai/controlled_generation/controlled_generation_test.py
    • Removed file.
  • generative_ai/controlled_generation/example_01.py
    • Removed file.
  • generative_ai/controlled_generation/example_02.py
    • Removed file.
  • generative_ai/controlled_generation/example_03.py
    • Removed file.
  • generative_ai/controlled_generation/example_04.py
    • Removed file.
  • generative_ai/controlled_generation/example_05.py
    • Removed file.
  • generative_ai/controlled_generation/example_06.py
    • Removed file.
  • generative_ai/controlled_generation/example_07.py
    • Removed file.
  • generative_ai/controlled_generation/noxfile_config.py
    • Removed file.
  • generative_ai/controlled_generation/requirements-test.txt
    • Removed file.
  • generative_ai/controlled_generation/requirements.txt
    • Removed file.
  • generative_ai/express_mode/api_key_example.py
    • Updated model name from gemini-1.5-flash to gemini-2.0-flash-001.
  • generative_ai/function_calling/advanced_example.py
    • Removed file.
  • generative_ai/function_calling/basic_example.py
    • Removed file.
  • generative_ai/function_calling/chat_example.py
    • Removed file.
  • generative_ai/function_calling/chat_function_calling_basic.py
    • Removed file.
  • generative_ai/function_calling/chat_function_calling_config.py
    • Removed file.
  • generative_ai/function_calling/noxfile_config.py
    • Removed file.
  • generative_ai/function_calling/parallel_function_calling_example.py
    • Removed file.
  • generative_ai/function_calling/requirements-test.txt
    • Removed file.
  • generative_ai/function_calling/requirements.txt
    • Removed file.
  • generative_ai/function_calling/test_function_calling.py
    • Removed file.
  • generative_ai/grounding/noxfile_config.py
    • Removed file.
  • generative_ai/grounding/palm_example.py
    • Removed file.
  • generative_ai/grounding/requirements-test.txt
    • Removed file.
  • generative_ai/grounding/requirements.txt
    • Removed file.
  • generative_ai/grounding/test_grounding.py
    • Removed file.
  • generative_ai/grounding/vais_example.py
    • Removed file.
  • generative_ai/grounding/web_example.py
    • Removed file.
  • generative_ai/image/image_example01.py
    • Updated model name from gemini-1.5-flash-002 to gemini-2.0-flash-001.
  • generative_ai/image/image_example02.py
    • Updated model name from gemini-1.5-flash-002 to gemini-2.0-flash-001.
  • generative_ai/labels/labels_example.py
    • Updated model name from gemini-1.5-flash-001 to gemini-2.0-flash-001.
  • generative_ai/prompts/prompt_create.py
    • Updated model name from gemini-1.5-pro-002 to gemini-2.0-flash-001.
  • generative_ai/prompts/prompt_delete.py
    • Updated model name from gemini-1.5-pro-002 to gemini-2.0-flash-001.
  • generative_ai/prompts/prompt_get.py
    • Updated model name from gemini-1.5-pro-002 to gemini-2.0-flash-001.
  • generative_ai/prompts/prompt_list_version.py
    • Updated model name from gemini-1.5-pro-002 to gemini-2.0-flash-001.
  • generative_ai/prompts/prompt_restore_version.py
    • Updated model name from gemini-1.5-pro-002 to gemini-2.0-flash-001.
  • generative_ai/prompts/prompt_template.py
    • Updated model name from gemini-1.5-flash-002 to gemini-2.0-flash-001.
  • generative_ai/provisioned_throughput/provisioned_throughput_with_txt.py
    • Updated model name from gemini-1.5-flash-002 to gemini-2.0-flash-001.
  • generative_ai/rag/generate_content_example.py
    • Updated model name from gemini-1.5-flash-001 to gemini-2.0-flash-001.
  • generative_ai/rag/quickstart_example.py
    • Updated model name from gemini-1.5-flash-001 to gemini-2.0-flash-001.
  • generative_ai/safety/safety_config_example.py
    • Updated model name from gemini-1.5-flash-002 to gemini-2.0-flash-001.
  • generative_ai/system_instructions/system_instructions_example.py
    • Updated model name from gemini-1.5-flash-002 to gemini-2.0-flash-001.
  • generative_ai/template_folder/advanced_example.py
    • Updated model name from gemini-1.5-flash-002 to gemini-2.0-flash-001.
  • generative_ai/template_folder/simple_example.py
    • Updated model name from gemini-1.5-flash-002 to gemini-2.0-flash-001.
  • generative_ai/text_generation/chat_multiturn_example.py
    • Updated model name from gemini-1.5-flash-002 to gemini-2.0-flash-001.
  • generative_ai/text_generation/chat_multiturn_stream_example.py
    • Updated model name from gemini-1.5-flash-002 to gemini-2.0-flash-001.
  • generative_ai/text_generation/gemini_describe_http_image_example.py
    • Updated model name from gemini-1.5-flash-002 to gemini-2.0-flash-001.
  • generative_ai/text_generation/gemini_describe_http_pdf_example.py
    • Updated model name from gemini-1.5-flash-002 to gemini-2.0-flash-001.
  • generative_ai/text_generation/gemini_translate_text.py
    • Updated model name from gemini-1.5-flash-002 to gemini-2.0-flash-001.
  • generative_ai/text_generation/generation_config_example.py
    • Updated model name from gemini-1.5-flash-002 to gemini-2.0-flash-001.
  • generative_ai/text_generation/multimodal_stream_example.py
    • Updated model name from gemini-1.5-flash-002 to gemini-2.0-flash-001.
  • generative_ai/text_generation/single_turn_multi_image_example.py
    • Updated model name from gemini-1.5-flash-002 to gemini-2.0-flash-001.
  • generative_ai/text_generation/text_example01.py
    • Updated model name from gemini-1.5-flash-002 to gemini-2.0-flash-001.
  • generative_ai/text_generation/text_example03.py
    • Updated model name from gemini-1.5-flash-002 to gemini-2.0-flash-001.
  • generative_ai/text_generation/text_stream_example01.py
    • Updated model name from gemini-1.5-flash-002 to gemini-2.0-flash-001.
  • generative_ai/token_count/api_example.py
    • Removed file.
  • generative_ai/token_count/list_tokens_example.py
    • Removed file.
  • generative_ai/token_count/local_sdk_example.py
    • Removed file.
  • generative_ai/token_count/multimodal_token_count_example.py
    • Removed file.
  • generative_ai/token_count/noxfile_config.py
    • Removed file.
  • generative_ai/token_count/requirements-test.txt
    • Removed file.
  • generative_ai/token_count/requirements.txt
    • Removed file.
  • generative_ai/token_count/simple_example.py
    • Removed file.
  • generative_ai/token_count/test_list_tokens_example.py
    • Removed file.
  • generative_ai/token_count/test_token_count_examples.py
    • Removed file.
  • generative_ai/understand_audio/summarization_example.py
    • Updated model name from gemini-1.5-flash-002 to gemini-2.0-flash-001.
  • generative_ai/understand_audio/transcription_example.py
    • Updated model name from gemini-1.5-flash-002 to gemini-2.0-flash-001.
  • generative_ai/understand_docs/pdf_example.py
    • Updated model name from gemini-1.5-flash-002 to gemini-2.0-flash-001.
  • generative_ai/understand_video/audio_video_example.py
    • Updated model name from gemini-1.5-flash-002 to gemini-2.0-flash-001.
  • generative_ai/understand_video/single_turn_video_example.py
    • Updated model name from gemini-1.5-flash-002 to gemini-2.0-flash-001.
  • generative_ai/video/gemini_describe_http_video_example.py
    • Updated model name from gemini-1.5-flash-002 to gemini-2.0-flash-001.
  • generative_ai/video/gemini_youtube_video_key_moments_example.py
    • Updated model name from gemini-1.5-flash-002 to gemini-2.0-flash-001.
  • generative_ai/video/gemini_youtube_video_summarization_example.py
    • Updated model name from gemini-1.5-flash-002 to gemini-2.0-flash-001.
  • generative_ai/video/multimodal_example01.py
    • Updated model name from gemini-1.5-flash-002 to gemini-2.0-flash-001.
  • generative_ai/video/multimodal_example02.py
    • Updated model name from gemini-1.5-flash-002 to gemini-2.0-flash-001.
  • translate/samples/snippets/translate_with_gemini.py
    • Updated model name from gemini-1.0-pro to gemini-2.0-flash-001.
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 is currently in preview and 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 to provide feedback.

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.


A new model arrives, shining bright,
Old samples fade into the night.
gemini-2.0-flash-001,
Now the chosen one,
In code, we trust its guiding light.

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

The pull request updates the Gemini samples by updating the model names and cleaning up old samples. The changes look good overall, but there are a few areas that could be improved.

Summary of Findings

  • Model Name Updates: The model names have been updated from gemini-1.5-pro-001 and gemini-1.5-flash-002 to gemini-2.0-flash-001. This is a necessary update to reflect the latest model versions.
  • File Deletions: Several files related to content caching have been deleted. Ensure that these files are no longer needed and that the deletion does not introduce any regressions.

Merge Readiness

The pull request is almost ready for merging. Please address the comments regarding the deleted files to ensure no regressions are introduced. I am unable to approve this pull request, and users should have others review and approve this code before merging.

@msampathkumar msampathkumar marked this pull request as ready for review March 31, 2025 16:59
@msampathkumar msampathkumar requested review from a team as code owners March 31, 2025 16:59
Copy link

snippet-bot bot commented Mar 31, 2025

Here is the summary of possible violations 😱

There are 2 possible violations for removing region tag in use.

The end of the violation section. All the stuff below is FYI purposes only.


You are about to delete the following sample browser pages.

Here is the summary of changes.

You are about to add 2 region tags.
You are about to delete 73 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

Copy link
Contributor

@iennae iennae left a comment

Choose a reason for hiding this comment

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

Please update the PR with the CL that removes the snippets in use. Thanks.

@msampathkumar msampathkumar changed the title Gemini samples updates feat(genai, generative_ai): Migration of Gemini samples to 2.X models Mar 31, 2025
@glasnt glasnt added the snippet-bot:force-run Force snippet-bot runs its logic label Mar 31, 2025
@snippet-bot snippet-bot bot removed the snippet-bot:force-run Force snippet-bot runs its logic label Mar 31, 2025
@glasnt glasnt added the snippet-bot:force-run Force snippet-bot runs its logic label Apr 1, 2025
@snippet-bot snippet-bot bot removed the snippet-bot:force-run Force snippet-bot runs its logic label Apr 1, 2025
@glasnt glasnt added the snippet-bot:force-run Force snippet-bot runs its logic label Apr 2, 2025
@snippet-bot snippet-bot bot removed the snippet-bot:force-run Force snippet-bot runs its logic label Apr 2, 2025
@holtskinner holtskinner added the snippet-bot:force-run Force snippet-bot runs its logic label Apr 3, 2025
@snippet-bot snippet-bot bot removed the snippet-bot:force-run Force snippet-bot runs its logic label Apr 3, 2025
@msampathkumar msampathkumar requested a review from iennae April 3, 2025 16:37
@msampathkumar
Copy link
Member Author

Update: After manual verification I can confirm that the blockers identified by snippet-bot-check are false positives. Requesting the re-review.

CC: @glasnt @iennae

@msampathkumar msampathkumar added priority: p0 Highest priority. Critical issue. P0 implies highest priority. snippet-bot:force-run Force snippet-bot runs its logic labels Apr 3, 2025
@snippet-bot snippet-bot bot removed the snippet-bot:force-run Force snippet-bot runs its logic label Apr 3, 2025
@iennae iennae added the snippet-bot:force-run Force snippet-bot runs its logic label Apr 3, 2025
@snippet-bot snippet-bot bot removed the snippet-bot:force-run Force snippet-bot runs its logic label Apr 3, 2025
@glasnt glasnt added the snippet-bot:force-run Force snippet-bot runs its logic label Apr 4, 2025
@snippet-bot snippet-bot bot removed the snippet-bot:force-run Force snippet-bot runs its logic label Apr 4, 2025
@glasnt glasnt added the snippet-bot:force-run Force snippet-bot runs its logic label Apr 4, 2025
@snippet-bot snippet-bot bot removed the snippet-bot:force-run Force snippet-bot runs its logic label Apr 4, 2025
@iennae
Copy link
Contributor

iennae commented Apr 4, 2025

snippetbot is good now; the PR has conflicts with requirements.txt that need to be resolved now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: discoveryengine Issues related to the Discovery Engine API API. priority: p0 Highest priority. Critical issue. P0 implies highest priority. samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants