@absolutejs/absolute 0.19.0-beta.514 → 0.19.0-beta.516

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,7 +9,7 @@ export { anthropicOCR, geminiOCR, ollamaOCR, ollamaTranscriber, openaiCompatible
9
9
  export { createRAGGmailEmailSyncClient, createRAGGraphEmailSyncClient, createRAGIMAPEmailSyncClient } from './emailProviders';
10
10
  export { buildRAGUpsertInputFromDirectory, buildRAGUpsertInputFromDocuments, buildRAGUpsertInputFromUploads, createBuiltinArchiveExpander, createEmailExtractor, createEPUBExtractor, createLegacyDocumentExtractor, createRAGPDFOCRExtractor, createRAGArchiveExpander, createRAGArchiveFileExtractor, createOfficeDocumentExtractor, createPDFFileExtractor, createRAGFileExtractor, createRAGImageOCRExtractor, createRAGMediaFileExtractor, createRAGMediaTranscriber, createRAGOCRProvider, createTextFileExtractor, loadRAGDocumentFromURL, loadRAGDocumentUpload, loadRAGDocumentsFromUploads, buildRAGUpsertInputFromURLs, loadRAGDocumentFile, loadRAGDocumentsFromDirectory, loadRAGDocumentsFromURLs, prepareRAGDirectoryDocuments, prepareRAGDocument, prepareRAGDocumentFile, prepareRAGDocuments } from './ingestion';
11
11
  export { buildRAGAnswerWorkflowState, buildRAGCitations, buildRAGCitationReferenceMap, buildRAGGroundedAnswer, buildRAGGroundingReferences, buildRAGSourceGroups, buildRAGSourceSummaries, buildRAGStreamProgress as buildRAGTransportProgress, getLatestAssistantMessage, getLatestRAGSources, resolveRAGStreamStage } from './presentation';
12
- export { buildRAGEvaluationLeaderboard, buildRAGEvaluationResponse, buildRAGEvaluationRunDiff, compareRAGRetrievalStrategies, compareRAGRerankers, createRAGFileEvaluationHistoryStore, createRAGEvaluationSuite, evaluateRAGCollection, executeDryRunRAGEvaluation, loadRAGEvaluationHistory, persistRAGEvaluationSuiteRun, runRAGEvaluationSuite, summarizeRAGEvaluationCase, summarizeRAGRerankerComparison } from './quality';
12
+ export { buildRAGAnswerGroundingEvaluationResponse, buildRAGEvaluationLeaderboard, buildRAGEvaluationResponse, buildRAGEvaluationRunDiff, compareRAGRetrievalStrategies, compareRAGRerankers, createRAGFileEvaluationHistoryStore, createRAGEvaluationSuite, evaluateRAGAnswerGrounding, evaluateRAGAnswerGroundingCase, evaluateRAGCollection, executeDryRunRAGEvaluation, loadRAGEvaluationHistory, persistRAGEvaluationSuiteRun, runRAGEvaluationSuite, summarizeRAGEvaluationCase, summarizeRAGRerankerComparison } from './quality';
13
13
  export { createRAGBunS3SyncClient, createRAGDirectorySyncSource, createRAGEmailSyncSource, createRAGFileSyncStateStore, createRAGStaticEmailSyncClient, createRAGStorageSyncSource, createRAGSyncManager, createRAGSyncScheduler, createRAGUrlSyncSource } from './sync';
14
14
  export type { RAGStreamProgress as RAGTransportProgress, RAGStreamProgressState as RAGTransportProgressState } from './presentation';
15
15
  export { createRAGCollection, ingestDocuments, ingestRAGDocuments, searchDocuments } from './collection';
@@ -21,5 +21,5 @@ export type { GeminiEmbeddingsConfig, OllamaEmbeddingsConfig, OpenAICompatibleEm
21
21
  export type { AnthropicOCRConfig, GeminiOCRConfig, OllamaOCRConfig, OllamaTranscriptionConfig, OpenAICompatibleOCRConfig, OpenAICompatibleTranscriptionConfig, OpenAIOCRConfig, OpenAITranscriptionConfig } from './extractorProviders';
22
22
  export type { GmailEmailSyncConfig, GraphEmailSyncConfig, IMAPEmailSyncConfig } from './emailProviders';
23
23
  export type { NativeSQLiteRAGStoreOptions, SQLiteRAGStoreOptions } from './adapters/sqlite';
24
- export type { AIHTMXRenderConfig, RAGAnswerWorkflowState, RAGBackendCapabilities, RAGCitation, RAGCitationReferenceMap, RAGGroundedAnswer, RAGGroundedAnswerPart, RAGGroundingReference, RAGChunkingOptions, RAGChunkingStrategy, RAGDocumentChunk, RAGDocumentChunkPreview, RAGArchiveEntry, RAGArchiveExpander, RAGArchiveExpansionResult, RAGExtractedFileDocument, RAGFileExtractionInput, RAGFileExtractor, RAGPDFOCRExtractorOptions, RAGDocumentFileInput, RAGDirectoryIngestInput, RAGDocumentIngestInput, RAGDocumentUploadIngestInput, RAGDocumentUploadInput, RAGDocumentUrlIngestInput, RAGDocumentUrlInput, RAGEmailSyncAttachment, RAGEmailSyncClient, RAGEmailSyncListInput, RAGEmailSyncListResult, RAGEmailSyncMessage, RAGEmailSyncSourceOptions, RAGStorageSyncClient, RAGStorageSyncFile, RAGStorageSyncListInput, RAGStorageSyncListResult, RAGStorageSyncObject, RAGStorageSyncSourceOptions, RAGEmbeddingFunction, RAGEmbeddingInput, RAGEmbeddingProvider, RAGEmbeddingProviderLike, RAGBackendDescriptor, RAGCollection, RAGCollectionSearchParams, RAGContentFormat, RAGEvaluationCase, RAGEvaluationCaseResult, RAGEvaluationLeaderboardEntry, RAGEvaluationInput, RAGEvaluationResponse, RAGEvaluationSummary, RAGEvaluationSuite, RAGEvaluationSuiteRun, RAGRetrievalCandidate, RAGRetrievalComparison, RAGRetrievalComparisonEntry, RAGRetrievalComparisonSummary, RAGHTMXConfig, RAGHTMXWorkflowRenderConfig, RAGIngestDocument, RAGIngestResponse, RAGIndexedDocument, RAGHybridFusionMode, RAGHybridRetrievalMode, RAGHybridSearchOptions, RAGMediaTranscriber, RAGMediaTranscriptSegment, RAGMediaTranscriptionResult, RAGMutationResponse, RAGLexicalQueryInput, RAGOCRProvider, RAGOCRResult, RAGQueryInput, RAGQueryResult, RAGQueryTransformInput, RAGQueryTransformProvider, RAGQueryTransformProviderLike, RAGQueryTransformResult, RAGQueryTransformer, RAGPreparedDocument, RAGReranker, RAGRerankerCandidate, RAGRerankerComparison, RAGRerankerComparisonEntry, RAGRerankerComparisonSummary, RAGRerankerInput, RAGRerankerProvider, RAGRerankerProviderLike, RAGSearchRequest, RAGSyncManager, RAGSyncSchedule, RAGSyncScheduler, RAGSyncResponse, RAGSyncRunOptions, RAGSyncStateStore, RAGSyncSourceContext, RAGSyncSourceDefinition, RAGSyncSourceRecord, RAGSyncSourceRunResult, RAGDirectorySyncSourceOptions, RAGUrlSyncSourceOptions, RAGSource, RAGSourceGroup, RAGSourceSummary, RAGSQLiteNativeDiagnostics, RAGStatusResponse, RAGUpsertInput, RAGVectorStore, RAGVectorStoreStatus, SQLiteVecResolution } from './types';
24
+ export type { AIHTMXRenderConfig, RAGAnswerWorkflowState, RAGBackendCapabilities, RAGCitation, RAGCitationReferenceMap, RAGGroundedAnswer, RAGGroundedAnswerPart, RAGGroundingReference, RAGChunkingOptions, RAGChunkingStrategy, RAGDocumentChunk, RAGDocumentChunkPreview, RAGArchiveEntry, RAGArchiveExpander, RAGArchiveExpansionResult, RAGExtractedFileDocument, RAGFileExtractionInput, RAGFileExtractor, RAGPDFOCRExtractorOptions, RAGDocumentFileInput, RAGDirectoryIngestInput, RAGDocumentIngestInput, RAGDocumentUploadIngestInput, RAGDocumentUploadInput, RAGDocumentUrlIngestInput, RAGDocumentUrlInput, RAGEmailSyncAttachment, RAGEmailSyncClient, RAGEmailSyncListInput, RAGEmailSyncListResult, RAGEmailSyncMessage, RAGEmailSyncSourceOptions, RAGStorageSyncClient, RAGStorageSyncFile, RAGStorageSyncListInput, RAGStorageSyncListResult, RAGStorageSyncObject, RAGStorageSyncSourceOptions, RAGEmbeddingFunction, RAGEmbeddingInput, RAGEmbeddingProvider, RAGEmbeddingProviderLike, RAGBackendDescriptor, RAGCollection, RAGCollectionSearchParams, RAGContentFormat, RAGAnswerGroundingEvaluationCase, RAGAnswerGroundingEvaluationCaseResult, RAGAnswerGroundingEvaluationInput, RAGAnswerGroundingEvaluationResponse, RAGAnswerGroundingEvaluationSummary, RAGEvaluationCase, RAGEvaluationCaseResult, RAGEvaluationLeaderboardEntry, RAGEvaluationInput, RAGEvaluationResponse, RAGEvaluationSummary, RAGEvaluationSuite, RAGEvaluationSuiteRun, RAGRetrievalCandidate, RAGRetrievalComparison, RAGRetrievalComparisonEntry, RAGRetrievalComparisonSummary, RAGHTMXConfig, RAGHTMXWorkflowRenderConfig, RAGIngestDocument, RAGIngestResponse, RAGIndexedDocument, RAGHybridFusionMode, RAGHybridRetrievalMode, RAGHybridSearchOptions, RAGMediaTranscriber, RAGMediaTranscriptSegment, RAGMediaTranscriptionResult, RAGMutationResponse, RAGLexicalQueryInput, RAGOCRProvider, RAGOCRResult, RAGQueryInput, RAGQueryResult, RAGQueryTransformInput, RAGQueryTransformProvider, RAGQueryTransformProviderLike, RAGQueryTransformResult, RAGQueryTransformer, RAGPreparedDocument, RAGReranker, RAGRerankerCandidate, RAGRerankerComparison, RAGRerankerComparisonEntry, RAGRerankerComparisonSummary, RAGRerankerInput, RAGRerankerProvider, RAGRerankerProviderLike, RAGSearchRequest, RAGSyncManager, RAGSyncSchedule, RAGSyncScheduler, RAGSyncResponse, RAGSyncRunOptions, RAGSyncStateStore, RAGSyncSourceContext, RAGSyncSourceDefinition, RAGSyncSourceRecord, RAGSyncSourceRunResult, RAGDirectorySyncSourceOptions, RAGUrlSyncSourceOptions, RAGSource, RAGSourceGroup, RAGSourceSummary, RAGSQLiteNativeDiagnostics, RAGStatusResponse, RAGUpsertInput, RAGVectorStore, RAGVectorStoreStatus, SQLiteVecResolution } from './types';
25
25
  export type { RAGPostgresNativeDiagnostics } from '../../../types/ai';
@@ -1,4 +1,4 @@
1
- import type { RAGCollection, RAGEvaluationCase, RAGEvaluationCaseResult, RAGEvaluationHistory, RAGEvaluationHistoryStore, RAGEvaluationInput, RAGEvaluationLeaderboardEntry, RAGEvaluationResponse, RAGEvaluationRunDiff, RAGEvaluationSuite, RAGEvaluationSuiteRun, RAGRetrievalCandidate, RAGRetrievalComparison, RAGRetrievalComparisonEntry, RAGRetrievalComparisonSummary, RAGRerankerCandidate, RAGRerankerComparison, RAGRerankerComparisonEntry, RAGRerankerComparisonSummary, RAGRerankerProviderLike } from '../../../types/ai';
1
+ import type { RAGAnswerGroundingEvaluationCase, RAGAnswerGroundingEvaluationCaseResult, RAGAnswerGroundingEvaluationInput, RAGAnswerGroundingEvaluationResponse, RAGCollection, RAGEvaluationCase, RAGEvaluationCaseResult, RAGEvaluationHistory, RAGEvaluationHistoryStore, RAGEvaluationInput, RAGEvaluationLeaderboardEntry, RAGEvaluationResponse, RAGEvaluationRunDiff, RAGEvaluationSuite, RAGEvaluationSuiteRun, RAGRetrievalCandidate, RAGRetrievalComparison, RAGRetrievalComparisonEntry, RAGRetrievalComparisonSummary, RAGRerankerCandidate, RAGRerankerComparison, RAGRerankerComparisonEntry, RAGRerankerComparisonSummary, RAGRerankerProviderLike } from '../../../types/ai';
2
2
  export declare const buildRAGEvaluationLeaderboard: (runs: RAGEvaluationSuiteRun[]) => RAGEvaluationLeaderboardEntry[];
3
3
  export declare const buildRAGEvaluationRunDiff: ({ current, previous }: {
4
4
  current: RAGEvaluationSuiteRun;
@@ -15,6 +15,12 @@ export declare const persistRAGEvaluationSuiteRun: ({ store, run }: {
15
15
  run: RAGEvaluationSuiteRun;
16
16
  }) => Promise<RAGEvaluationSuiteRun>;
17
17
  export declare const buildRAGEvaluationResponse: (cases: RAGEvaluationCaseResult[]) => RAGEvaluationResponse;
18
+ export declare const evaluateRAGAnswerGroundingCase: ({ caseIndex, caseInput }: {
19
+ caseIndex: number;
20
+ caseInput: RAGAnswerGroundingEvaluationCase;
21
+ }) => RAGAnswerGroundingEvaluationCaseResult;
22
+ export declare const buildRAGAnswerGroundingEvaluationResponse: (cases: RAGAnswerGroundingEvaluationCaseResult[]) => RAGAnswerGroundingEvaluationResponse;
23
+ export declare const evaluateRAGAnswerGrounding: (input: RAGAnswerGroundingEvaluationInput) => RAGAnswerGroundingEvaluationResponse;
18
24
  export declare const compareRAGRerankers: ({ collection, suite, rerankers, defaultTopK }: {
19
25
  collection: RAGCollection;
20
26
  suite: RAGEvaluationSuite;
@@ -1,5 +1,5 @@
1
1
  import type { RAGDocumentChunk, RAGQueryInput, RAGQueryResult, RAGUpsertInput } from '../../../types/ai';
2
- export type { AIHTMXRenderConfig, RAGAnswerWorkflowState, RAGBackendCapabilities, RAGCitation, RAGCitationReferenceMap, RAGGroundedAnswer, RAGGroundedAnswerPart, RAGGroundingReference, RAGChunkingOptions, RAGChunkingStrategy, RAGCollection, RAGCollectionSearchParams, RAGContentFormat, RAGHTMXConfig, RAGHybridFusionMode, RAGHybridRetrievalMode, RAGHybridSearchOptions, RAGDocumentChunk, RAGDocumentChunkPreview, RAGArchiveEntry, RAGArchiveExpander, RAGArchiveExpansionResult, RAGExtractedFileDocument, RAGFileExtractionInput, RAGFileExtractor, RAGPDFOCRExtractorOptions, RAGDirectoryIngestInput, RAGDirectorySyncSourceOptions, RAGDocumentFileInput, RAGDocumentIngestInput, RAGDocumentUploadIngestInput, RAGDocumentUploadInput, RAGEmbeddingFunction, RAGEmbeddingInput, RAGEmbeddingProvider, RAGEmbeddingProviderLike, RAGBackendDescriptor, RAGHTMXWorkflowRenderConfig, RAGIngestDocument, RAGIndexedDocument, RAGMediaTranscriber, RAGMediaTranscriptSegment, RAGMediaTranscriptionResult, RAGLexicalQueryInput, RAGDocumentUrlInput, RAGDocumentUrlIngestInput, RAGEmailSyncAttachment, RAGEmailSyncClient, RAGEmailSyncListInput, RAGEmailSyncListResult, RAGEmailSyncMessage, RAGEmailSyncSourceOptions, RAGStorageSyncClient, RAGStorageSyncFile, RAGStorageSyncListInput, RAGStorageSyncListResult, RAGStorageSyncObject, RAGStorageSyncSourceOptions, RAGOCRProvider, RAGOCRResult, RAGPreparedDocument, RAGSource, RAGSourceGroup, RAGSourceSummary, RAGIngestResponse, RAGMutationResponse, RAGPostgresNativeDiagnostics, RAGQueryInput, RAGQueryResult, RAGQueryTransformInput, RAGQueryTransformProvider, RAGQueryTransformProviderLike, RAGQueryTransformResult, RAGQueryTransformer, RAGSearchRequest, RAGSyncManager, RAGSyncRunOptions, RAGSyncSchedule, RAGSyncScheduler, RAGSyncResponse, RAGSyncStateStore, RAGSyncSourceContext, RAGSyncSourceDefinition, RAGSyncSourceRecord, RAGSyncSourceRunResult, RAGUrlSyncSourceOptions, RAGSQLiteNativeDiagnostics, RAGStatusResponse, RAGStreamStage, RAGEvaluationCase, RAGEvaluationCaseDiff, RAGEvaluationHistory, RAGEvaluationHistoryStore, RAGEvaluationCaseResult, RAGEvaluationLeaderboardEntry, RAGEvaluationInput, RAGEvaluationResponse, RAGEvaluationRunDiff, RAGEvaluationSummary, RAGEvaluationSuite, RAGEvaluationSuiteRun, RAGRetrievalCandidate, RAGRetrievalComparison, RAGRetrievalComparisonEntry, RAGRetrievalComparisonSummary, RAGUpsertInput, RAGVectorStore, RAGVectorStoreStatus, SQLiteVecResolution } from '../../../types/ai';
2
+ export type { AIHTMXRenderConfig, RAGAnswerWorkflowState, RAGBackendCapabilities, RAGCitation, RAGCitationReferenceMap, RAGGroundedAnswer, RAGGroundedAnswerPart, RAGGroundingReference, RAGChunkingOptions, RAGChunkingStrategy, RAGCollection, RAGCollectionSearchParams, RAGContentFormat, RAGHTMXConfig, RAGHybridFusionMode, RAGHybridRetrievalMode, RAGHybridSearchOptions, RAGDocumentChunk, RAGDocumentChunkPreview, RAGArchiveEntry, RAGArchiveExpander, RAGArchiveExpansionResult, RAGExtractedFileDocument, RAGFileExtractionInput, RAGFileExtractor, RAGPDFOCRExtractorOptions, RAGDirectoryIngestInput, RAGDirectorySyncSourceOptions, RAGDocumentFileInput, RAGDocumentIngestInput, RAGDocumentUploadIngestInput, RAGDocumentUploadInput, RAGEmbeddingFunction, RAGEmbeddingInput, RAGEmbeddingProvider, RAGEmbeddingProviderLike, RAGBackendDescriptor, RAGHTMXWorkflowRenderConfig, RAGIngestDocument, RAGIndexedDocument, RAGMediaTranscriber, RAGMediaTranscriptSegment, RAGMediaTranscriptionResult, RAGLexicalQueryInput, RAGDocumentUrlInput, RAGDocumentUrlIngestInput, RAGEmailSyncAttachment, RAGEmailSyncClient, RAGEmailSyncListInput, RAGEmailSyncListResult, RAGEmailSyncMessage, RAGEmailSyncSourceOptions, RAGStorageSyncClient, RAGStorageSyncFile, RAGStorageSyncListInput, RAGStorageSyncListResult, RAGStorageSyncObject, RAGStorageSyncSourceOptions, RAGOCRProvider, RAGOCRResult, RAGPreparedDocument, RAGSource, RAGSourceGroup, RAGSourceSummary, RAGIngestResponse, RAGMutationResponse, RAGPostgresNativeDiagnostics, RAGQueryInput, RAGQueryResult, RAGQueryTransformInput, RAGQueryTransformProvider, RAGQueryTransformProviderLike, RAGQueryTransformResult, RAGQueryTransformer, RAGSearchRequest, RAGSyncManager, RAGSyncRunOptions, RAGSyncSchedule, RAGSyncScheduler, RAGSyncResponse, RAGSyncStateStore, RAGSyncSourceContext, RAGSyncSourceDefinition, RAGSyncSourceRecord, RAGSyncSourceRunResult, RAGUrlSyncSourceOptions, RAGSQLiteNativeDiagnostics, RAGStatusResponse, RAGStreamStage, RAGAnswerGroundingEvaluationCase, RAGAnswerGroundingEvaluationCaseResult, RAGAnswerGroundingEvaluationInput, RAGAnswerGroundingEvaluationResponse, RAGAnswerGroundingEvaluationSummary, RAGEvaluationCase, RAGEvaluationCaseDiff, RAGEvaluationHistory, RAGEvaluationHistoryStore, RAGEvaluationCaseResult, RAGEvaluationLeaderboardEntry, RAGEvaluationInput, RAGEvaluationResponse, RAGEvaluationRunDiff, RAGEvaluationSummary, RAGEvaluationSuite, RAGEvaluationSuiteRun, RAGRetrievalCandidate, RAGRetrievalComparison, RAGRetrievalComparisonEntry, RAGRetrievalComparisonSummary, RAGUpsertInput, RAGVectorStore, RAGVectorStoreStatus, SQLiteVecResolution } from '../../../types/ai';
3
3
  export type InternalRAGStoredChunk = RAGDocumentChunk & {
4
4
  vector: number[];
5
5
  sourceId: string;
@@ -1674,6 +1674,30 @@ var buildSources = (results) => results.map((result) => ({
1674
1674
  text: result.chunkText,
1675
1675
  title: result.title
1676
1676
  }));
1677
+ var buildAnswerGroundingStatus = ({
1678
+ coverage,
1679
+ expectedCount,
1680
+ matchedCount,
1681
+ unresolvedCitationCount,
1682
+ resolvedCitationCount
1683
+ }) => {
1684
+ if (expectedCount > 0) {
1685
+ if (matchedCount === expectedCount && unresolvedCitationCount === 0 && coverage !== "ungrounded") {
1686
+ return "pass";
1687
+ }
1688
+ if (matchedCount > 0 || resolvedCitationCount > 0) {
1689
+ return "partial";
1690
+ }
1691
+ return "fail";
1692
+ }
1693
+ if (coverage === "grounded" && unresolvedCitationCount === 0) {
1694
+ return "pass";
1695
+ }
1696
+ if (resolvedCitationCount > 0 || coverage === "partial") {
1697
+ return "partial";
1698
+ }
1699
+ return "fail";
1700
+ };
1677
1701
  var buildRAGEvaluationLeaderboard = (runs) => {
1678
1702
  const sorted = [...runs].sort((left, right) => {
1679
1703
  if (right.response.passingRate !== left.response.passingRate) {
@@ -1826,6 +1850,93 @@ var buildRAGEvaluationResponse = (cases) => {
1826
1850
  totalCases
1827
1851
  };
1828
1852
  };
1853
+ var evaluateRAGAnswerGroundingCase = ({
1854
+ caseIndex,
1855
+ caseInput
1856
+ }) => {
1857
+ const mode = resolveEvaluationMode(caseInput);
1858
+ const expectedIds = normalizeExpectedIds(mode === "chunkId" ? caseInput.expectedChunkIds ?? [] : mode === "source" ? caseInput.expectedSources ?? [] : caseInput.expectedDocumentIds ?? []);
1859
+ const groundedAnswer = buildRAGGroundedAnswer(caseInput.answer, caseInput.sources);
1860
+ const citedReferences = groundedAnswer.parts.flatMap((part) => part.type === "citation" ? part.references : []);
1861
+ const citedIds = normalizeExpectedIds(citedReferences.map((reference) => extractExpectedId(reference, mode)));
1862
+ const expectedSet = new Set(expectedIds);
1863
+ const citedSet = new Set(citedIds);
1864
+ const matchedIds = normalizeExpectedIds([...expectedSet].filter((id) => citedSet.has(id)));
1865
+ const missingIds = normalizeExpectedIds([...expectedSet].filter((id) => !citedSet.has(id)));
1866
+ const extraIds = normalizeExpectedIds([...citedSet].filter((id) => !expectedSet.has(id)));
1867
+ const matchedCount = matchedIds.length;
1868
+ const expectedCount = expectedIds.length;
1869
+ const citedCount = citedIds.length;
1870
+ const precision = citedCount > 0 ? matchedCount / citedCount : 0;
1871
+ const recall = expectedCount > 0 ? matchedCount / expectedCount : 0;
1872
+ const citationF1 = precision + recall > 0 ? 2 * precision * recall / (precision + recall) : 0;
1873
+ const citationCount = groundedAnswer.parts.filter((part) => part.type === "citation").length;
1874
+ const unresolvedCitationCount = new Set(groundedAnswer.ungroundedReferenceNumbers).size;
1875
+ const resolvedCitationCount = citedReferences.length;
1876
+ const resolvedCitationRate = citationCount > 0 ? Math.min(1, resolvedCitationCount / citationCount) : 0;
1877
+ return {
1878
+ answer: caseInput.answer,
1879
+ caseId: caseInput.id ?? `case-${caseIndex + 1}`,
1880
+ citationCount,
1881
+ citationF1,
1882
+ citationPrecision: precision,
1883
+ citationRecall: recall,
1884
+ citedIds,
1885
+ coverage: groundedAnswer.coverage,
1886
+ expectedCount,
1887
+ expectedIds,
1888
+ extraIds,
1889
+ groundedAnswer,
1890
+ hasCitations: groundedAnswer.hasCitations,
1891
+ label: caseInput.label,
1892
+ matchedCount,
1893
+ matchedIds,
1894
+ metadata: caseInput.metadata,
1895
+ missingIds,
1896
+ mode,
1897
+ query: caseInput.query,
1898
+ referenceCount: groundedAnswer.references.length,
1899
+ resolvedCitationCount,
1900
+ resolvedCitationRate,
1901
+ status: buildAnswerGroundingStatus({
1902
+ coverage: groundedAnswer.coverage,
1903
+ expectedCount,
1904
+ matchedCount,
1905
+ resolvedCitationCount,
1906
+ unresolvedCitationCount
1907
+ }),
1908
+ unresolvedCitationCount
1909
+ };
1910
+ };
1911
+ var buildRAGAnswerGroundingEvaluationResponse = (cases) => {
1912
+ const totalCases = cases.length;
1913
+ const passedCases = cases.filter((entry) => entry.status === "pass").length;
1914
+ const partialCases = cases.filter((entry) => entry.status === "partial").length;
1915
+ const failedCases = cases.filter((entry) => entry.status === "fail").length;
1916
+ const groundedCases = cases.filter((entry) => entry.coverage === "grounded").length;
1917
+ const partiallyGroundedCases = cases.filter((entry) => entry.coverage === "partial").length;
1918
+ const ungroundedCases = cases.filter((entry) => entry.coverage === "ungrounded").length;
1919
+ return {
1920
+ cases,
1921
+ ok: true,
1922
+ passingRate: totalCases > 0 ? passedCases / totalCases * 100 : 0,
1923
+ summary: {
1924
+ averageCitationF1: cases.reduce((sum, result) => sum + result.citationF1, 0) / (totalCases || 1),
1925
+ averageCitationPrecision: cases.reduce((sum, result) => sum + result.citationPrecision, 0) / (totalCases || 1),
1926
+ averageCitationRecall: cases.reduce((sum, result) => sum + result.citationRecall, 0) / (totalCases || 1),
1927
+ averageResolvedCitationRate: cases.reduce((sum, result) => sum + result.resolvedCitationRate, 0) / (totalCases || 1),
1928
+ failedCases,
1929
+ groundedCases,
1930
+ partiallyGroundedCases,
1931
+ passedCases,
1932
+ partialCases,
1933
+ totalCases,
1934
+ ungroundedCases
1935
+ },
1936
+ totalCases
1937
+ };
1938
+ };
1939
+ var evaluateRAGAnswerGrounding = (input) => buildRAGAnswerGroundingEvaluationResponse(input.cases.map((caseInput, caseIndex) => evaluateRAGAnswerGroundingCase({ caseIndex, caseInput })));
1829
1940
  var compareRAGRerankers = async ({
1830
1941
  collection,
1831
1942
  suite,
@@ -2746,5 +2857,5 @@ export {
2746
2857
  createAIStream
2747
2858
  };
2748
2859
 
2749
- //# debugId=DC26809CB98DE1DE64756E2164756E21
2860
+ //# debugId=0F462710B58AF35664756E2164756E21
2750
2861
  //# sourceMappingURL=index.js.map