( firstOutput: DatasetEntryOutput["output"], secondOutput: DatasetEntryOutput["output"], )
| 515 | }; |
| 516 | |
| 517 | const 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 | |
| 544 | const formatDatasetEntryInputInstructions = (datasetEntryInput: DatasetEntryInput) => { |
| 545 | const { messages, tool_choice, tools } = typedDatasetEntryInput(datasetEntryInput); |
no outgoing calls
no test coverage detected