I have to call Vertex AI Structured Text Prompt model using python and below is the code generated for it after clicking on View Code link. However prior to it, seems like we have to set up Vertex AI SDK for Python. However documentation for setting up this SDK seems to be very complex and spanning across multiple webpages.
May I request to please guide me what high level steps(along with documentation link if possible) I have to follow for setting up Vertex AI SDK for Python?
import vertexai
from vertexai.language_models import TextGenerationModel
vertexai.init(project="project-1-369709", location="us-central1")
parameters = {
"candidate_count": 1,
"max_output_tokens": 1024,
"temperature": 0.2,
"top_p": 0.8,
"top_k": 40
}
model = TextGenerationModel.from_pretrained("text-bison")
response = model.predict(
"""UiPath is a global software company that makes robotic process automation (RPA) software. It was founded in Bucharest, Romania, by Daniel Dines and Marius Tîrcă. Its headquarters are in New York City. The company\'s software monitors user activity to automate repetitive front and back office tasks, including those performed using other business software such as customer relationship management or enterprise resource planning (ERP) software.
In December 2020, the company filed confidentially for an initial public offering, and became public on April 21, 2021.
input: What is Uipath?
output:
""",
**parameters
)
print(f"Response from Model: {response.text}")
Thanks!
Vertex AI SDK
is part of the python libraries available via PyPI.To install it you basically need to run
pip install google-cloud-aiplatform
(assuming that your Python environment is properly setup). After that you will have it available on your pip base as below:And then you can start instantiating the SDK on your Python environment as the documentation you've read shows (here a small example within python console):
Hope that helps.