vertexai_utils
convert_dict_to_input
Convert content dictionary to Vertex AI Content object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content_dict
|
dict
|
Content dictionary with keys “role” and “parts” where the values are strings. |
required |
media_folder
|
str
|
Folder where media files are stored ({data_folder}/media). |
required |
Returns:
| Type | Description |
|---|---|
Content
|
Vertex AI Content object created from content dictionary |
Source code in src/prompto/apis/vertexai/vertexai_utils.py
parse_parts
Parse “parts” value and create a list of Vertex AI Part object(s). If parts is a single dictionary or a string, a list with a single Part object is returned, otherwise, a list of multiple Part objects is created.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parts
|
list[dict | str] | dict | str
|
Corresponding to the “parts” value in the prompt. Can be a list of dictionaries and strings, or a single dictionary or string. |
required |
media_folder
|
str
|
Folder where media files are stored ({data_folder}/media). |
required |
Returns:
| Type | Description |
|---|---|
list[Part]
|
List of Vertex AI Part object(s) created from “parts” value in a prompt |
Source code in src/prompto/apis/vertexai/vertexai_utils.py
parse_parts_value
Create Vertex AI Part objects from a dictionary or string. If parts is a string, a Part object with text is created. If parts is a dictionary, expected keys are: - type: str, multimedia type, one of [“image”, “video”, “uri” “text”] - media: str, file location (if type is image or video) or text (if type is text). This can be either a local file path (relative to the media folder) or a GCS URI. - mime_type: str, mime type of the image orvideo file, only required if using a GCS URI, or using a local video file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
part
|
dict | str
|
Either a dictionary or a string which defines a Part object. |
required |
media_folder
|
str
|
Folder where media files are stored ({data_folder}/media). |
required |
Returns:
| Type | Description |
|---|---|
Part
|
Vertex AI Part object created from multimedia data |