Skip to content

Structured Task Extraction using Pydantic and Gemini 3 Flash#1112

Closed
Shivangisharma4 wants to merge 1 commit intogoogle-gemini:mainfrom
Shivangisharma4:recipe-task-extraction
Closed

Structured Task Extraction using Pydantic and Gemini 3 Flash#1112
Shivangisharma4 wants to merge 1 commit intogoogle-gemini:mainfrom
Shivangisharma4:recipe-task-extraction

Conversation

@Shivangisharma4
Copy link

Description

This PR adds a new recipe to the examples/ directory.

Note: This replaces the closed PR #1111. I have updated my account settings and CLA to resolve previous check failures and have incorporated all feedback provided by the assistant bot in the previous thread.

Summary

The notebook demonstrates how to perform Structured Data Extraction using the google-genai SDK (v1.0+) and Pydantic. It showcases:

  • Using response_schema to enforce JSON structure.
  • Leveraging Gemini 3 Flash for efficient parsing.
  • Proper environment handling for both Colab and local environments.
  • Implementation of Colab form parameters for interactive inputs.

Why this is useful

Many developers struggle with "hallucinated" JSON. This example provides a robust, production-ready template for turning natural language into machine-readable data.

Checklist

  • Notebook follows the Google style guide (Refactored to Markdown cells).
  • Used the gemini-3-flash model.

@google-cla
Copy link

google-cla bot commented Jan 17, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@github-actions github-actions bot added status:awaiting review PR awaiting review from a maintainer component:examples Issues/PR referencing examples folder labels Jan 17, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Shivangisharma4, 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 adds a new example notebook that showcases a robust method for converting natural language into machine-readable, structured data. By integrating the Gemini API with Pydantic, developers can effectively define and enforce data schemas, mitigating issues like 'hallucinated' JSON and streamlining the process of building AI agents that interact with structured data systems.

Highlights

  • New Example Notebook: Introduces a new recipe for Structured Data Extraction using the google-genai SDK (v1.0+) and Pydantic.
  • Structured Data Extraction: Demonstrates how to enforce JSON structure using response_schema and leverage Gemini 3 Flash for efficient parsing of unstructured text into validated JSON objects.
  • Environment Handling: Includes proper environment setup for both Colab and local development, ensuring API key management is robust.
  • Interactive Inputs: Implements Colab form parameters to provide interactive input capabilities within the notebook.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

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.

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

This pull request adds a great example for structured data extraction using Pydantic and the Gemini API. The notebook is well-structured and follows most of the repository's style guide.

I've left a few comments for minor improvements, mostly related to adhering to the style guide regarding model selection and phrasing in markdown cells, as well as some suggestions to make the Pydantic schema more robust.

Additionally, please remember to:

  • Add a reference to this new notebook in examples/README.md as per the style guide (line 8).
  • Run the notebook and commit the outputs so users can see the expected results without running it themselves (style guide line 42).

@Shivangisharma4
Copy link
Author

I have implemented all the suggested changes from the code review:

  • Phrasing: Rephrased text to the second person ("you").
  • Schema: Updated Pydantic models with Literal and Optional for robustness.
  • README: Added a reference to the notebook in examples/README.md.
  • Form: Added the model selection form parameter.

@googlebot I fixed it. Please rescan for CLA and style compliance.

Copy link

Choose a reason for hiding this comment

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

Submit the approval with the change....

@Shivangisharma4
Copy link
Author

I have implemented all suggested changes, including the Pydantic schema refinements and style guide updates, and have resolved the corresponding conversation threads.

@googlebot I fixed it. Please rescan for the CLA

@Shivangisharma4 Shivangisharma4 closed this by deleting the head repository Feb 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component:examples Issues/PR referencing examples folder status:awaiting review PR awaiting review from a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants