Skip to content

Commit

Permalink
Add gemini as a partner provider
Browse files Browse the repository at this point in the history
  • Loading branch information
giswqs committed Mar 5, 2024
1 parent 0a7513a commit df46d63
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from jupyter_ai_magics.providers import BaseProvider, EnvAuthStrategy
from langchain_google_genai import GoogleGenerativeAI


class GeminiProvider(BaseProvider, GoogleGenerativeAI):
id = "gemini"
name = "Gemini"
models = [
"gemini-pro",
]
model_id_key = "model"
auth_strategy = EnvAuthStrategy(name="GOOGLE_API_KEY")
pypi_package_deps = ["langchain-google-genai"]
17 changes: 1 addition & 16 deletions packages/jupyter-ai-magics/jupyter_ai_magics/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
SagemakerEndpoint,
Together,
)
from langchain_google_genai import GoogleGenerativeAI


# this is necessary because `langchain.pydantic_v1.main` does not include
# `ModelMetaclass`, as it is not listed in `__all__` by the `pydantic.main`
Expand Down Expand Up @@ -901,18 +901,3 @@ class QianfanProvider(BaseProvider, QianfanChatEndpoint):
model_id_key = "model_name"
pypi_package_deps = ["qianfan"]
auth_strategy = MultiEnvAuthStrategy(names=["QIANFAN_AK", "QIANFAN_SK"])


class GeminiProvider(BaseProvider, GoogleGenerativeAI):
id = "gemini"
name = "Gemini"
models = [
"gemini-pro",
]
model_id_key = "model_name"
pypi_package_deps = ["langchain-google-genai"]
auth_strategy = EnvAuthStrategy(name="GOOGLE_API_KEY")

@classmethod
def is_api_key_exc(cls, e: Exception):
return False
1 change: 1 addition & 0 deletions packages/jupyter-ai-magics/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ amazon-bedrock-chat = "jupyter_ai_magics:BedrockChatProvider"
qianfan = "jupyter_ai_magics:QianfanProvider"
nvidia-chat = "jupyter_ai_magics.partner_providers.nvidia:ChatNVIDIAProvider"
together-ai = "jupyter_ai_magics:TogetherAIProvider"
gemini = "jupyter_ai_magics.partner_providers.gemini:GeminiProvider"

[project.entry-points."jupyter_ai.embeddings_model_providers"]
bedrock = "jupyter_ai_magics:BedrockEmbeddingsProvider"
Expand Down

0 comments on commit df46d63

Please sign in to comment.