@absolutejs/rag 0.0.7 → 0.0.9
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 +42 -25
- package/dist/ai/client/index.js.map +5 -4
- package/dist/ai/client/ui.js +42 -25
- package/dist/ai/client/ui.js.map +5 -4
- package/dist/ai/rag/index.js +66 -37
- package/dist/ai/rag/index.js.map +8 -7
- package/dist/ai/rag/quality.js +42 -25
- package/dist/ai/rag/quality.js.map +5 -4
- package/dist/ai/rag/ui.js +42 -25
- package/dist/ai/rag/ui.js.map +5 -4
- package/dist/angular/ai/index.js +5 -2
- package/dist/angular/ai/index.js.map +5 -4
- package/dist/react/ai/index.js +5 -2
- package/dist/react/ai/index.js.map +5 -4
- package/dist/src/ai/rag/atomicWrite.d.ts +1 -0
- package/dist/svelte/ai/index.js +5 -2
- package/dist/svelte/ai/index.js.map +5 -4
- package/dist/vue/ai/index.js +5 -2
- package/dist/vue/ai/index.js.map +5 -4
- package/package.json +131 -131
package/dist/ai/client/index.js
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// src/ai/rag/quality.ts
|
|
3
|
-
import { mkdir, readFile
|
|
3
|
+
import { mkdir, readFile } from "fs/promises";
|
|
4
|
+
|
|
5
|
+
// src/ai/rag/atomicWrite.ts
|
|
6
|
+
import { rename, unlink, writeFile } from "fs/promises";
|
|
7
|
+
var writeFileAtomic = async (path, data, encoding = "utf8") => {
|
|
8
|
+
const tmpPath = `${path}.tmp.${process.pid}.${Math.random().toString(36).slice(2, 10)}`;
|
|
9
|
+
try {
|
|
10
|
+
await writeFile(tmpPath, data, encoding);
|
|
11
|
+
await rename(tmpPath, path);
|
|
12
|
+
} catch (error) {
|
|
13
|
+
try {
|
|
14
|
+
await unlink(tmpPath);
|
|
15
|
+
} catch {}
|
|
16
|
+
throw error;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// src/ai/rag/quality.ts
|
|
4
21
|
import { dirname } from "path";
|
|
5
22
|
import { generateId } from "@absolutejs/ai";
|
|
6
23
|
|
|
@@ -6505,7 +6522,7 @@ var createRAGFileEvaluationHistoryStore = (path) => ({
|
|
|
6505
6522
|
...existing.filter((entry) => entry.id !== run.id)
|
|
6506
6523
|
]);
|
|
6507
6524
|
await mkdir(dirname(path), { recursive: true });
|
|
6508
|
-
await
|
|
6525
|
+
await writeFileAtomic(path, JSON.stringify(next, null, "\t") + `
|
|
6509
6526
|
`, "utf8");
|
|
6510
6527
|
},
|
|
6511
6528
|
pruneRuns: async (input) => {
|
|
@@ -6525,7 +6542,7 @@ var createRAGFileEvaluationHistoryStore = (path) => ({
|
|
|
6525
6542
|
sort: normalizeHistoryRuns
|
|
6526
6543
|
});
|
|
6527
6544
|
await mkdir(dirname(path), { recursive: true });
|
|
6528
|
-
await
|
|
6545
|
+
await writeFileAtomic(path, JSON.stringify(pruned.next, null, "\t") + `
|
|
6529
6546
|
`, "utf8");
|
|
6530
6547
|
return {
|
|
6531
6548
|
keptCount: pruned.keptCount,
|
|
@@ -6576,7 +6593,7 @@ var createRAGFileEvaluationSuiteSnapshotHistoryStore = (path) => ({
|
|
|
6576
6593
|
...existing.filter((entry) => entry.id !== snapshot.id)
|
|
6577
6594
|
]);
|
|
6578
6595
|
await mkdir(dirname(path), { recursive: true });
|
|
6579
|
-
await
|
|
6596
|
+
await writeFileAtomic(path, JSON.stringify(next, null, "\t") + `
|
|
6580
6597
|
`, "utf8");
|
|
6581
6598
|
},
|
|
6582
6599
|
pruneSnapshots: async (input) => {
|
|
@@ -6596,7 +6613,7 @@ var createRAGFileEvaluationSuiteSnapshotHistoryStore = (path) => ({
|
|
|
6596
6613
|
sort: normalizeEvaluationSuiteSnapshots
|
|
6597
6614
|
});
|
|
6598
6615
|
await mkdir(dirname(path), { recursive: true });
|
|
6599
|
-
await
|
|
6616
|
+
await writeFileAtomic(path, JSON.stringify(pruned.next, null, "\t") + `
|
|
6600
6617
|
`, "utf8");
|
|
6601
6618
|
return {
|
|
6602
6619
|
keptCount: pruned.keptCount,
|
|
@@ -6639,7 +6656,7 @@ var createRAGFileRetrievalComparisonHistoryStore = (path) => ({
|
|
|
6639
6656
|
...existing.filter((entry) => entry.id !== run.id)
|
|
6640
6657
|
]);
|
|
6641
6658
|
await mkdir(dirname(path), { recursive: true });
|
|
6642
|
-
await
|
|
6659
|
+
await writeFileAtomic(path, JSON.stringify(next, null, "\t") + `
|
|
6643
6660
|
`, "utf8");
|
|
6644
6661
|
}
|
|
6645
6662
|
});
|
|
@@ -6693,7 +6710,7 @@ var createRAGFileRetrievalBaselineStore = (path) => {
|
|
|
6693
6710
|
...existing.map((entry) => entry.groupKey === record.groupKey && (entry.rolloutLabel ?? undefined) === (record.rolloutLabel ?? undefined) ? { ...entry, status: "superseded" } : entry)
|
|
6694
6711
|
]);
|
|
6695
6712
|
await mkdir(dirname(path), { recursive: true });
|
|
6696
|
-
await
|
|
6713
|
+
await writeFileAtomic(path, JSON.stringify(next, null, "\t") + `
|
|
6697
6714
|
`, "utf8");
|
|
6698
6715
|
}
|
|
6699
6716
|
};
|
|
@@ -6732,7 +6749,7 @@ var createRAGFileRetrievalReleaseDecisionStore = (path) => ({
|
|
|
6732
6749
|
...existing.filter((entry) => entry.id !== record.id)
|
|
6733
6750
|
]);
|
|
6734
6751
|
await mkdir(dirname(path), { recursive: true });
|
|
6735
|
-
await
|
|
6752
|
+
await writeFileAtomic(path, JSON.stringify(next, null, "\t") + `
|
|
6736
6753
|
`, "utf8");
|
|
6737
6754
|
}
|
|
6738
6755
|
});
|
|
@@ -6776,7 +6793,7 @@ var createRAGFileRetrievalLaneHandoffDecisionStore = (path) => ({
|
|
|
6776
6793
|
...existing.filter((entry) => entry.id !== record.id)
|
|
6777
6794
|
]);
|
|
6778
6795
|
await mkdir(dirname(path), { recursive: true });
|
|
6779
|
-
await
|
|
6796
|
+
await writeFileAtomic(path, JSON.stringify(next, null, "\t") + `
|
|
6780
6797
|
`, "utf8");
|
|
6781
6798
|
}
|
|
6782
6799
|
});
|
|
@@ -6821,7 +6838,7 @@ var createRAGFileRetrievalReleaseIncidentStore = (path) => ({
|
|
|
6821
6838
|
...existing.filter((entry) => entry.id !== record.id)
|
|
6822
6839
|
]);
|
|
6823
6840
|
await mkdir(dirname(path), { recursive: true });
|
|
6824
|
-
await
|
|
6841
|
+
await writeFileAtomic(path, JSON.stringify(next, null, "\t") + `
|
|
6825
6842
|
`, "utf8");
|
|
6826
6843
|
}
|
|
6827
6844
|
});
|
|
@@ -6865,7 +6882,7 @@ var createRAGFileRetrievalLaneHandoffIncidentStore = (path) => ({
|
|
|
6865
6882
|
...existing.filter((entry) => entry.id !== record.id)
|
|
6866
6883
|
]);
|
|
6867
6884
|
await mkdir(dirname(path), { recursive: true });
|
|
6868
|
-
await
|
|
6885
|
+
await writeFileAtomic(path, JSON.stringify(next, null, "\t") + `
|
|
6869
6886
|
`, "utf8");
|
|
6870
6887
|
}
|
|
6871
6888
|
});
|
|
@@ -6905,7 +6922,7 @@ var createRAGFileRetrievalLaneHandoffIncidentHistoryStore = (path) => ({
|
|
|
6905
6922
|
})();
|
|
6906
6923
|
const next = [record, ...existing].sort((left, right) => right.recordedAt - left.recordedAt);
|
|
6907
6924
|
await mkdir(dirname(path), { recursive: true });
|
|
6908
|
-
await
|
|
6925
|
+
await writeFileAtomic(path, JSON.stringify(next, null, "\t") + `
|
|
6909
6926
|
`, "utf8");
|
|
6910
6927
|
}
|
|
6911
6928
|
});
|
|
@@ -6949,7 +6966,7 @@ var createRAGFileRetrievalIncidentRemediationDecisionStore = (path) => ({
|
|
|
6949
6966
|
...existing
|
|
6950
6967
|
]);
|
|
6951
6968
|
await mkdir(dirname(path), { recursive: true });
|
|
6952
|
-
await
|
|
6969
|
+
await writeFileAtomic(path, JSON.stringify(next, null, "\t") + `
|
|
6953
6970
|
`, "utf8");
|
|
6954
6971
|
}
|
|
6955
6972
|
});
|
|
@@ -6995,7 +7012,7 @@ var createRAGFileRetrievalIncidentRemediationExecutionHistoryStore = (path) => (
|
|
|
6995
7012
|
...existing
|
|
6996
7013
|
]);
|
|
6997
7014
|
await mkdir(dirname(path), { recursive: true });
|
|
6998
|
-
await
|
|
7015
|
+
await writeFileAtomic(path, JSON.stringify(next, null, "\t") + `
|
|
6999
7016
|
`, "utf8");
|
|
7000
7017
|
}
|
|
7001
7018
|
});
|
|
@@ -7029,7 +7046,7 @@ var createRAGFileRetrievalLaneHandoffAutoCompletePolicyHistoryStore = (path) =>
|
|
|
7029
7046
|
})();
|
|
7030
7047
|
const next = [record, ...existing].sort((left, right) => right.recordedAt - left.recordedAt);
|
|
7031
7048
|
await mkdir(dirname(path), { recursive: true });
|
|
7032
|
-
await
|
|
7049
|
+
await writeFileAtomic(path, JSON.stringify(next, null, "\t") + `
|
|
7033
7050
|
`, "utf8");
|
|
7034
7051
|
}
|
|
7035
7052
|
});
|
|
@@ -7063,7 +7080,7 @@ var createRAGFileRetrievalReleaseLanePolicyHistoryStore = (path) => ({
|
|
|
7063
7080
|
})();
|
|
7064
7081
|
const next = [record, ...existing].sort((left, right) => right.recordedAt - left.recordedAt);
|
|
7065
7082
|
await mkdir(dirname(path), { recursive: true });
|
|
7066
|
-
await
|
|
7083
|
+
await writeFileAtomic(path, JSON.stringify(next, null, "\t") + `
|
|
7067
7084
|
`, "utf8");
|
|
7068
7085
|
}
|
|
7069
7086
|
});
|
|
@@ -7097,7 +7114,7 @@ var createRAGFileRetrievalBaselineGatePolicyHistoryStore = (path) => ({
|
|
|
7097
7114
|
})();
|
|
7098
7115
|
const next = [record, ...existing].sort((left, right) => right.recordedAt - left.recordedAt);
|
|
7099
7116
|
await mkdir(dirname(path), { recursive: true });
|
|
7100
|
-
await
|
|
7117
|
+
await writeFileAtomic(path, JSON.stringify(next, null, "\t") + `
|
|
7101
7118
|
`, "utf8");
|
|
7102
7119
|
}
|
|
7103
7120
|
});
|
|
@@ -7131,7 +7148,7 @@ var createRAGFileRetrievalReleaseLaneEscalationPolicyHistoryStore = (path) => ({
|
|
|
7131
7148
|
})();
|
|
7132
7149
|
const next = [record, ...existing].sort((left, right) => right.recordedAt - left.recordedAt);
|
|
7133
7150
|
await mkdir(dirname(path), { recursive: true });
|
|
7134
|
-
await
|
|
7151
|
+
await writeFileAtomic(path, JSON.stringify(next, null, "\t") + `
|
|
7135
7152
|
`, "utf8");
|
|
7136
7153
|
}
|
|
7137
7154
|
});
|
|
@@ -7177,7 +7194,7 @@ var createRAGFileSearchTraceStore = (path) => ({
|
|
|
7177
7194
|
...traces.filter((entry) => entry.id !== trace.id)
|
|
7178
7195
|
]);
|
|
7179
7196
|
await mkdir(dirname(path), { recursive: true });
|
|
7180
|
-
await
|
|
7197
|
+
await writeFileAtomic(path, JSON.stringify({
|
|
7181
7198
|
traces: nextTraces
|
|
7182
7199
|
}, null, 2));
|
|
7183
7200
|
},
|
|
@@ -7197,7 +7214,7 @@ var createRAGFileSearchTraceStore = (path) => ({
|
|
|
7197
7214
|
traces
|
|
7198
7215
|
});
|
|
7199
7216
|
await mkdir(dirname(path), { recursive: true });
|
|
7200
|
-
await
|
|
7217
|
+
await writeFileAtomic(path, JSON.stringify({
|
|
7201
7218
|
traces: pruned.next
|
|
7202
7219
|
}, null, 2));
|
|
7203
7220
|
return {
|
|
@@ -7240,7 +7257,7 @@ var createRAGFileSearchTracePruneHistoryStore = (path) => ({
|
|
|
7240
7257
|
...existing.filter((entry) => entry.id !== run.id)
|
|
7241
7258
|
]);
|
|
7242
7259
|
await mkdir(dirname(path), { recursive: true });
|
|
7243
|
-
await
|
|
7260
|
+
await writeFileAtomic(path, JSON.stringify(next, null, "\t") + `
|
|
7244
7261
|
`, "utf8");
|
|
7245
7262
|
}
|
|
7246
7263
|
});
|
|
@@ -8869,7 +8886,7 @@ var createRAGFileAnswerGroundingEvaluationHistoryStore = (path) => ({
|
|
|
8869
8886
|
...runs.filter((entry) => entry.id !== run.id)
|
|
8870
8887
|
]);
|
|
8871
8888
|
await mkdir(dirname(path), { recursive: true });
|
|
8872
|
-
await
|
|
8889
|
+
await writeFileAtomic(path, JSON.stringify({
|
|
8873
8890
|
runs: nextRuns
|
|
8874
8891
|
}, null, 2));
|
|
8875
8892
|
},
|
|
@@ -8890,7 +8907,7 @@ var createRAGFileAnswerGroundingEvaluationHistoryStore = (path) => ({
|
|
|
8890
8907
|
sort: normalizeGroundingHistoryRuns
|
|
8891
8908
|
});
|
|
8892
8909
|
await mkdir(dirname(path), { recursive: true });
|
|
8893
|
-
await
|
|
8910
|
+
await writeFileAtomic(path, JSON.stringify({
|
|
8894
8911
|
runs: pruned.next
|
|
8895
8912
|
}, null, 2));
|
|
8896
8913
|
return {
|
|
@@ -8930,7 +8947,7 @@ var createRAGFileAnswerGroundingCaseDifficultyHistoryStore = (path) => ({
|
|
|
8930
8947
|
...runs.filter((entry) => entry.id !== run.id)
|
|
8931
8948
|
]);
|
|
8932
8949
|
await mkdir(dirname(path), { recursive: true });
|
|
8933
|
-
await
|
|
8950
|
+
await writeFileAtomic(path, JSON.stringify({
|
|
8934
8951
|
runs: nextRuns
|
|
8935
8952
|
}, null, 2));
|
|
8936
8953
|
}
|
|
@@ -12587,5 +12604,5 @@ export {
|
|
|
12587
12604
|
buildRAGEvaluationLeaderboard
|
|
12588
12605
|
};
|
|
12589
12606
|
|
|
12590
|
-
//# debugId=
|
|
12607
|
+
//# debugId=B46A519521FA9A6264756E2164756E21
|
|
12591
12608
|
//# sourceMappingURL=index.js.map
|