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

Update everything to use google-genai SDK #446

Open
markmcd opened this issue Feb 7, 2025 · 27 comments
Open

Update everything to use google-genai SDK #446

markmcd opened this issue Feb 7, 2025 · 27 comments
Labels
good first issue Good for newcomers type:feature request New feature request/enhancement

Comments

@markmcd
Copy link
Member

markmcd commented Feb 7, 2025

Description of the feature request:

Lots of notebooks are using the google-generativeai SDK, but now that google-genai is at 1.0, we should be using that.

e.g. pip install google-generativeai needs to be replaced with pip install google-genai and then relevant code and text needs to be updated.

There's lots to do right now, but we can do every notebook independently so this would be a great one to open to community contributions. If you want to work on one, check the open PR list to see if someone has already done it, then just send a PR directly (but stick to one notebook per PR).

And here's the migration guide: https://ai.google.dev/gemini-api/docs/migrate

@markmcd markmcd added type:feature request New feature request/enhancement good first issue Good for newcomers labels Feb 7, 2025
@mitrick2
Copy link

Are there plans to create a google-genai SDK for JS?

@Faakhir30
Copy link
Contributor

Updating Anomaly_detection_with_embeddings.ipynb. Informed to avoid duplicate efforts by other contributors, thanks

@Faakhir30
Copy link
Contributor

Are there plans to create a google-genai SDK for JS?

I guess we already have it https://github.com/google-gemini/generative-ai-js, currently at google/[email protected] at the time of comment.

@charantek1styearbtech
Copy link
Contributor

@markmcd need help in accepting Google contributor licence agreement there is always an server error.
Any suggestions?

@ROHANDWIVEDI2005
Copy link
Contributor

@markmcd need help in accepting Google contributor licence agreement there is always an server error. Any suggestions?

I also have the same issue.

@Giom-V
Copy link
Collaborator

Giom-V commented Mar 4, 2025

Are there plans to create a google-genai SDK for JS?

