def extract_output()

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


    def extract_output(self, data: Union[List, Dict], num_records: int = 1) -> str:
        """
        Extracts the output string from the JumpStartModel response. This value is provided by all JS text models, but
        not all JS FM models. This only supported for text-to-text models.

        :param data: The model response from the JumpStart Model
        :param num_records: The number of records in the model response. Must be 1.
        """
        assert num_records == 1, "Jumpstart extractor does not support batch requests"
        try:
            assert (
                self._output_jmespath_compiler
            ), f"Unable to extract generated text from Jumpstart model: {self._model_id}"
            output = self._output_jmespath_compiler.search(data)
            if output is None and not isinstance(output, str):
                raise EvalAlgorithmClientError(f"Unable to extract output from Jumpstart model: {self._model_id}")
            return output
        except ValueError as e:
            raise EvalAlgorithmClientError(f"Unable to extract output from Jumpstart model: {self._model_id}", e)