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

fix: Add Batch Prediction to Gen AI SDK Intro #1595

Merged
merged 3 commits into from
Jan 3, 2025
Merged

Conversation

holtskinner
Copy link
Collaborator

Description

Add Batch Prediction example to Gen AI SDK Intro Notebook.

@holtskinner holtskinner requested a review from a team as a code owner January 3, 2025 15:45
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Copy link
Contributor

@code-review-assist code-review-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.

Hi team,

I'm currently reviewing this pull request and will provide my feedback shortly. In the meantime, here's a summary for you and other reviewers to quickly get up to speed:

This pull request, authored by holtskinner, aims to add a Batch Prediction example to the Gen AI SDK introduction notebook within the generative-ai repository. The changes are focused on enhancing the tutorial's comprehensiveness by illustrating the use of batch prediction capabilities.

Here's a breakdown of the changes:

  • File: gemini/getting-started/intro_genai_sdk.ipynb
    • A minor typographical correction was made in the notebook's title (line 32, changed from "Google generative AI" to "Google Generative AI").
    • The list of features demonstrated in the notebook was updated to include "Batch prediction" (line 120).
    • The notebook's code was modified to include the necessary imports and code snippets for demonstrating batch prediction (lines 149-150, 196-204). This includes importing datetime and pandas, and adding CreateBatchJobConfig to the imports from google.genai.types.
    • A significant section was added to the notebook to explain and demonstrate batch prediction using the Gemini API in Vertex AI (lines 1014-1202). This includes sections on preparing batch inputs and outputs, sending a batch prediction request, retrieving results, and listing batch prediction jobs. The example uses Cloud Storage for input and output.

The changes are well-structured and clearly explained. The addition of the batch prediction example significantly improves the tutorial's practical value.


Short poem for your enjoyment:

Code flows like a stream,
Batch predictions, swift and clean,
Efficiency gleams.

Thanks,
Gemini/code-review-assist

Copy link
Contributor

@code-review-assist code-review-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.

This pull request adds a batch prediction example to the Gen AI SDK Intro Notebook. This is a valuable addition that enhances the comprehensiveness of the tutorial. The code and documentation changes are well-structured and easy to follow. I have a few suggestions to further improve the clarity and completeness of the example.

I've based my maintainability suggestions on common Python style guides, including PEP 8, since no specific style guide was provided.

It's great to see the added section in the notebook's overview mentioning batch prediction. This helps users quickly understand the notebook's contents.

gemini/getting-started/intro_genai_sdk.ipynb Show resolved Hide resolved
gemini/getting-started/intro_genai_sdk.ipynb Show resolved Hide resolved
gemini/getting-started/intro_genai_sdk.ipynb Show resolved Hide resolved
gemini/getting-started/intro_genai_sdk.ipynb Show resolved Hide resolved
gemini/getting-started/intro_genai_sdk.ipynb Show resolved Hide resolved
gemini/getting-started/intro_genai_sdk.ipynb Outdated Show resolved Hide resolved
Copy link
Contributor

@code-review-assist code-review-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.

Hi team,

I'm currently reviewing this pull request and will provide my feedback shortly. In the meantime, here's a summary of the changes for you and other reviewers to get up to speed quickly:

This pull request, authored by holtskinner, aims to add a Batch Prediction example to the Gen AI SDK Intro Notebook within the generative-ai repository. The changes made include:

  • Minor Text Update: Line 32 of gemini/getting-started/intro_genai_sdk.ipynb corrects a minor typo, changing "Google generative AI" to "Google Generative AI".
  • Addition of Batch Prediction to Outline: Line 120 in gemini/getting-started/intro_genai_sdk.ipynb adds "Batch prediction" to the list of features covered in the notebook.
  • Dependency Update: Line 150 in gemini/getting-started/intro_genai_sdk.ipynb adds pandas as a dependency to the pip install command, likely required for the batch prediction example.
  • Import Statements Update: Lines 197-205 in gemini/getting-started/intro_genai_sdk.ipynb add the necessary import statements for batch prediction functionality, specifically importing datetime and CreateBatchJobConfig from google.genai.types.
  • Major Section Addition: A significant section (lines 1014-1202) has been added to gemini/getting-started/intro_genai_sdk.ipynb detailing how to perform batch predictions using the Gen AI SDK. This includes explanations of preparing batch inputs and outputs, sending batch requests, and retrieving results. The new section covers preparing batch inputs from Cloud Storage, preparing batch output locations (Cloud Storage or BigQuery), sending a batch prediction request, and retrieving the results using pandas.

The changes are well-structured and clearly explain the process of batch prediction. The addition of pandas as a dependency is logical and necessary for the data manipulation involved in the batch prediction example.

I'll have a more detailed review shortly.


Here's a little haiku to brighten your day:

Code flows like a stream,
Batch predictions, swift and clean,
Efficiency's gleam.

Copy link
Contributor

@code-review-assist code-review-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.

This pull request adds a batch prediction example to the Gen AI SDK Intro Notebook. This is a valuable addition that enhances the comprehensiveness of the notebook. The code is generally well-written and clear. The use of markdown to explain the batch prediction process and the inclusion of code examples for preparing input, output, sending requests, and retrieving results is commendable. Here are a few suggestions based on Python PEP 8 style guide to further improve the notebook:

gemini/getting-started/intro_genai_sdk.ipynb Show resolved Hide resolved
gemini/getting-started/intro_genai_sdk.ipynb Show resolved Hide resolved
gemini/getting-started/intro_genai_sdk.ipynb Show resolved Hide resolved
gemini/getting-started/intro_genai_sdk.ipynb Show resolved Hide resolved
gemini/getting-started/intro_genai_sdk.ipynb Show resolved Hide resolved
gemini/getting-started/intro_genai_sdk.ipynb Outdated Show resolved Hide resolved
@holtskinner holtskinner merged commit 24ac07f into main Jan 3, 2025
9 checks passed
@holtskinner holtskinner deleted the gen-ai-sdk-batch branch January 3, 2025 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant