(results: QuestionResultRecord[], selectedCount: number, config: RunnerConfig)
| 841 | } |
| 842 | |
| 843 | function buildSummary(results: QuestionResultRecord[], selectedCount: number, config: RunnerConfig): RunSummary { |
| 844 | const rows: RunSummaryRow[] = LONGMEMEVAL_QUESTION_TYPES.map((category) => { |
| 845 | const items = results.filter((result) => result.question_type === category); |
| 846 | const correct = items.reduce((sum, item) => sum + item.score, 0); |
| 847 | return { |
| 848 | category, |
| 849 | correct, |
| 850 | total: items.length, |
| 851 | accuracy: items.length === 0 ? 0 : correct / items.length, |
| 852 | }; |
| 853 | }); |
| 854 | |
| 855 | const overallCorrect = results.reduce((sum, item) => sum + item.score, 0); |
| 856 | rows.push({ |
| 857 | category: "overall", |
| 858 | correct: overallCorrect, |
| 859 | total: results.length, |
| 860 | accuracy: results.length === 0 ? 0 : overallCorrect / results.length, |
| 861 | }); |
| 862 | |
| 863 | const tokens = results.reduce( |
| 864 | (acc, result) => addTokenUsage(acc, result.token_usage.total), |
| 865 | createEmptyTokenUsageStats(), |
| 866 | ); |
| 867 | const totalActualUsd = results.reduce((sum, result) => sum + result.costs.totalActualUsd, 0); |
| 868 | const totalEstimatedUsd = results.reduce((sum, result) => sum + result.costs.totalEstimatedUsd, 0); |
| 869 | |
| 870 | return { |
| 871 | generatedAt: nowIso(), |
| 872 | datasetPath: config.datasetPath, |
| 873 | selectionSignature: config.selectionSignature, |
| 874 | completedQuestions: results.length, |
| 875 | selectedQuestions: selectedCount, |
| 876 | pendingQuestions: Math.max(selectedCount - results.length, 0), |
| 877 | rows, |
| 878 | costs: { |
| 879 | totalActualUsd, |
| 880 | totalEstimatedUsd, |
| 881 | }, |
| 882 | tokens, |
| 883 | }; |
| 884 | } |
| 885 | |
| 886 | function printSummary(summary: RunSummary): void { |
| 887 | console.log("\nLongMemEval summary"); |
no test coverage detected