def get_input_type()

in assets/batch_score_oss/components/driver/src/batch_score_oss/common/request_modification/modifiers/input_type_modifier.py [0:0]


    def get_input_type(request_obj: any) -> InputType:
        """Classify the request based on message type."""
        inputType = InputType.Unknown
        if not isinstance(request_obj, dict) or "messages" not in request_obj or not request_obj["messages"]:
            return inputType

        for message in request_obj["messages"]:
            if "content" not in message or not message["content"]:
                continue
            for item in message["content"]:
                if isinstance(item, str):
                    if inputType == InputType.Unknown:
                        inputType = InputType.TextOnly
                    elif inputType == InputType.Image:
                        inputType = InputType.ImageAndText
                elif isinstance(item, dict) and "type" in item:
                    if item["type"] == IMAGE_CONTENT_TYPE or item["type"] == IMAGE_URL_CONTENT_TYPE:
                        if inputType == InputType.Unknown:
                            inputType = InputType.Image
                        elif inputType == InputType.TextOnly:
                            inputType = InputType.ImageAndText
                    elif item["type"] == TEXT_CONTENT_TYPE:
                        if inputType == InputType.Unknown:
                            inputType = InputType.TextOnly
                        elif inputType == InputType.Image:
                            inputType = InputType.ImageAndText

        return inputType