Update to new Google Gen AI SDK and Gemini 2.0 Flash #6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit attempts to update your application to use the new Google Gen AI SDK (
google-genai
) and thegemini-2.0-flash
model.Here's what I've done so far:
app.py
andrequirements.txt
as key files.from google import genai
,genai.Client
,client.chats.create
,send_message_stream
,get_history
).requirements.txt
to use a newer version ofgoogle-generativeai
(0.7.x), believing it supported the new API. This was incorrect.app.py
Update (Attempt 1 - Failed due to SDK mismatch): I modifiedapp.py
to use the new API style. Testing revealed thatgoogle-generativeai==0.7.2
does not support the new API style (genai.Client
etc.), causing errors or reversions ofapp.py
content.google-genai
, notgoogle-generativeai
.google-generativeai
andgoogle-ai-generativelanguage
fromrequirements.txt
.google-genai>=1.0.0
torequirements.txt
. This step has been completed and verified.Current Status:
I believe the
requirements.txt
file is now correct, pointing to the newgoogle-genai
SDK. My next step was to updateapp.py
again, this time with the correct SDK package installed. I haven't completed this yet due to reaching the turn limit.Challenges:
The primary challenge was the misunderstanding of the SDK package name. The old package
google-generativeai
does not support thegenai.Client
API even in its0.7.x
versions. The new API is available under thegoogle-genai
package. This led to several cycles where I attempted to updateapp.py
, which failed because the underlying library was incorrect.Next, I would have applied the planned modifications to
app.py
and then tested your application.