MCPcopy
hub / github.com/promptfoo/promptfoo / runEvalInternal

Function runEvalInternal

src/evaluator.ts:1399–1596  ·  view source on GitHub ↗
({
  provider,
  prompt, // raw prompt
  test,
  testSuite,
  delay,
  nunjucksFilters: filters,
  evaluateOptions,
  // TODO(ian): Rename these public `Idx` fields to `Index` with compatibility handling.
  testIdx: testIndex,
  promptIdx: promptIndex,
  repeatIndex,
  conversations,
  registers,
  isRedteam,
  abortSignal,
  deferGrading,
  evalId,
  providerCallQueue,
  rateLimitRegistry,
}: RunEvalOptions)

Source from the content-addressed store, hash-verified

1397}
1398
1399async function runEvalInternal({
1400 provider,
1401 prompt, // raw prompt
1402 test,
1403 testSuite,
1404 delay,
1405 nunjucksFilters: filters,
1406 evaluateOptions,
1407 // TODO(ian): Rename these public `Idx` fields to `Index` with compatibility handling.
1408 testIdx: testIndex,
1409 promptIdx: promptIndex,
1410 repeatIndex,
1411 conversations,
1412 registers,
1413 isRedteam,
1414 abortSignal,
1415 deferGrading,
1416 evalId,
1417 providerCallQueue,
1418 rateLimitRegistry,
1419}: RunEvalOptions): Promise<EvaluateResult[]> {
1420 provider.delay ??= delay ?? getEnvInt('PROMPTFOO_DELAY_MS', 0);
1421 invariant(
1422 typeof provider.delay === 'number',
1423 `Provider delay should be set for ${provider.label}`,
1424 );
1425
1426 const state = createRunEvalState({ provider, prompt, test });
1427 attachConversationVar({
1428 conversations,
1429 conversationKey: state.conversationKey,
1430 prompt,
1431 test,
1432 vars: state.vars,
1433 });
1434 Object.assign(state.vars, registers);
1435 Object.assign(
1436 state.vars,
1437 getEvalRuntimeVars({
1438 evalId,
1439 promptIndex,
1440 repeatIndex,
1441 testIndex,
1442 }),
1443 );
1444
1445 let setup = state.setup;
1446 let latencyMs = 0;
1447 let traceContext: Awaited<ReturnType<typeof generateTraceContextIfNeeded>> | undefined;
1448
1449 try {
1450 const rendered = await renderRunEvalPrompt({
1451 filters,
1452 isRedteam,
1453 provider,
1454 promptForRender: state.promptForRender,
1455 test,
1456 testSuite,

Callers 2

runEvalFunction · 0.85

Calls 15

getEnvIntFunction · 0.90
safeJsonStringifyFunction · 0.90
invariantFunction · 0.85
createRunEvalStateFunction · 0.85
attachConversationVarFunction · 0.85
getEvalRuntimeVarsFunction · 0.85
renderRunEvalPromptFunction · 0.85
callProviderForRunEvalFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…