Skip to content

Commit 348fb92

Browse files
anthonyhungnguyenhungnp
andauthored
Add VertexAI model provider (#1417)
* feat: add vertexai provider * feat: add help documentation for Vertex AI provider authentication requirements --------- Co-authored-by: hungnp <[email protected]>
1 parent 7e2fa6f commit 348fb92

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from jupyter_ai_magics.base_provider import BaseProvider
2+
from langchain_google_vertexai import VertexAI, VertexAIEmbeddings
3+
4+
5+
class VertexAIProvider(BaseProvider, VertexAI):
6+
id = "vertexai"
7+
name = "Vertex AI"
8+
models = [
9+
"gemini-2.5-pro",
10+
"gemini-2.5-flash",
11+
]
12+
model_id_key = "model"
13+
auth_strategy = None
14+
pypi_package_deps = ["langchain-google-vertexai"]
15+
help = (
16+
"To use Vertex AI Generative AI you must have the langchain-google-vertexai Python package installed and either:\n\n"
17+
"- Have credentials configured for your environment (gcloud, workload identity, etc...)\n"
18+
"- Store the path to a service account JSON file as the GOOGLE_APPLICATION_CREDENTIALS environment variable\n\n"
19+
"This codebase uses the google.auth library which first looks for the application credentials variable mentioned above, and then looks for system-level auth. "
20+
"For more information, see the [Vertex AI authentication documentation](https://python.langchain.com/docs/integrations/llms/google_vertex_ai_palm/)."
21+
)
22+
23+
class VertexAIEmbeddingsProvider(BaseProvider, VertexAIEmbeddings):
24+
id = "vertexai"
25+
name = "Vertex AI"
26+
models = [
27+
"text-embedding-004",
28+
]
29+
model_id_key = "model"
30+
auth_strategy = None
31+
pypi_package_deps = ["langchain-google-vertexai"]
32+
help = (
33+
"To use Vertex AI Generative AI you must have the langchain-google-vertexai Python package installed and either:\n\n"
34+
"- Have credentials configured for your environment (gcloud, workload identity, etc...)\n"
35+
"- Store the path to a service account JSON file as the GOOGLE_APPLICATION_CREDENTIALS environment variable\n\n"
36+
"This codebase uses the google.auth library which first looks for the application credentials variable mentioned above, and then looks for system-level auth. "
37+
"For more information, see the [Vertex AI authentication documentation](https://python.langchain.com/docs/integrations/llms/google_vertex_ai_palm/)."
38+
)

packages/jupyter-ai-magics/pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ dependencies = [
3030
"pydantic>=2.10.0,<3",
3131
"click>=8.1.0,<9",
3232
"jsonpath-ng>=1.5.3,<2",
33+
"langchain-google-vertexai",
3334
]
3435

3536
[project.optional-dependencies]
@@ -63,6 +64,7 @@ all = [
6364
"boto3",
6465
"qianfan",
6566
"together",
67+
"langchain-google-vertexai",
6668
]
6769

6870
[project.entry-points."jupyter_ai.model_providers"]
@@ -86,6 +88,7 @@ together-ai = "jupyter_ai_magics:TogetherAIProvider"
8688
gemini = "jupyter_ai_magics.partner_providers.gemini:GeminiProvider"
8789
mistralai = "jupyter_ai_magics.partner_providers.mistralai:MistralAIProvider"
8890
openrouter = "jupyter_ai_magics.partner_providers.openrouter:OpenRouterProvider"
91+
vertexai = "jupyter_ai_magics.partner_providers.vertexai:VertexAIProvider"
8992

9093
[project.entry-points."jupyter_ai.embeddings_model_providers"]
9194
azure = "jupyter_ai_magics.partner_providers.openai:AzureOpenAIEmbeddingsProvider"
@@ -98,6 +101,7 @@ ollama = "jupyter_ai_magics.partner_providers.ollama:OllamaEmbeddingsProvider"
98101
openai = "jupyter_ai_magics.partner_providers.openai:OpenAIEmbeddingsProvider"
99102
openai-custom = "jupyter_ai_magics.partner_providers.openai:OpenAIEmbeddingsCustomProvider"
100103
qianfan = "jupyter_ai_magics:QianfanEmbeddingsEndpointProvider"
104+
vertexai = "jupyter_ai_magics.partner_providers.vertexai:VertexAIEmbeddingsProvider"
101105

102106
[tool.hatch.version]
103107
source = "nodejs"

0 commit comments

Comments
 (0)