Skip to content

Commit

Permalink
static node
Browse files Browse the repository at this point in the history
  • Loading branch information
isamu committed Jun 20, 2024
1 parent 0f782ca commit cf19da1
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/utils/toGraphAi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ComputedNodeData, AgentFunctionInfo } from "graphai";
import { NodeData, AgentFunctionInfo } from "graphai";
import { serializedLGraph, LGraphNode } from "litegraph.js";

const liteGraph2GraphData = (liteGraph: serializedLGraph, lite2agent: Record<string, AgentFunctionInfo>, lite2inputs: Record<string, string[]>, lite2output: Record<string, string[]>) => {
Expand Down Expand Up @@ -36,13 +36,20 @@ const liteGraph2GraphData = (liteGraph: serializedLGraph, lite2agent: Record<str
return tmp;
}, {});

const nodes = liteGraph.nodes.reduce((tmp: Record<string, ComputedNodeData>, node: ReturnType<LGraphNode["serialize"]>) => {
const nodes = liteGraph.nodes.reduce((tmp: Record<string, NodeData>, node: ReturnType<LGraphNode["serialize"]>) => {
// [link index, out node, out position, in node, in position]
const inputs = linkObj[node.id];
const agent = lite2agent[node.type||''];
tmp[`node_${node.id}`] = {
agent: agent ? agent.name : node.type || '',
inputs: inputs ? inputs : undefined,

if ((node.type||'').startsWith("static/")) {
tmp[`node_${node.id}`] = {
value: "123",
}
} else {
const agent = lite2agent[node.type||''];
tmp[`node_${node.id}`] = {
agent: agent ? agent.name : node.type || '',
inputs: inputs ? inputs : undefined,
}
}
return tmp;
}, {});
Expand Down

0 comments on commit cf19da1

Please sign in to comment.