@mitrick2 A new typescript unified SDK is on its way. (and BTW, we're also accepting submissions in other languages than Python if you have great examples)

@Giom-V
Copy link
Collaborator

Giom-V commented Mar 4, 2025

@charantek1styearbtech @ROHANDWIVEDI2005 @Faakhir30 As for the CLA issue, it's being investigated internally. And it seems it was fixed a couple of hours ago, so please try again and tell me if that still doesn't work.

Thanks you all for your contributions!

Giom-V added a commit that referenced this issue Mar 4, 2025
Refers #446

* Updated notebook to use genai module
* Refactoed imports
* Updated Readme Links
---------

Signed-off-by: Faakhir30 <[email protected]>
Co-authored-by: Guillaume Vernade <[email protected]>
Giom-V added a commit that referenced this issue Mar 4, 2025
Refers #446 

* Updated `examples/Upload_files_to_Colab.ipynb` to use `google-genai` module instead of `generativeai`.
* Removing link to the colab

I'm removing the link to this colab in the README as I don't think it's worth having it there. While it's good to have this code example, it doesn't really bring any value as an example of the advanced capabilities of Gemini.

---------

Signed-off-by: Faakhir30 <[email protected]>
Co-authored-by: Guillaume Vernade <[email protected]>
Giom-V added a commit that referenced this issue Mar 4, 2025
Refers #446 

* Updated `examples/Apollo_11.ipynb` to use `google-genai` module instead of `generativeai`.
* Update reference in readme
* Updating link to file api notebook for a relative one.

---------

Signed-off-by: Faakhir30 <[email protected]>
Co-authored-by: Guillaume Vernade <[email protected]>
Giom-V added a commit that referenced this issue Mar 5, 2025
Part of #446

* changed sample.py to use google-genai sdk

---------

Co-authored-by: Guillaume Vernade <[email protected]>
Giom-V pushed a commit that referenced this issue Mar 5, 2025
Refers #446

* Updated module google-generativeai to use google-genai>=1.0.0
* Refactored imports

Signed-off-by: Faakhir30 <[email protected]>
freddyaboulton pushed a commit to freddyaboulton/gemini-cookbook that referenced this issue Mar 5, 2025
…ini#499)

Refers google-gemini#446

* Updated notebook to use genai module
* Refactoed imports
* Updated Readme Links
---------

Signed-off-by: Faakhir30 <[email protected]>
Co-authored-by: Guillaume Vernade <[email protected]>
freddyaboulton pushed a commit to freddyaboulton/gemini-cookbook that referenced this issue Mar 5, 2025
…ni#486)

Refers google-gemini#446 

* Updated `examples/Upload_files_to_Colab.ipynb` to use `google-genai` module instead of `generativeai`.
* Removing link to the colab

I'm removing the link to this colab in the README as I don't think it's worth having it there. While it's good to have this code example, it doesn't really bring any value as an example of the advanced capabilities of Gemini.

---------

Signed-off-by: Faakhir30 <[email protected]>
Co-authored-by: Guillaume Vernade <[email protected]>
freddyaboulton pushed a commit to freddyaboulton/gemini-cookbook that referenced this issue Mar 5, 2025
Refers google-gemini#446 

* Updated `examples/Apollo_11.ipynb` to use `google-genai` module instead of `generativeai`.
* Update reference in readme
* Updating link to file api notebook for a relative one.

---------

Signed-off-by: Faakhir30 <[email protected]>
Co-authored-by: Guillaume Vernade <[email protected]>
freddyaboulton pushed a commit to freddyaboulton/gemini-cookbook that referenced this issue Mar 5, 2025
Part of google-gemini#446

* changed sample.py to use google-genai sdk

---------

Co-authored-by: Guillaume Vernade <[email protected]>
@KSruthiVel
Copy link
Contributor

Thank you, @Giom-V. I will check the function calling notebook for reference.

@markmcd
Copy link
Member Author

markmcd commented Mar 14, 2025

Use chat.get_history() in Python SDK 1.5 or higher.

KSruthiVel added a commit to KSruthiVel/cookbook that referenced this issue Mar 17, 2025
KSruthiVel added a commit to KSruthiVel/cookbook that referenced this issue Mar 17, 2025
KSruthiVel added a commit to KSruthiVel/cookbook that referenced this issue Mar 18, 2025
KSruthiVel added a commit to KSruthiVel/cookbook that referenced this issue Mar 21, 2025
KSruthiVel added a commit to KSruthiVel/cookbook that referenced this issue Mar 21, 2025
@Chamikajaya
Copy link

Hi @markmcd, @Giom-V,

I've created several PRs that migrate cookbook examples to use the new google-genai SDK as requested in the issue. These migrations maintain the original functionality while updating the API calls to the latest version.

PR links:

I've thoroughly tested each example to ensure they run correctly with the updated SDK.

Thank you,
Chamika Jayasinghe

@Raunak2024
Copy link

Raunak2024 commented Mar 25, 2025

Hi @markmcd, @Giom-V
I have finished migrating the Search_Wikipedia_using_ReAct.ipynb to new google-genai sdk from old google-generative-ai sdk. and ready to make a pull request and informing others to avoid duplicate submissions. The code looks good but I think we need to modify the model_instructions.txt file because the code output seems to be incorrect. We can open a new issue for this one that needs a fix. I have attached a screenshot for reference along with the correct output from the web.
Do let me know.

Thank You
Raunak Nag

Image Image Image

@myanvoos
Copy link
Contributor

If anyone is interested in picking up where me and @Giom-V left off at #487, please feel free to!

Giom-V pushed a commit that referenced this issue Mar 31, 2025
…DK (#446) (#555)

This pull request updates the following notebooks to replace google-generativeai with google-genai, aligning with the transition to the new SDK as outlined in #446:

* `Caching.ipynb`
* `Gemini_Flash_Introduction.ipynb`
* `JSON_mode.ipynb`
* `Template.ipynb`

These changes ensure the notebooks remain compatible with the latest SDK version.

This PR addresses #446
@Giom-V
Copy link
Collaborator

Giom-V commented Mar 31, 2025

Thank you all for your submission (especially those of you who migrated dozen of notebooks).

I made a quick check on what had not been migrated yet so you can have a quick way to find something to work on:

Once again thank you all and don't hesitate to continue to improve the cookbook by fixing typos, adding missing examples (like an example using generate_content instead of chat for the grounding, or a function calling example using a OpenAPI schema object like we do on AI Studio), or maybe just proposing more interesting or more fun prompts in the notebook (just keep in mind the is still Google stuff we you can't be too unhinged so I might be difficult).

@Jenniebn
Copy link
Contributor

If anyone is interested in picking up where me and @Giom-V left off at #487, please feel free to!

I‘ve migrated examples/Classify_text_with_embeddings.ipynb in #622. Feel free to check it out!

@Raunak2024
Copy link

Hi @markmcd, @Giom-V I have finished migrating the Search_Wikipedia_using_ReAct.ipynb to new google-genai sdk from old google-generative-ai sdk. and ready to make a pull request and informing others to avoid duplicate submissions. The code looks good but I think we need to modify the model_instructions.txt file because the code output seems to be incorrect. We can open a new issue for this one that needs a fix. I have attached a screenshot for reference along with the correct output from the web. Do let me know.

Thank You Raunak Nag

Image Image Image

Hi @markmcd, @Giom-V I have finished migrating the Search_Wikipedia_using_ReAct.ipynb to new google-genai sdk from old google-generative-ai sdk. and ready to make a pull request and informing others to avoid duplicate submissions. The code looks good but I think we need to modify the model_instructions.txt file because the code output seems to be incorrect. We can open a new issue for this one that needs a fix. I have attached a screenshot for reference along with the correct output from the web. Do let me know.

Thank You Raunak Nag

Image Image Image

@markmcd @Giom-V Do review this once!

@Giom-V
Copy link
Collaborator

Giom-V commented Apr 3, 2025

@markmcd @Giom-V Do review this once!

@Raunak2024 I reviewed it 3 days ago...

@nsbg
Copy link

nsbg commented Apr 3, 2025

Hi everyone! If this topic is still open, I'd like to contribute — could you let me know exactly what I need to do?

@Giom-V
Copy link
Collaborator

Giom-V commented Apr 3, 2025

Hi everyone! If this topic is still open, I'd like to contribute — could you let me know exactly what I need to do?

Thanks for volunteering your help. The easiest is to take one of the notebooks I listed in this post that isn't been worked on (double-check the open pull request just in case). And then migrate them to use the new google-genai SDK following this migration guide.

Be warned that I'll likely ask you to not only update the code but to also correct the wording if it's a bit old and to improve the readability of the code in various ways. You can check past PR to get an idea.

@omkenge
Copy link
Contributor

omkenge commented Apr 3, 2025

@Giom-V
Copy link
Collaborator

Giom-V commented Apr 7, 2025

@ALL, I will be travelling to Google Cloud Next this week, which mean that I won't have much time to review and merge all of your pull requests (especially since there are more and more every day... and think you for that!).

I know that some of you wanted to use them to apply for the GSoC, feel free to still use them, even if they haven't been merged yet.

@Mu-Magdy
Copy link
Contributor

Mu-Magdy commented Apr 7, 2025

Hi @Giom-V
Have a safe trip and good luck with your meetings.

I made a new PR #679 to update the weaviate example

@andycandy
Copy link
Contributor

andycandy commented Apr 7, 2025

Hey @Mu-Magdy , I think you didn't notice, I already submitted a PR for that notebook
#659

@Mu-Magdy
Copy link
Contributor

Mu-Magdy commented Apr 7, 2025

Hi @andycandy
Yes I didn't notice at first.
But I think you need to update you pr to be reviewable.
I can help with that if you want

@andycandy
Copy link
Contributor

andycandy commented Apr 7, 2025

Hi @andycandy
Yes I didn't notice at first.
But I think you need to update you pr to be reviewable.
I can help with that if you want

No, thank you tho. It was an old PR which I didn't get time to check back. It's all updated now :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers type:feature request New feature request/enhancement
Projects
None yet
Development

No branches or pull requests