@@ -234,28 +234,32 @@ class MultiModalEmbeddingModel(_model_garden_models._ModelGardenModel):
234234 )
235235
236236 def get_embeddings (
237- self , image : Image , contextual_text : Optional [str ] = None
237+ self , image : Optional [ Image ] = None , contextual_text : Optional [str ] = None
238238 ) -> "MultiModalEmbeddingResponse" :
239239 """Gets embedding vectors from the provided image.
240240
241241 Args:
242242 image (Image):
243- The image to generate embeddings for.
243+ Optional. The image to generate embeddings for. One of `image` or `contextual_text` is required .
244244 contextual_text (str):
245245 Optional. Contextual text for your input image. If provided, the model will also
246246 generate an embedding vector for the provided contextual text. The returned image
247247 and text embedding vectors are in the same semantic space with the same dimensionality,
248248 and the vectors can be used interchangeably for use cases like searching image by text
249- or searching text by image.
249+ or searching text by image. One of `image` or `contextual_text` is required.
250250
251251 Returns:
252252 ImageEmbeddingResponse:
253253 The image and text embedding vectors.
254254 """
255255
256- instance = {
257- "image" : {"bytesBase64Encoded" : image ._as_base64_string ()},
258- }
256+ if not image and not contextual_text :
257+ raise ValueError ("One of `image` or `contextual_text` is required." )
258+
259+ instance = {}
260+
261+ if image :
262+ instance ["image" ] = {"bytesBase64Encoded" : image ._as_base64_string ()}
259263
260264 if contextual_text :
261265 instance ["text" ] = contextual_text
@@ -280,11 +284,11 @@ class MultiModalEmbeddingResponse:
280284
281285 Attributes:
282286 image_embedding (List[float]):
283- The emebedding vector generated from your image.
287+ Optional. The embedding vector generated from your image.
284288 text_embedding (List[float]):
285289 Optional. The embedding vector generated from the contextual text provided for your image.
286290 """
287291
288- image_embedding : List [float ]
289292 _prediction_response : Any
293+ image_embedding : Optional [List [float ]] = None
290294 text_embedding : Optional [List [float ]] = None
0 commit comments