{"version":3,"sources":["../../src/metrics/deep-equal.ts"],"sourcesContent":["/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as assert from 'assert';\nimport {\n  EvalStatusEnum,\n  type BaseEvalDataPoint,\n  type Score,\n} from 'genkit/evaluator';\n\n/**\n * Deep equality evaluator -- tests output equality against the reference.\n */\nexport async function deepEqual(dataPoint: BaseEvalDataPoint): Promise<Score> {\n  if (!dataPoint.output) {\n    throw new Error('Output was not provided');\n  }\n  if (!dataPoint.reference) {\n    throw new Error('Reference was not provided');\n  }\n\n  try {\n    assert.deepStrictEqual(dataPoint.output, dataPoint.reference);\n    return {\n      score: true,\n      status: EvalStatusEnum.PASS,\n    };\n  } catch (e) {\n    return {\n      score: false,\n      details: { reasoning: `${e instanceof Error ? e.message : e}` },\n      status: EvalStatusEnum.FAIL,\n    };\n  }\n}\n"],"mappings":"AAgBA,YAAY,YAAY;AACxB;AAAA,EACE;AAAA,OAGK;AAKP,eAAsB,UAAU,WAA8C;AAC5E,MAAI,CAAC,UAAU,QAAQ;AACrB,UAAM,IAAI,MAAM,yBAAyB;AAAA,EAC3C;AACA,MAAI,CAAC,UAAU,WAAW;AACxB,UAAM,IAAI,MAAM,4BAA4B;AAAA,EAC9C;AAEA,MAAI;AACF,WAAO,gBAAgB,UAAU,QAAQ,UAAU,SAAS;AAC5D,WAAO;AAAA,MACL,OAAO;AAAA,MACP,QAAQ,eAAe;AAAA,IACzB;AAAA,EACF,SAAS,GAAG;AACV,WAAO;AAAA,MACL,OAAO;AAAA,MACP,SAAS,EAAE,WAAW,GAAG,aAAa,QAAQ,EAAE,UAAU,CAAC,GAAG;AAAA,MAC9D,QAAQ,eAAe;AAAA,IACzB;AAAA,EACF;AACF;","names":[]}