(
testSuite: EvaluateTestSuite,
options: InternalEvaluateOptions = {},
)
| 315 | } |
| 316 | |
| 317 | export async function evaluateWithSource( |
| 318 | testSuite: EvaluateTestSuite, |
| 319 | options: InternalEvaluateOptions = {}, |
| 320 | ) { |
| 321 | const { author: suiteAuthor, ...testSuiteConfig } = testSuite; |
| 322 | |
| 323 | if (testSuiteConfig.writeLatestResults) { |
| 324 | await runDbMigrations(); |
| 325 | } |
| 326 | |
| 327 | const loadedProviders = await loadApiProviders(testSuiteConfig.providers, { |
| 328 | env: testSuiteConfig.env, |
| 329 | }); |
| 330 | const providerMap = buildConfiguredProviderMap(loadedProviders); |
| 331 | const constructedTestSuite = await createRuntimeTestSuite(testSuiteConfig, loadedProviders); |
| 332 | await resolveNestedProviders(testSuiteConfig, constructedTestSuite, providerMap); |
| 333 | |
| 334 | const parsedProviderPromptMap = readProviderPromptMap( |
| 335 | testSuiteConfig, |
| 336 | constructedTestSuite.prompts, |
| 337 | ); |
| 338 | const unifiedConfig = createSerializableUnifiedConfig( |
| 339 | testSuiteConfig, |
| 340 | constructedTestSuite.prompts, |
| 341 | ); |
| 342 | const author = getAuthor(suiteAuthor); |
| 343 | const evalRecord = testSuiteConfig.writeLatestResults |
| 344 | ? await Eval.create(unifiedConfig, constructedTestSuite.prompts, { author }) |
| 345 | : new Eval(unifiedConfig, { author }); |
| 346 | |
| 347 | const ret = await cache.withCacheEnabled(options.cache === false ? false : undefined, () => |
| 348 | doEvaluate( |
| 349 | { |
| 350 | ...constructedTestSuite, |
| 351 | providerPromptMap: parsedProviderPromptMap, |
| 352 | }, |
| 353 | evalRecord, |
| 354 | { |
| 355 | isRedteam: Boolean(testSuiteConfig.redteam), |
| 356 | ...options, |
| 357 | }, |
| 358 | ), |
| 359 | ); |
| 360 | |
| 361 | await maybeShareEval(testSuiteConfig, ret); |
| 362 | if (testSuiteConfig.outputPath) { |
| 363 | const outputPaths = |
| 364 | typeof testSuiteConfig.outputPath === 'string' |
| 365 | ? [testSuiteConfig.outputPath] |
| 366 | : testSuiteConfig.outputPath; |
| 367 | warnOnDegradedJsonlRecovery(evalRecord, outputPaths); |
| 368 | // writeMultipleOutputs maps each path through writeOutput, so it covers the single-path |
| 369 | // case too — matching the doEval call site in src/node/doEval.ts. |
| 370 | if (outputPaths.length) { |
| 371 | await writeMultipleOutputs(outputPaths, evalRecord, null); |
| 372 | } |
| 373 | } |
| 374 |
no test coverage detected
searching dependent graphs…