MCPcopy Index your code
hub / github.com/OpenPipe/OpenPipe / outputsAreEqual

Function outputsAreEqual

app/src/server/tasks/evaluateTestSetEntries.task.ts:517–542  ·  view source on GitHub ↗
(
  firstOutput: DatasetEntryOutput["output"],
  secondOutput: DatasetEntryOutput["output"],
)

Source from the content-addressed store, hash-verified

515};
516
517const outputsAreEqual = (
518 firstOutput: DatasetEntryOutput["output"],
519 secondOutput: DatasetEntryOutput["output"],
520) => {
521 try {
522 const typedFirstOutput = chatCompletionMessage.parse(firstOutput);
523 const typedSecondOutput = chatCompletionMessage.parse(secondOutput);
524
525 typedFirstOutput.tool_calls = typedFirstOutput.tool_calls?.map((call) => ({
526 ...call,
527 // Remove ids, which are not relevant to the comparison
528 id: "",
529 // Ignore differences in the serialization of arguments
530 function: { ...call.function, arguments: JSON.parse(call.function.arguments) },
531 }));
532 typedSecondOutput.tool_calls = typedSecondOutput.tool_calls?.map((call) => ({
533 ...call,
534 id: "",
535 function: { ...call.function, arguments: JSON.parse(call.function.arguments) },
536 }));
537
538 return isEqual(typedFirstOutput, typedSecondOutput);
539 } catch {
540 return false;
541 }
542};
543
544const formatDatasetEntryInputInstructions = (datasetEntryInput: DatasetEntryInput) => {
545 const { messages, tool_choice, tools } = typedDatasetEntryInput(datasetEntryInput);

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected