Skip to content

feat(genai): Adding live_code_exec_with_txt with test #13516

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

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

Guiners
Copy link

@Guiners Guiners commented Jul 24, 2025

Description

Fixes #

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

Checklist

@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Jul 24, 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.

Summary of Changes

Hello @Guiners, 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 introduces a new Python sample that showcases the live code execution capabilities of the Google GenAI SDK, allowing models to generate and execute code based on text prompts. It includes the necessary setup for the live connection and a corresponding test to validate the new functionality.

Highlights

  • New Live Code Execution Example: I've added a new Python sample, live_code_exec_with_txt.py, which demonstrates how to use the google.genai SDK to interact with a live Gemini model (gemini-2.0-flash-live-preview-04-09) for code execution based on text input. This example configures the session to enable ToolCodeExecution and processes both text responses and executable code/results from the model.
  • Dedicated Test Case: A new asynchronous test function, test_live_code_exec_with_txt, has been added to test_live_examples.py to ensure the functionality of the new live code execution sample.
  • Dependency Updates: The requirements.txt file has been updated to include soundfile==0.13.1 and librosa==0.11.0. While these dependencies are not directly used by the new live_code_exec_with_txt.py sample, they are likely for other audio-related live examples within the genai/live directory.
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 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 or fill out our survey 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.

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 introduces a new Python sample, live_code_exec_with_txt.py, demonstrating live code execution with text input using the Gemini API, and includes a corresponding test. The implementation is generally sound, but I've identified several areas for improvement to enhance code quality, clarity, and maintainability.

)

client = genai.Client()
# model_id = "gemini-live-2.5-flash" #todo
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This commented-out line with a todo appears to be a leftover from development. It should be removed to keep the code clean and avoid confusion.

Copy link
Member

Choose a reason for hiding this comment

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

As suggested here, please remove TODO line

Copy link
Author

Choose a reason for hiding this comment

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

We will discuss this model_id on today's call. Afterwards, I'll remove that or update a model

@Guiners Guiners changed the title Adding live_code_exec_with_txt with test feat(genai): Adding live_code_exec_with_txt with test Jul 28, 2025

client = genai.Client()
# model_id = "gemini-live-2.5-flash" #todo
model_id = "gemini-2.0-flash-live-preview-04-09"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
model_id = "gemini-2.0-flash-live-preview-04-09"
GEMINI_MODEL_NAME = "gemini-2.0-flash-live-preview-04-09"

response_modalities=[Modality.TEXT],
tools=[Tool(code_execution=ToolCodeExecution())],
)
async with client.aio.live.connect(model=model_id, config=config) as session:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
async with client.aio.live.connect(model=model_id, config=config) as session:
async with client.aio.live.connect(model=GEMINI_MODEL_NAME, config=config) as session:

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.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy