diff --git a/clarifai/client/input.py b/clarifai/client/input.py index 2bb259fb..8b79d9e4 100644 --- a/clarifai/client/input.py +++ b/clarifai/client/input.py @@ -283,15 +283,17 @@ def get_text_input(input_id: str, raw_text: str, dataset_id: str = None, @staticmethod def get_multimodal_input(input_id: str, raw_text: str, + text_bytes: bytes = None, image_url: str = None, image_bytes: bytes = None, dataset_id: str = None, **kwargs) -> Text: - """Create input proto for text data type from raw text and image from bytes or url. + """Create input proto for text and image from bytes or url. Args: input_id (str): The input ID for the input to create. raw_text (str): The raw text input. + text_bytes (str): The bytes for the text. image_url (str): The url for the image. image_bytes (str): The bytes for the image. dataset_id (str): The dataset ID for the dataset to add the input to. @@ -304,8 +306,10 @@ def get_multimodal_input(input_id: str, >>> from clarifai.client.input import Inputs >>> input_protos = Inputs.get_multimodal_input(input_id = 'demo', raw_text = 'What time of day is it?', image_url='https://samples.clarifai.com/metro-north.jpg') """ - image_pb = resources_pb2.Image(base64=image_bytes) if image_bytes and not image_url else None - image_pb = resources_pb2.Image(url=image_url) if image_url and not image_bytes else None + # Will only use URL if both bytes and URL are supplied. + image_pb = resources_pb2.Image(base64=image_bytes) if image_bytes else None + image_pb = resources_pb2.Image(url=image_url) if image_url else None + text_pb = resources_pb2.Text(raw=text_bytes) if text_bytes else None text_pb = resources_pb2.Text(raw=raw_text) return Inputs._get_proto( input_id=input_id, dataset_id=dataset_id, imagepb=image_pb, text_pb=text_pb, **kwargs)