feat: add array and sum node
This commit is contained in:
@ -1,4 +1,3 @@
|
||||
|
||||
type SparseArray<T = number> = (T | T[] | SparseArray<T>)[];
|
||||
|
||||
// Encodes a nested array into a flat array with bracket and distance notation
|
||||
|
@ -51,6 +51,9 @@ export class RemoteNodeRegistry implements NodeRegistry {
|
||||
const a = performance.now();
|
||||
nodeIds.push("max/plantarium/random");
|
||||
nodeIds.push("max/plantarium/float");
|
||||
nodeIds.push("max/plantarium/array");
|
||||
nodeIds.push("max/plantarium/sum");
|
||||
|
||||
for (const id of nodeIds) {
|
||||
const nodeUrl = `${this.url}/n/${id}`;
|
||||
const response = await fetch(nodeUrl);
|
||||
@ -96,6 +99,8 @@ wasm = val;`);
|
||||
|
||||
export class MemoryNodeRegistry implements NodeRegistry {
|
||||
|
||||
status: "loading" | "ready" | "error" = "ready";
|
||||
|
||||
async load(nodeIds: string[]) {
|
||||
// Do nothing
|
||||
}
|
||||
|
@ -135,7 +135,12 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
|
||||
}
|
||||
|
||||
// execute the node and store the result
|
||||
results[node.id] = node.tmp.type.execute(...Object.values(inputs)) as number;
|
||||
try {
|
||||
console.log(`Executing node ${node.tmp.type.id || node.id}`, inputs);
|
||||
results[node.id] = node.tmp.type.execute(...Object.values(inputs)) as number;
|
||||
} catch (e) {
|
||||
console.error(`Error executing node ${node.tmp.type.id || node.id}`, e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,8 @@
|
||||
console.log("INPUT");
|
||||
console.log(input);
|
||||
|
||||
const encoded = encode(input);
|
||||
let encoded = encode(input);
|
||||
encoded = [0, 3, 5, ...encoded.slice(2).slice(0, -4), 5, 5, 1, 1];
|
||||
console.log("ENCODED");
|
||||
console.log(encoded);
|
||||
|
||||
|
Reference in New Issue
Block a user