@absolutejs/rag 0.6.0 → 0.6.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/dist/index.js CHANGED
@@ -36126,6 +36126,10 @@ var planRAGCorpus = async (store, owner, desired) => {
36126
36126
  unchanged
36127
36127
  };
36128
36128
  };
36129
+ var filterToWritten = (planned, written) => {
36130
+ const ids = new Set(written);
36131
+ return planned.filter((doc) => ids.has(doc.chunkId));
36132
+ };
36129
36133
  var reconcileRAGCorpus = async (store, owner, desired, apply) => {
36130
36134
  const plan = await planRAGCorpus(store, owner, desired);
36131
36135
  if (plan.remove.length > 0) {
@@ -36134,11 +36138,15 @@ var reconcileRAGCorpus = async (store, owner, desired, apply) => {
36134
36138
  }
36135
36139
  let embedded = 0;
36136
36140
  if (plan.embed.length > 0) {
36137
- embedded = await apply.embed(plan.embed, owner);
36138
- await store.remember(owner, await Promise.all(plan.embed.map(async (doc) => ({
36139
- chunkId: doc.chunkId,
36140
- textHash: await corpusTextHash(doc.text)
36141
- }))));
36141
+ const outcome = await apply.embed(plan.embed, owner);
36142
+ const written = typeof outcome === "number" ? plan.embed.slice(0, Math.max(0, Math.min(outcome, plan.embed.length))) : filterToWritten(plan.embed, outcome);
36143
+ embedded = written.length;
36144
+ if (written.length > 0) {
36145
+ await store.remember(owner, await Promise.all(written.map(async (doc) => ({
36146
+ chunkId: doc.chunkId,
36147
+ textHash: await corpusTextHash(doc.text)
36148
+ }))));
36149
+ }
36142
36150
  }
36143
36151
  return { embedded, removed: plan.remove.length, unchanged: plan.unchanged };
36144
36152
  };
@@ -36442,5 +36450,5 @@ export {
36442
36450
  addRAGEvaluationSuiteCase
36443
36451
  };
36444
36452
 
36445
- //# debugId=8567BF91160369B364756E2164756E21
36453
+ //# debugId=9A8B228F28FF5ED164756E2164756E21
36446
36454
  //# sourceMappingURL=index.js.map