-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 thegoogle.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 enableToolCodeExecution
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 totest_live_examples.py
to ensure the functionality of the new live code execution sample. - Dependency Updates: The
requirements.txt
file has been updated to includesoundfile==0.13.1
andlibrosa==0.11.0
. While these dependencies are not directly used by the newlive_code_exec_with_txt.py
sample, they are likely for other audio-related live examples within thegenai/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
-
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. ↩
There was a problem hiding this 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
|
||
client = genai.Client() | ||
# model_id = "gemini-live-2.5-flash" #todo | ||
model_id = "gemini-2.0-flash-live-preview-04-09" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: |
Description
Fixes #
Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.
Checklist
nox -s py-3.9
(see Test Environment Setup)nox -s lint
(see Test Environment Setup)