@equationalapplications/core-llm-wiki 7.7.0 → 7.7.2
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/README.md +1 -0
- package/dist/{chunk-VOSMYISQ.mjs → chunk-NWODQRSM.mjs} +32 -17
- package/dist/chunk-NWODQRSM.mjs.map +1 -0
- package/dist/index.js +41 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -3
- package/dist/index.mjs.map +1 -1
- package/dist/testing.js +30 -15
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-VOSMYISQ.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -107,7 +107,7 @@ async function setupDatabase(db, prefix) {
|
|
|
107
107
|
UNIQUE(entity_id, source_id, target_id, edge_type)
|
|
108
108
|
);
|
|
109
109
|
|
|
110
|
-
CREATE INDEX IF NOT EXISTS ${prefix}
|
|
110
|
+
CREATE INDEX IF NOT EXISTS ${prefix}edges_entity_id_idx ON ${prefix}edges(entity_id, id);
|
|
111
111
|
|
|
112
112
|
CREATE TABLE IF NOT EXISTS ${prefix}events (
|
|
113
113
|
id TEXT PRIMARY KEY,
|
|
@@ -620,6 +620,16 @@ var MIGRATIONS = [
|
|
|
620
620
|
if (!existing.has(name)) await db.execAsync(sql);
|
|
621
621
|
}
|
|
622
622
|
}
|
|
623
|
+
},
|
|
624
|
+
{
|
|
625
|
+
version: 12,
|
|
626
|
+
description: "Replace edges_entity_idx with composite edges(entity_id, id) for keyset paging",
|
|
627
|
+
run: async (db, prefix) => {
|
|
628
|
+
await db.execAsync(`
|
|
629
|
+
CREATE INDEX IF NOT EXISTS ${prefix}edges_entity_id_idx ON ${prefix}edges(entity_id, id);
|
|
630
|
+
DROP INDEX IF EXISTS ${prefix}edges_entity_idx;
|
|
631
|
+
`);
|
|
632
|
+
}
|
|
623
633
|
}
|
|
624
634
|
];
|
|
625
635
|
for (let i = 1; i < MIGRATIONS.length; i++) {
|
|
@@ -4837,11 +4847,16 @@ var IngestionService = class {
|
|
|
4837
4847
|
let ingestedChunks = 0;
|
|
4838
4848
|
let failedChunks = 0;
|
|
4839
4849
|
const failures = [];
|
|
4840
|
-
const
|
|
4841
|
-
const orderedChunkFacts = [];
|
|
4842
|
-
const groundingLedger = /* @__PURE__ */ new Map();
|
|
4850
|
+
const winners = /* @__PURE__ */ new Map();
|
|
4843
4851
|
const diagBuffer = new DiagnosticBuffer();
|
|
4844
4852
|
const diagBase = { entityId, operation: "ingest", trigger: "call" };
|
|
4853
|
+
const pushDeduplicated = (chunkIndex, itemIndex) => {
|
|
4854
|
+
diagBuffer.push({
|
|
4855
|
+
...diagBase,
|
|
4856
|
+
code: "fact_deduplicated",
|
|
4857
|
+
detail: { sourceRef, chunkIndex, itemIndex, reason: "exact_title" }
|
|
4858
|
+
});
|
|
4859
|
+
};
|
|
4845
4860
|
for (const [chunkIndex, slot] of chunkResults.entries()) {
|
|
4846
4861
|
if (slot.status === "failed") {
|
|
4847
4862
|
failedChunks++;
|
|
@@ -4852,22 +4867,32 @@ var IngestionService = class {
|
|
|
4852
4867
|
for (const r of slot.rejected) {
|
|
4853
4868
|
diagBuffer.push({ ...diagBase, code: "fact_rejected", detail: { sourceRef, chunkIndex, itemIndex: r.itemIndex, reason: r.reason } });
|
|
4854
4869
|
}
|
|
4855
|
-
const dedupedFacts = [];
|
|
4856
4870
|
slot.facts.forEach((fact, k) => {
|
|
4857
|
-
const
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4871
|
+
const key = normalizeTitleKey(fact.title);
|
|
4872
|
+
const candidate = { chunkIndex, k, itemIndex: slot.itemIndexes[k], rank: slot.verdicts[k]?.status === "grounded" ? 1 : 0 };
|
|
4873
|
+
const current = winners.get(key);
|
|
4874
|
+
if (!current) {
|
|
4875
|
+
winners.set(key, candidate);
|
|
4876
|
+
} else if (candidate.rank > current.rank) {
|
|
4877
|
+
pushDeduplicated(current.chunkIndex, current.itemIndex);
|
|
4878
|
+
winners.set(key, candidate);
|
|
4862
4879
|
} else {
|
|
4863
|
-
|
|
4864
|
-
...diagBase,
|
|
4865
|
-
code: "fact_deduplicated",
|
|
4866
|
-
detail: { sourceRef, chunkIndex, itemIndex: slot.itemIndexes[k], reason: "exact_title" }
|
|
4867
|
-
});
|
|
4880
|
+
pushDeduplicated(candidate.chunkIndex, candidate.itemIndex);
|
|
4868
4881
|
}
|
|
4869
4882
|
});
|
|
4870
|
-
|
|
4883
|
+
}
|
|
4884
|
+
const orderedChunkFacts = [];
|
|
4885
|
+
const groundingLedger = /* @__PURE__ */ new Map();
|
|
4886
|
+
for (const [chunkIndex, slot] of chunkResults.entries()) {
|
|
4887
|
+
if (slot.status === "failed") continue;
|
|
4888
|
+
const keptFacts = [];
|
|
4889
|
+
slot.facts.forEach((fact, k) => {
|
|
4890
|
+
const winner = winners.get(normalizeTitleKey(fact.title));
|
|
4891
|
+
if (winner?.chunkIndex !== chunkIndex || winner.k !== k) return;
|
|
4892
|
+
keptFacts.push(fact);
|
|
4893
|
+
if (ingestGrounding) groundingLedger.set(fact, { verdict: slot.verdicts[k], chunkIndex, itemIndex: winner.itemIndex });
|
|
4894
|
+
});
|
|
4895
|
+
orderedChunkFacts.push({ facts: keptFacts, ontology_updates: slot.ontology_updates });
|
|
4871
4896
|
}
|
|
4872
4897
|
for (const reason of ["parse", "llm"]) {
|
|
4873
4898
|
const ofReason = failures.filter((f) => f.source === reason);
|