@absolutejs/absolute 0.19.0-beta.510 → 0.19.0-beta.511
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.
- package/dist/ai/client/index.js +112 -1
- package/dist/ai/client/index.js.map +3 -3
- package/dist/ai/index.js +123 -8
- package/dist/ai/index.js.map +4 -4
- package/dist/ai-client/react/ai/index.js +323 -0
- package/dist/ai-client/vue/ai/index.js +323 -0
- package/dist/angular/index.js +2 -2
- package/dist/angular/index.js.map +1 -1
- package/dist/angular/server.js +2 -2
- package/dist/angular/server.js.map +1 -1
- package/dist/build.js +2 -2
- package/dist/build.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/react/ai/index.js +112 -1
- package/dist/react/ai/index.js.map +3 -3
- package/dist/src/ai/index.d.ts +2 -2
- package/dist/src/ai/rag/index.d.ts +1 -1
- package/dist/src/ai/rag/quality.d.ts +15 -1
- package/dist/src/ai/rag/types.d.ts +1 -1
- package/dist/svelte/ai/index.js +112 -1
- package/dist/svelte/ai/index.js.map +3 -3
- package/dist/types/ai.d.ts +45 -0
- package/dist/vue/ai/index.js +112 -1
- package/dist/vue/ai/index.js.map +3 -3
- package/package.json +1 -1
package/dist/react/ai/index.js
CHANGED
|
@@ -1587,7 +1587,10 @@ var createRAGClient = (options) => {
|
|
|
1587
1587
|
};
|
|
1588
1588
|
};
|
|
1589
1589
|
// src/ai/rag/quality.ts
|
|
1590
|
+
import { mkdir, readFile, writeFile } from "fs/promises";
|
|
1591
|
+
import { dirname } from "path";
|
|
1590
1592
|
var DEFAULT_TOP_K = 6;
|
|
1593
|
+
var DEFAULT_HISTORY_LIMIT = 20;
|
|
1591
1594
|
var normalizeStringArray = (value) => {
|
|
1592
1595
|
if (!Array.isArray(value)) {
|
|
1593
1596
|
return [];
|
|
@@ -1645,6 +1648,114 @@ var buildRAGEvaluationLeaderboard = (runs) => {
|
|
|
1645
1648
|
totalCases: run.response.totalCases
|
|
1646
1649
|
}));
|
|
1647
1650
|
};
|
|
1651
|
+
var toHistorySortOrder = (left, right) => right.finishedAt - left.finishedAt;
|
|
1652
|
+
var normalizeHistoryRuns = (runs) => [...runs].sort(toHistorySortOrder);
|
|
1653
|
+
var buildCaseDiff = (currentCase, previousCase) => ({
|
|
1654
|
+
caseId: currentCase.caseId,
|
|
1655
|
+
currentF1: currentCase.f1,
|
|
1656
|
+
currentMatchedIds: currentCase.matchedIds,
|
|
1657
|
+
currentMissingIds: currentCase.missingIds,
|
|
1658
|
+
currentStatus: currentCase.status,
|
|
1659
|
+
label: currentCase.label,
|
|
1660
|
+
previousF1: previousCase?.f1,
|
|
1661
|
+
previousMatchedIds: previousCase?.matchedIds ?? [],
|
|
1662
|
+
previousMissingIds: previousCase?.missingIds ?? [],
|
|
1663
|
+
previousStatus: previousCase?.status,
|
|
1664
|
+
query: currentCase.query
|
|
1665
|
+
});
|
|
1666
|
+
var getStatusRank = (status) => status === "pass" ? 2 : status === "partial" ? 1 : 0;
|
|
1667
|
+
var buildRAGEvaluationRunDiff = ({
|
|
1668
|
+
current,
|
|
1669
|
+
previous
|
|
1670
|
+
}) => {
|
|
1671
|
+
const previousCases = new Map((previous?.response.cases ?? []).map((entry) => [entry.caseId, entry]));
|
|
1672
|
+
const diffs = current.response.cases.map((entry) => buildCaseDiff(entry, previousCases.get(entry.caseId)));
|
|
1673
|
+
const regressedCases = diffs.filter((entry) => getStatusRank(entry.currentStatus) < getStatusRank(entry.previousStatus ?? "fail"));
|
|
1674
|
+
const improvedCases = diffs.filter((entry) => getStatusRank(entry.currentStatus) > getStatusRank(entry.previousStatus ?? "fail"));
|
|
1675
|
+
const unchangedCases = diffs.filter((entry) => getStatusRank(entry.currentStatus) === getStatusRank(entry.previousStatus ?? "fail"));
|
|
1676
|
+
return {
|
|
1677
|
+
currentRunId: current.id,
|
|
1678
|
+
improvedCases,
|
|
1679
|
+
previousRunId: previous?.id,
|
|
1680
|
+
regressedCases,
|
|
1681
|
+
suiteId: current.suiteId,
|
|
1682
|
+
summaryDelta: {
|
|
1683
|
+
averageF1: current.response.summary.averageF1 - (previous?.response.summary.averageF1 ?? 0),
|
|
1684
|
+
averageLatencyMs: current.response.summary.averageLatencyMs - (previous?.response.summary.averageLatencyMs ?? 0),
|
|
1685
|
+
failedCases: current.response.summary.failedCases - (previous?.response.summary.failedCases ?? 0),
|
|
1686
|
+
passedCases: current.response.summary.passedCases - (previous?.response.summary.passedCases ?? 0),
|
|
1687
|
+
passingRate: current.response.passingRate - (previous?.response.passingRate ?? 0),
|
|
1688
|
+
partialCases: current.response.summary.partialCases - (previous?.response.summary.partialCases ?? 0)
|
|
1689
|
+
},
|
|
1690
|
+
unchangedCases
|
|
1691
|
+
};
|
|
1692
|
+
};
|
|
1693
|
+
var createRAGFileEvaluationHistoryStore = (path) => ({
|
|
1694
|
+
listRuns: async ({ limit, suiteId } = {}) => {
|
|
1695
|
+
let parsed = [];
|
|
1696
|
+
try {
|
|
1697
|
+
const content = await readFile(path, "utf8");
|
|
1698
|
+
const value = JSON.parse(content);
|
|
1699
|
+
parsed = Array.isArray(value) ? value : [];
|
|
1700
|
+
} catch (error) {
|
|
1701
|
+
if (error.code !== "ENOENT") {
|
|
1702
|
+
throw error;
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
const filtered = parsed.filter((entry) => !suiteId || entry.suiteId === suiteId);
|
|
1706
|
+
const sorted = normalizeHistoryRuns(filtered);
|
|
1707
|
+
return typeof limit === "number" ? sorted.slice(0, limit) : sorted;
|
|
1708
|
+
},
|
|
1709
|
+
saveRun: async (run) => {
|
|
1710
|
+
const existing = await (async () => {
|
|
1711
|
+
try {
|
|
1712
|
+
const content = await readFile(path, "utf8");
|
|
1713
|
+
const value = JSON.parse(content);
|
|
1714
|
+
return Array.isArray(value) ? value : [];
|
|
1715
|
+
} catch (error) {
|
|
1716
|
+
if (error.code !== "ENOENT") {
|
|
1717
|
+
throw error;
|
|
1718
|
+
}
|
|
1719
|
+
return [];
|
|
1720
|
+
}
|
|
1721
|
+
})();
|
|
1722
|
+
const next = normalizeHistoryRuns([
|
|
1723
|
+
run,
|
|
1724
|
+
...existing.filter((entry) => entry.id !== run.id)
|
|
1725
|
+
]);
|
|
1726
|
+
await mkdir(dirname(path), { recursive: true });
|
|
1727
|
+
await writeFile(path, JSON.stringify(next, null, "\t") + `
|
|
1728
|
+
`, "utf8");
|
|
1729
|
+
}
|
|
1730
|
+
});
|
|
1731
|
+
var loadRAGEvaluationHistory = async ({
|
|
1732
|
+
store,
|
|
1733
|
+
suite,
|
|
1734
|
+
limit = DEFAULT_HISTORY_LIMIT
|
|
1735
|
+
}) => {
|
|
1736
|
+
const runs = normalizeHistoryRuns(await Promise.resolve(store.listRuns({ limit, suiteId: suite.id })));
|
|
1737
|
+
const latestRun = runs[0];
|
|
1738
|
+
const previousRun = runs[1];
|
|
1739
|
+
return {
|
|
1740
|
+
diff: latestRun ? buildRAGEvaluationRunDiff({
|
|
1741
|
+
current: latestRun,
|
|
1742
|
+
previous: previousRun
|
|
1743
|
+
}) : undefined,
|
|
1744
|
+
latestRun,
|
|
1745
|
+
leaderboard: buildRAGEvaluationLeaderboard(runs),
|
|
1746
|
+
previousRun,
|
|
1747
|
+
runs,
|
|
1748
|
+
suiteId: suite.id,
|
|
1749
|
+
suiteLabel: suite.label ?? suite.id
|
|
1750
|
+
};
|
|
1751
|
+
};
|
|
1752
|
+
var persistRAGEvaluationSuiteRun = async ({
|
|
1753
|
+
store,
|
|
1754
|
+
run
|
|
1755
|
+
}) => {
|
|
1756
|
+
await Promise.resolve(store.saveRun(run));
|
|
1757
|
+
return run;
|
|
1758
|
+
};
|
|
1648
1759
|
var buildRAGEvaluationResponse = (cases) => {
|
|
1649
1760
|
const totalCases = cases.length;
|
|
1650
1761
|
const passedCases = cases.filter((entry) => entry.status === "pass").length;
|
|
@@ -2822,5 +2933,5 @@ export {
|
|
|
2822
2933
|
AIStreamProvider
|
|
2823
2934
|
};
|
|
2824
2935
|
|
|
2825
|
-
//# debugId=
|
|
2936
|
+
//# debugId=BAD5D631F86DF3DD64756E2164756E21
|
|
2826
2937
|
//# sourceMappingURL=index.js.map
|