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

docs: vertexai updates #1841

Merged
merged 4 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions docs/plugins/vertex-ai.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The Vertex AI plugin provides interfaces to several AI services:
* Gemini text generation
* Imagen2 and Imagen3 image generation
* Text embedding generation
* Multimodal embedding generation
* A subset of evaluation metrics through the Vertex AI [Rapid Evaluation API](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/evaluation):
* [BLEU](https://cloud.google.com/vertex-ai/docs/reference/rest/v1beta1/projects.locations/evaluateInstances#bleuinput)
* [ROUGE](https://cloud.google.com/vertex-ai/docs/reference/rest/v1beta1/projects.locations/evaluateInstances#rougeinput)
Expand Down Expand Up @@ -130,7 +131,7 @@ const ai = genkit({
});
```

Or you can generate an embedding directly:
Or you can generate embeddings directly:

```ts
const ai = genkit({
Expand All @@ -146,6 +147,8 @@ const embeddings = await ai.embed({
This plugin can also handle multimodal embeddings:

```ts
import { multimodalEmbedding001, vertexAI } from '@genkit-ai/vertexai';

const ai = genkit({
plugins: [vertextAI({location: 'us-central1' })],
});
Expand Down Expand Up @@ -218,7 +221,7 @@ Refer to [Imagen model documentation](https://cloud.google.com/vertex-ai/generat

If you have access to Claude 3 models ([haiku](https://console.cloud.google.com/vertex-ai/publishers/anthropic/model-garden/claude-3-haiku), [sonnet](https://console.cloud.google.com/vertex-ai/publishers/anthropic/model-garden/claude-3-sonnet) or [opus](https://console.cloud.google.com/vertex-ai/publishers/anthropic/model-garden/claude-3-opus)) in Vertex AI Model Garden you can use them with Genkit.

Here's sample configuration for enabling Vertex AI Model Garden models:
Here's a sample configuration for enabling Vertex AI Model Garden models:

```ts
import { genkit } from 'genkit';
Expand Down Expand Up @@ -268,7 +271,7 @@ const ai = genkit({
});
```

Then use it as regular models:
Then use it as a regular model:

```ts
const llmResponse = await ai.generate({
Expand All @@ -281,7 +284,7 @@ const llmResponse = await ai.generate({

If you have access to Mistral models ([Mistral Large](https://console.cloud.google.com/vertex-ai/publishers/mistralai/model-garden/mistral-large), [Mistral Nemo](https://console.cloud.google.com/vertex-ai/publishers/mistralai/model-garden/mistral-nemo), or [Codestral](https://console.cloud.google.com/vertex-ai/publishers/mistralai/model-garden/codestral)) in Vertex AI Model Garden, you can use them with Genkit.

Here's sample configuration for enabling Vertex AI Model Garden models:
Here's a sample configuration for enabling Vertex AI Model Garden models:

```ts
import { genkit } from 'genkit';
Expand Down Expand Up @@ -388,9 +391,9 @@ Important: Pricing for Vector Search consists of both a charge for every gigabyt

To use Vertex AI Vector Search:

1. Choose an embedding model. This model is responsible for creating vector embeddings from text. Advanced users might use an embedding model optimized for their particular data sets, but for most users, Vertex AI's `text-embedding-004` model is a good choice for English text and the `text-multilingual-embedding-002` model is good for multilingual text.
1. Choose an embedding model. This model is responsible for creating vector embeddings from text or media. Advanced users might use an embedding model optimized for their particular data sets, but for most users, Vertex AI's `text-embedding-004` model is a good choice for English text, the `text-multilingual-embedding-002` model is good for multilingual text, and the `multimodalEmbedding001` model is good for mixed text, images, and video.
2. In the [Vector Search](https://console.cloud.google.com/vertex-ai/matching-engine/indexes) section of the Google Cloud console, create a new index. The most important settings are:
* **Dimensions:** Specify the dimensionality of the vectors produced by your chosen embedding model. The `text-embedding-004` and `text-multilingual-embedding-002` models produce vectors of 768 dimensions.
* **Dimensions:** Specify the dimensionality of the vectors produced by your chosen embedding model. The `text-embedding-004` and `text-multilingual-embedding-002` models produce vectors of 768 dimensions. The `multimodalEmbedding001` model can produce vectors of 128, 256, 512, or 1408 dimensions for text and image, and will produce vectors of 1408 dimensions for video.
* **Update method:** Select streaming updates.

After you create the index, deploy it to a standard (public) endpoint.
Expand Down
2 changes: 1 addition & 1 deletion js/testapps/custom-evaluators/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"build:clean": "rimraf ./lib",
"build:watch": "tsc --watch",
"dev": "tsx --watch src/index.ts",
"genkit:dev": "cross-env GENKIT_ENV=dev pnpm dev"
"genkit:dev": "genkit start -- tsx --watch src/index.ts"
},
"keywords": [],
"author": "",
Expand Down
2 changes: 1 addition & 1 deletion js/testapps/dev-ui-gallery/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"start": "node lib/index.js",
"dev": "tsx --watch src/index.ts",
"genkit:dev": "cross-env GENKIT_ENV=dev pnpm dev",
"genkit:dev": "genkit start -- tsx --watch src/index.ts",
"compile": "tsc",
"build": "pnpm build:clean && pnpm compile",
"build:clean": "rimraf ./lib",
Expand Down
2 changes: 1 addition & 1 deletion js/testapps/esm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"start": "node lib/index.js",
"dev": "tsx --watch src/index.ts",
"genkit:dev": "cross-env GENKIT_ENV=dev pnpm dev",
"genkit:dev": "genkit start -- tsx --watch src/index.ts",
"compile": "tsc",
"build": "pnpm build:clean && pnpm compile",
"build:clean": "rimraf ./lib",
Expand Down
2 changes: 1 addition & 1 deletion js/testapps/evals/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"build:watch": "tsc --watch",
"build-and-run": "pnpm build && node lib/index.js",
"dev": "tsx --watch src/index.ts",
"genkit:dev": "cross-env GENKIT_ENV=dev pnpm dev"
"genkit:dev": "genkit start -- tsx --watch src/index.ts"
},
"keywords": [],
"author": "",
Expand Down
2 changes: 1 addition & 1 deletion js/testapps/multimodal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"start": "node lib/index.js",
"dev": "tsx --watch src/index.ts",
"genkit:dev": "cross-env GENKIT_ENV=dev pnpm dev",
"genkit:dev": "genkit start -- tsx --watch src/index.ts",
"compile": "tsc",
"build": "pnpm build:clean && pnpm compile",
"build:clean": "rimraf ./lib",
Expand Down
2 changes: 1 addition & 1 deletion js/testapps/ollama/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"start": "node lib/index.js",
"build": "tsc",
"build:watch": "tsc --watch",
"genkit:dev": "cross-env GENKIT_ENV=dev pnpm dev",
"genkit:dev": "genkit start -- tsx --watch src/index.ts",
"dev": "tsx --watch src/index.ts"
},
"keywords": [],
Expand Down
2 changes: 1 addition & 1 deletion js/testapps/rag/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"start": "node lib/index.js",
"dev": "tsx --watch src/index.ts",
"genkit:dev": "cross-env GENKIT_ENV=dev pnpm dev",
"genkit:dev": "genkit start -- tsx --watch src/index.ts",
"compile": "tsc",
"build": "pnpm build:clean && pnpm compile",
"build:clean": "rimraf ./lib",
Expand Down
2 changes: 1 addition & 1 deletion js/testapps/vertexai-vector-search-firestore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ the core packages. This sample uses `workspace:*` dependencies, so they will nee
Then

```bash
cd js/testapps/vertex-vector-search-bigquery && pnpm i
cd js/testapps/vertexai-vector-search-firestore && pnpm i
```

### Step 3: Set Up Environment Variables
Expand Down
2 changes: 2 additions & 0 deletions js/testapps/vertexai-vector-search-firestore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"main": "lib/index.js",
"scripts": {
"start": "node lib/index.js",
"dev": "tsx --watch src/index.ts",
"genkit:dev": "genkit start -- tsx --watch src/index.ts",
"compile": "tsc",
"build": "pnpm build:clean && pnpm compile",
"build:clean": "rimraf ./lib",
Expand Down
Loading