in experiments/legacy/backend/embeddings.py [0:0]
def embed(
text: str,
image: Optional[str] = None,
base64: bool = False,
project: str = config.PROJECT) -> 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
"""
client = get_client(project)
start = time.time()
response = client.get_embedding(text=text, image=image, base64=base64)
end = time.time()
return response