/ docs-website / versioned_docs / version-2.18 / pipeline-components / generators / vertexaitextgenerator.mdx
vertexaitextgenerator.mdx
1 --- 2 title: "VertexAITextGenerator" 3 id: vertexaitextgenerator 4 slug: "/vertexaitextgenerator" 5 description: "This component enables text generation using Google Vertex AI generative models." 6 --- 7 8 # VertexAITextGenerator 9 10 This component enables text generation using Google Vertex AI generative models. 11 12 | | | 13 | --- | --- | 14 | **Mandatory run variables** | “prompt”: A string containing the prompt for the model | 15 | **Output variables** | “replies”: A list of strings containing answers generated by the model <br /> <br />”safety_attributes”: A dictionary containing scores for safety attributes <br /> <br />”citations”: A list of dictionaries containing grounding citations | 16 | **API reference** | [Google Vertex](/reference/integrations-google-vertex) | 17 | **GitHub link** | https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/google_vertex | 18 19 `VertexAITextGenerator` supports `text-bison`, `text-unicorn` and `text-bison-32k` models. 20 21 ### Parameters Overview 22 23 `VertexAITextGenerator` uses Google Cloud Application Default Credentials (ADCs) for authentication. For more information on how to set up ADCs, see the [official documentation](https://cloud.google.com/docs/authentication/provide-credentials-adc). 24 25 Keep in mind that it’s essential to use an account that has access to a project authorized to use Google Vertex AI endpoints. 26 27 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 its [official documentation](https://cloud.google.com/cli). 28 29 ## Usage 30 31 You need to install `google-vertex-haystack` package to use the `VertexAITextGenerator`: 32 33 ```python 34 pip install google-vertex-haystack 35 ``` 36 37 ### On its own 38 39 Basic usage: 40 41 ````python 42 from haystack_integrations.components.generators.google_vertex import VertexAITextGenerator 43 44 generator = VertexAITextGenerator() 45 res = generator.run("Tell me a good interview question for a software engineer.") 46 47 print(res["replies"][0]) 48 49 ```` 50 51 You can also set other parameters like the number of answers generated, temperature to control the randomness, and stop sequences to stop generation. For a full list of possible parameters, see the documentation of [`TextGenerationModel.predict()`](https://cloud.google.com/python/docs/reference/aiplatform/latest/vertexai.language_models.TextGenerationModel#vertexai_language_models_TextGenerationModel_predict). 52 53 ```python 54 from haystack_integrations.components.generators.google_vertex import VertexAITextGenerator 55 56 generator = VertexAITextGenerator( 57 candidate_count=3, 58 temperature=0.2, 59 stop_sequences=["example", "Example"], 60 ) 61 res = generator.run("Tell me a good interview question for a software engineer.") 62 63 for answer in res["replies"]: 64 print(answer) 65 print("-----") 66 67 ```