Skip to content

feat: add new GenAI SDK text generation samples #10144

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

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

Conversation

jdomingr
Copy link
Contributor

@jdomingr jdomingr commented Aug 5, 2025

Description

Add new text generation samples (1):

  • Text generation with multiple local images
  • Text generation with mute video
  • Text generation with PDF
  • Text generation with YouTube Video
  • Text generation async with text
  • Remove unused imports in TextGenerationWithText and ToolFunctionDescriptionWithText

Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.

Checklist

  • I have followed Sample Format Guide
  • Tests pass: mvn clean verify required
  • Lint passes: mvn -P lint checkstyle:check required
  • Static Analysis: mvn -P lint clean compile pmd:cpd-check spotbugs:check advisory only
  • Please merge this PR for me once it is approved

@jdomingr jdomingr requested review from yoshi-approver and a team as code owners August 5, 2025 15:33
@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Aug 5, 2025
Copy link

snippet-bot bot commented Aug 5, 2025

Here is the summary of changes.

You are about to add 5 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

Warning

Gemini encountered an error creating the summary. You can try again by commenting /gemini summary.

@jdomingr
Copy link
Contributor Author

jdomingr commented Aug 5, 2025

/gemini summary

Copy link
Contributor

Summary of Changes

I've introduced a set of new text generation samples for the GenAI SDK, expanding its capabilities to handle various input types. These additions include samples for asynchronous text generation from text, generating text from multiple local images, and extracting information from mute videos, PDFs, and YouTube videos. My aim is to provide comprehensive examples that showcase the SDK's versatility in multimodal content understanding and generation. Additionally, I've performed some minor code cleanup by removing unused imports in existing files.

Highlights

  • Asynchronous Text Generation: I've added a new sample that demonstrates how to perform text generation asynchronously using a text prompt.
  • Multi-Local Image Text Generation: I've included a new sample that shows how to generate text by providing multiple local image files as input to the model.
  • Mute Video Text Generation: I've added a new sample illustrating how to generate text from a mute video input, allowing the model to describe or summarize video content.
  • PDF Text Generation: I've provided a new sample that demonstrates generating text by feeding a PDF document to the model, useful for summarization or content extraction.
  • YouTube Video Text Generation: I've included a new sample showing how to generate text from a YouTube video URL, enabling the model to process and respond to video content.
  • Code Cleanup and Import Optimization: I've cleaned up several existing files by removing imports that were no longer necessary, improving code readability and reducing potential clutter.
Changelog
  • genai/snippets/src/main/java/genai/textgeneration/TextGenerationAsyncWithText.java
    • Added a new sample demonstrating asynchronous text generation with text input.
  • genai/snippets/src/main/java/genai/textgeneration/TextGenerationWithMultiLocalImage.java
    • Added a new sample demonstrating text generation using multiple local images.
  • genai/snippets/src/main/java/genai/textgeneration/TextGenerationWithMuteVideo.java
    • Added a new sample demonstrating text generation with mute video input.
  • genai/snippets/src/main/java/genai/textgeneration/TextGenerationWithPdf.java
    • Added a new sample demonstrating text generation with PDF file input.
  • genai/snippets/src/main/java/genai/textgeneration/TextGenerationWithText.java
    • Removed unused imports (Content, Part) to clean up the file.
  • genai/snippets/src/main/java/genai/textgeneration/TextGenerationWithYoutubeVideo.java
    • Added a new sample demonstrating text generation with YouTube video input.
  • genai/snippets/src/main/java/genai/tools/ToolFunctionDescriptionWithText.java
    • Removed unused imports (List, Objects, Optional) to clean up the file.
  • genai/snippets/src/test/java/genai/textgeneration/TextGenerationIT.java
    • Updated the existing TextGenerationWithMultiImage test to use a constant for local image paths.
    • Added new integration tests for the newly introduced text generation samples: TextGenerationAsyncWithText, TextGenerationWithMultiLocalImage, TextGenerationWithMuteVideo, TextGenerationWithPdf, and TextGenerationWithYoutubeVideo.
Activity
  • snippet-bot[bot] commented on August 5, 2025, providing a summary of 5 new region tags added by this pull request.
  • gemini-code-assist[bot] reported an error generating a summary on August 5, 2025.
  • jdomingr (the author) re-requested a summary from gemini on August 5, 2025.

@gericdong gericdong added the kokoro:run Add this label to force Kokoro to re-run the tests. label Aug 7, 2025
@kokoro-team kokoro-team removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Aug 7, 2025
@jdomingr
Copy link
Contributor Author

jdomingr commented Aug 7, 2025

/gemini review

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 several new text generation samples for the GenAI SDK, demonstrating features like asynchronous calls, and using various inputs such as multiple local images, videos, and PDFs. The changes also include cleanup of unused imports in existing files and adding corresponding integration tests for the new samples. My review focuses on improving code consistency, readability, and test conciseness. I've suggested using System.out.print for consistent output, adopting Java text blocks for better readability of multi-line strings, and removing redundant assertions in the new tests.

@msampathkumar msampathkumar added the kokoro:run Add this label to force Kokoro to re-run the tests. label Aug 8, 2025
@kokoro-team kokoro-team removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Aug 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants