def extract_embedding()

in src/fmeval/model_runners/extractors/json_extractor.py [0:0]


    def extract_embedding(self, data: Union[List, Dict], num_records: int) -> Union[List[float]]:
        """
        Extract embedding from JSON model output

        :param data: Model response. The embedding_jmespath_expression is used to extract the predicted output. The
                     predicted output must be a string
        :param num_records: number of inference records in the model output
        :return: model output
        """
        assert num_records == 1, "JSON extractor does not support batch requests"
        util.require(
            self.embedding_jmespath_expression,
            "Extractor cannot extract embedding as embedding_jmespath_expression is not provided",
        )
        embedding = self.embedding_jmespath.search(data)
        util.require(embedding is not None, f"JMESpath {self.embedding_jmespath_expression} could not find any data")
        util.require(
            isinstance(embedding, List), f"Extractor found: {embedding} which does not match expected type {List}"
        )
        return embedding