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

Add support for Gemini #666

Merged
merged 9 commits into from
Mar 6, 2024
Merged

Add support for Gemini #666

merged 9 commits into from
Mar 6, 2024

Conversation

giswqs
Copy link
Contributor

@giswqs giswqs commented Mar 3, 2024

This is an attempt to add support for Google Gemini API.

@simonff @richlysakowski @3coins

Reference: #395

https://python.langchain.com/docs/integrations/llms/google_ai

Copy link

welcome bot commented Mar 3, 2024

Thanks for submitting your first pull request! You are awesome! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please make sure you followed the pull request template, as this will help us review your contribution more quickly.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also a intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

@giswqs
Copy link
Contributor Author

giswqs commented Mar 3, 2024

I followed the instructions from here to test the new Gemini provider. However, it does not show up on the model list. Any advice?

image

@giswqs giswqs mentioned this pull request Mar 3, 2024
Copy link
Member

@dlqqq dlqqq left a comment

Choose a reason for hiding this comment

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

@giswqs Thank you very much for your contribution! This will be really useful once it's released. There remains only a minor concern that needs to be addressed.

It would also be helpful if you could include a screenshot (or preferably a video) of Gemini working in Jupyter AI after making these changes. That would help verify that this PR behaves as expected. 👍

packages/jupyter-ai-magics/jupyter_ai_magics/providers.py Outdated Show resolved Hide resolved
@giswqs
Copy link
Contributor Author

giswqs commented Mar 5, 2024

@dlqqq I have made the changes as suggested, but Gemini still does not show up on the provider list. Anything else I should change?

The following code snippet works without the jupyter-ai magic command.

from langchain_google_genai import GoogleGenerativeAI

llm = GoogleGenerativeAI(model="gemini-pro")
result = llm.invoke("Write a ballad about LangChain")
print(result)

image

@giswqs
Copy link
Contributor Author

giswqs commented Mar 5, 2024

I figured it out. I just need to reinstall the packages using the following command line. It now works properly

jlpm dev-uninstall && jlpm dev-install

image

@giswqs
Copy link
Contributor Author

giswqs commented Mar 5, 2024

Here is a demo showing Gemini in action @dlqqq @@simonff

gemini-jupyter.mp4

@giswqs
Copy link
Contributor Author

giswqs commented Mar 5, 2024

There are more Gemini models available. Let me work on adding them.
https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models

@giswqs
Copy link
Contributor Author

giswqs commented Mar 5, 2024

I have added a few more gemini models to the list.

image

https://ai.google.dev/api/python/google/generativeai
https://ai.google.dev/api/python/google/generativeai/list_models

# pip install google-generativeai
import pprint
import google.generativeai as genai

for model in genai.list_models():
    pprint.pprint(model.name)

@dlqqq dlqqq added the enhancement New feature or request label Mar 5, 2024
Copy link
Member

@dlqqq dlqqq left a comment

Choose a reason for hiding this comment

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

@giswqs Awesome work, thank you! I've rebased this branch on the latest main and fixed the merge conflicts. Will merge this, pending passing CI. 🚀

I had missed your question earlier in my review, my apologies. You are correct in recognizing that you need to run jlpm dev-install if you are updating the entry points in pyproject.toml. I've opened a new issue to add this info to the contributor documentation, so other contributors won't experience the same pain point. 👍

@dlqqq dlqqq enabled auto-merge (squash) March 6, 2024 00:47
@dlqqq dlqqq merged commit 329ada3 into jupyterlab:main Mar 6, 2024
8 checks passed
Copy link

welcome bot commented Mar 6, 2024

Congrats on your first merged pull request in this project! 🎉
congrats
Thank you for contributing, we are very proud of you! ❤️

@dlqqq
Copy link
Member

dlqqq commented Mar 6, 2024

@meeseeksdev please backport to 1.x

meeseeksmachine pushed a commit to meeseeksmachine/jupyter-ai that referenced this pull request Mar 6, 2024
@dlqqq dlqqq added this to the v2.12.0 milestone Mar 6, 2024
dlqqq pushed a commit that referenced this pull request Mar 6, 2024
@giswqs giswqs deleted the gemini branch March 6, 2024 02:31
dbelgrod pushed a commit to dbelgrod/jupyter-ai that referenced this pull request Jun 10, 2024
* Add Gemini Provider

* Rename GeminiAI

* Use VertexAI

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Change back to langchain-google-genai

* Add gemini as a partner provider

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add more gemini models

* Add Gemini to docs

---------

Co-authored-by: David L. Qiu <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Marchlak pushed a commit to Marchlak/jupyter-ai that referenced this pull request Oct 28, 2024
* Add Gemini Provider

* Rename GeminiAI

* Use VertexAI

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Change back to langchain-google-genai

* Add gemini as a partner provider

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add more gemini models

* Add Gemini to docs

---------

Co-authored-by: David L. Qiu <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants