Google - GenAI Product Catalog
GitHub Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Embeddings

aiplatform_v1

embeddings

utils

Config

index_client

search_index_id

insert_dp

def insert_dp(dp_id: str, emb: list[float], cat=[])

upsert_dp

def upsert_dp(prod_id: str, desc: str, image: str, cat=[])

remove_dp

def remove_dp(dp_id: str)

delete_dp

def delete_dp(prod_id: str)

Invoke Vertex Embedding API.

logging

cache

NamedTuple

Optional

Sequence

aiplatform

struct_pb2

Config

EmbeddingResponse Objects

class EmbeddingResponse(NamedTuple)

text_embedding

image_embedding

EmbeddingPredictionClient Objects

class EmbeddingPredictionClient()

Wrapper around Prediction Service Client.

__init__

def __init__()

get_embedding

def get_embedding(text: Optional[str] = None,
                  image: Optional[str] = None,
                  base64: bool = False)

Invoke Vertex multimodal embedding API.

You can pass text and/or image. If neither is passed will raise exception

Args: text: text to embed image: can be local file path, GCS URI or base64 encoded image base64: True indicates image is base64. False (default) will be interpreted as image path (either local or GCS) Returns: named tuple with the following attributes: text_embedding: 1408 dimension vector of type Sequence[float] image_embedding: 1408 dimension vector of type Sequence[float] OR None if no image provide

get_client

@cache
def get_client(project)

embed

def embed(
    text: str,
    image: Optional[str] = None,
    base64: bool = False,
    project: str = Config.value("project", "id")
) -> EmbeddingResponse

Invoke vertex multimodal embedding API.

Args: text: text to embed image: can be local file path, GCS URI or base64 encoded image base64: True indicates image is base64. False (default) will be interpreted as image path (either local or GCS) project: GCP Project ID

Returns: named tuple with the following attributes: text_embedding: 1408 dimension vector of type Sequence[float] image_embedding: 1408 dimension vector of type Sequence[float] OR None if no image provide