@ai.ntellect/core 0.6.10 → 0.6.11
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/graph/engine.js +16 -4
- package/graph/engine.ts +15 -3
- package/package.json +1 -1
package/dist/graph/engine.js
CHANGED
@@ -44,7 +44,7 @@ class GraphEngine {
|
|
44
44
|
throw new Error("Cycle détecté dans le workflow");
|
45
45
|
}
|
46
46
|
if (options === null || options === void 0 ? void 0 : options.initialState) {
|
47
|
-
|
47
|
+
this.setState(options.initialState);
|
48
48
|
}
|
49
49
|
}
|
50
50
|
/**
|
@@ -257,11 +257,23 @@ class GraphEngine {
|
|
257
257
|
}
|
258
258
|
break;
|
259
259
|
}
|
260
|
-
// Gestion des relations (branchements)
|
261
260
|
const relationsNodes = currentNode.relationships || [];
|
262
|
-
|
261
|
+
// Check condition for all relations
|
262
|
+
let nextNodes = [];
|
263
|
+
for (const relation of relationsNodes) {
|
264
|
+
const nextNode = this.nodes.get(relation.name);
|
265
|
+
if ((nextNode === null || nextNode === void 0 ? void 0 : nextNode.condition) && !nextNode.condition(this.currentState)) {
|
266
|
+
// Skip this relation
|
267
|
+
continue;
|
268
|
+
}
|
269
|
+
nextNodes.push({
|
270
|
+
name: relation.name,
|
271
|
+
condition: nextNode === null || nextNode === void 0 ? void 0 : nextNode.condition,
|
272
|
+
});
|
273
|
+
}
|
274
|
+
if (nextNodes.length > 1) {
|
263
275
|
// Exécution parallèle des branches
|
264
|
-
yield Promise.all(
|
276
|
+
yield Promise.all(nextNodes.map((relation) => this.execute(this.currentState, relation.name, onStream, onError)));
|
265
277
|
// Après exécution en parallèle, on arrête la boucle
|
266
278
|
break;
|
267
279
|
}
|
package/graph/engine.ts
CHANGED
@@ -317,12 +317,24 @@ export class GraphEngine<T> {
|
|
317
317
|
break;
|
318
318
|
}
|
319
319
|
|
320
|
-
// Gestion des relations (branchements)
|
321
320
|
const relationsNodes = currentNode.relationships || [];
|
322
|
-
|
321
|
+
// Check condition for all relations
|
322
|
+
let nextNodes = [];
|
323
|
+
for (const relation of relationsNodes) {
|
324
|
+
const nextNode = this.nodes.get(relation.name);
|
325
|
+
if (nextNode?.condition && !nextNode.condition(this.currentState)) {
|
326
|
+
// Skip this relation
|
327
|
+
continue;
|
328
|
+
}
|
329
|
+
nextNodes.push({
|
330
|
+
name: relation.name,
|
331
|
+
condition: nextNode?.condition,
|
332
|
+
});
|
333
|
+
}
|
334
|
+
if (nextNodes.length > 1) {
|
323
335
|
// Exécution parallèle des branches
|
324
336
|
await Promise.all(
|
325
|
-
|
337
|
+
nextNodes.map((relation) =>
|
326
338
|
this.execute(this.currentState, relation.name, onStream, onError)
|
327
339
|
)
|
328
340
|
);
|