Skip to content

Commit d0d6b70

Browse files
authored
Upgrade gemini models (#314)
1 parent 54a6413 commit d0d6b70

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

integrations/google-vertex-ai.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,17 @@ pip install google-vertex-haystack
4747
## Usage
4848

4949
Once installed, you will have access to various Haystack Generators:
50-
- [`VertexAIGeminiGenerator`](https://docs.haystack.deepset.ai/docs/vertexaigeminigenerator): Use this component with Gemini models '**gemini-pro**' and '**gemini-1.5-flash**' for text generation and multimodal prompts.
51-
- [`VertexAIGeminiChatGenerator`](https://docs.haystack.deepset.ai/docs/vertexaigeminichatgenerator): Use this component with Gemini models '**gemini-pro**' and '**gemini-1.5-flash**' for text generation, multimodal prompts and function calling in chat completion setting.
50+
- [`VertexAIGeminiGenerator`](https://docs.haystack.deepset.ai/docs/vertexaigeminigenerator): Use this component with Gemini models '**gemini-1.5-pro**', '**gemini-1.5-flash**', '**gemini-2.0-flash**' for text generation and multimodal prompts.
51+
- [`VertexAIGeminiChatGenerator`](https://docs.haystack.deepset.ai/docs/vertexaigeminichatgenerator): Use this component with Gemini models '**gemini-1.5-pro**', '**gemini-1.5-flash**', '**gemini-2.0-flash**' for text generation, multimodal prompts and function calling in chat completion setting.
5252
- `VertexAITextGenerator`: Use this component with PaLM models for text generation.
5353
- `VertexAICodeGenerator`: Use this component with Codey model for code generation and code completion.
5454
- `VertexAIImageGenerator`: Use this component with Imagen model '**imagegeneration**' for image generation.
5555
- [`VertexAIImageCaptioner`](https://docs.haystack.deepset.ai/docs/vertexaiimagecaptioner): Use this component with Imagen model '**imagetext**' for image captioning.
5656
- `VertexAIImageQA`: Use this component with Imagen model '**imagetext**' for visual question answering.
5757

5858
To use Vertex AI models, you need to have a Google Cloud Platform account and be logged in using Application Default Credentials (ADCs). For more info see the [official documentation](https://colab.research.google.com/corgiredirector?site=https%3A%2F%2Fcloud.google.com%2Fdocs%2Fauthentication%2Fprovide-credentials-adc).
59+
`VertexAIGeminiGenerator` and `VertexAIGeminiChatGenerator` support both `gemini-1.5-pro` and `gemini-1.5-flash`/ `gemini-2.0-flash` models.
60+
Note that [Google recommends upgrading](https://cloud.google.com/vertex-ai/generative-ai/docs/learn/model-versions) from `gemini-1.5-pro` to `gemini-2.0-flash`.
5961

6062
To start using Vertex AI generators in Haystack, it is essential that your account has access to a project authorized to use Google Vertex AI endpoints. The `project_id` needed for initialization of Vertex AI generators is set during GCP authentication mentioned above. Additonally, you can also set a different `project_id` by passing it as a variable during initialization of the generator.
6163
You can find your `project_id` in the [GCP resource manager](https://console.cloud.google.com/cloud-resource-manager) or locally by running `gcloud projects list` in your terminal. For more info on the gcloud CLI see the [official documentation](https://cloud.google.com/cli).
@@ -64,15 +66,15 @@ You can find your `project_id` in the [GCP resource manager](https://console.clo
6466

6567
You can leverage Gemini models through two components: [VertexAIGeminiGenerator](https://docs.haystack.deepset.ai/docs/vertexaigeminigenerator) and [VertexAIGeminiChatGenerator](https://docs.haystack.deepset.ai/docs/vertexaigeminichatgenerator). You can use these components on their own or in a pipeline.
6668

67-
**Text Generation with `gemini-pro`**
69+
**Text Generation with `gemini-1.5-pro`**
6870

69-
To use Gemini model for text generation, initialize a `VertexAIGeminiGenerator` with `"gemini-pro"` and `project_id`:
71+
To use Gemini model for text generation, initialize a `VertexAIGeminiGenerator` with `"gemini-1.5-pro"` and `project_id`:
7072

7173
```python
7274
from haystack_integrations.components.generators.google_vertex import VertexAIGeminiGenerator
7375

7476

75-
gemini_generator = VertexAIGeminiGenerator(model="gemini-pro")
77+
gemini_generator = VertexAIGeminiGenerator(model="gemini-1.5-pro")
7678
result = gemini_generator.run(parts = ["What is assemblage in art?"])
7779
print(result["replies"][0])
7880
```
@@ -81,9 +83,9 @@ Output:
8183
Assemblage in art refers to the creation of a three-dimensional artwork by combining various found objects...
8284
```
8385

84-
**Multimodality with `gemini-1.5-flash`**
86+
**Multimodality with `gemini-2.0-flash`**
8587

86-
To use `gemini-1.5-flash` model for visual question answering, initialize a `VertexAIGeminiGenerator` with `"gemini-1.5-flash"`. Then, run it with the images as well as the prompt:
88+
To use `gemini-2.0-flash` model for visual question answering, initialize a `VertexAIGeminiGenerator` with `"gemini-2.0-flash"`. Then, run it with the images as well as the prompt:
8789

8890
```python
8991
import requests
@@ -100,7 +102,7 @@ images = [
100102
ByteStream(data=requests.get(url).content, mime_type="image/jpeg")
101103
for url in URLS
102104
]
103-
gemini_generator = VertexAIGeminiGenerator(model="gemini-1.5-flash")
105+
gemini_generator = VertexAIGeminiGenerator(model="gemini-2.0-flash")
104106
result = gemini_generator.run(parts = ["What can you tell me about these robots?", *images])
105107
for answer in result["replies"]:
106108
print(answer)
@@ -113,7 +115,7 @@ The third image is of Gort from the 1951 film The Day the Earth Stood Still...
113115
The fourth image is of Marvin from the 1977 film The Hitchhiker's Guide to the Galaxy...
114116
```
115117
116-
*For function calling with `gemini-pro`, refer to the [Notebook](https://haystack.deepset.ai/cookbook/vertexai-gemini-examples).*
118+
*For function calling with `gemini-1.5-pro`, refer to the [Notebook](https://haystack.deepset.ai/cookbook/vertexai-gemini-examples).*
117119
118120
### PaLM API Models
119121

0 commit comments

Comments
 (0)