Skip to content

Commit

Permalink
Merge pull request #31 from receptron/graphai_03
Browse files Browse the repository at this point in the history
GraphAI 0.3.1
  • Loading branch information
isamu authored May 10, 2024
2 parents d755dd5 + 3a3a19f commit d477514
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 39 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"cytoscape-fcose": "^2.2.0",
"cytoscape-klay": "^3.1.4",
"firebase": "^10.7.1",
"graphai": "^0.2.7",
"graphai": "^0.3.1",
"pinia": "^2.1.7",
"vue": "^3.4.4",
"vue-i18n": "^9.8.0",
Expand Down
3 changes: 2 additions & 1 deletion src/composables/cytoscope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ const colorMap = {
};

const parseInput = (input: string) => {
const ids = input.split(".");
// WARNING: Assuming the first character is always ":"
const ids = input.slice(1).split(".");
const source = ids.shift() || "";
const label = ids.length ? ids.join(".") : undefined;
return { source, label };
Expand Down
5 changes: 3 additions & 2 deletions src/utils/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ export const generateGraph = (staticNode: number = 10, computedNode: number = 50

const inputs = arrays(randomInt(3) + 1).map(() => {
const rand = randomInt2(inputsNode.length);
return inputsNode[rand];
return ":" + inputsNode[rand];
});

// Ensure that all static nodes are used by other nodes
if (k < staticNode) {
inputs.push(inputsNode[k]);
inputs.push(":" + inputsNode[k]);
}

nodes[name] = {
Expand All @@ -48,6 +48,7 @@ export const generateGraph = (staticNode: number = 10, computedNode: number = 50
});

return {
version: 0.3,
nodes,
concurrency,
};
Expand Down
60 changes: 32 additions & 28 deletions src/utils/graph_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,111 +2,114 @@ import { GraphData } from "graphai";
import { randomInt } from "./graph";

export const graph_data: GraphData = {
version: 0.3,
loop: {
while: "source",
while: ":source",
},
nodes: {
source: {
value: ["orange", "banana", "lemon", "orange", "banana", "lemon", "orange", "banana", "lemon", "orange", "banana", "lemon"],
update: "popper.array",
update: ":popper.array",
},
result: {
value: [],
update: "reducer",
update: ":reducer",
isResult: true,
},
sleeper1: {
agent: "sleepTestAgent",
params: {
duration: 200,
},
inputs: ["source"],
inputs: [":source"],
},
sleeper2: {
agent: "sleepTestAgent",
params: {
duration: 200,
},
inputs: ["sleeper1"],
inputs: [":sleeper1"],
},
sleeper3: {
agent: "sleepTestAgent",
params: {
duration: 200,
},
inputs: ["sleeper2"],
inputs: [":sleeper2"],
},
sleeper4: {
agent: "sleepTestAgent",
params: {
duration: 200,
},
inputs: ["sleeper3"],
inputs: [":sleeper3"],
},
popper: {
inputs: ["sleeper4"],
inputs: [":sleeper4"],
agent: "popAgent", // returns { array, item }
},
reducer: {
agent: "pushAgent",
inputs: ["result", "popper.item"],
inputs: [":result", ":popper.item"],
},
},
};

export const graph_data2: GraphData = {
version: 0.3,
nodes: {
node1: {
value: { message: "Hello World" },
},
node2: {
agent: "sleepTestAgent",
inputs: ["node1"],
inputs: [":node1"],
},
node3: {
agent: "sleepTestAgent",
inputs: ["node2"],
inputs: [":node2"],
},
node4: {
agent: "sleepTestAgent",
inputs: ["node2", "node3"],
inputs: [":node2", ":node3"],
},
node5: {
agent: "sleepTestAgent",
inputs: ["node3", "node4"],
inputs: [":node3", ":node4"],
},
node6: {
agent: "sleepTestAgent",
inputs: ["node1", "node5"],
inputs: [":node1", ":node5"],
},
node7: {
agent: "sleepTestAgent",
inputs: ["node3", "node5"],
inputs: [":node3", ":node5"],
},
node8: {
agent: "sleepTestAgent",
inputs: ["node2", "node5", "node3"],
inputs: [":node2", ":node5", ":node3"],
},
node9: {
agent: "sleepTestAgent",
inputs: ["node4", "node8", "node6"],
inputs: [":node4", ":node8", ":node6"],
},
node10: {
agent: "sleepTestAgent",
inputs: ["node5", "node6", "node7"],
inputs: [":node5", ":node6", ":node7"],
},
node11: {
agent: "sleepTestAgent",
inputs: ["node3", "node6", "node7"],
inputs: [":node3", ":node6", ":node7"],
},
node12: {
agent: "sleepTestAgent",
inputs: ["node10", "node11", "node9"],
inputs: [":node10", ":node11", ":node9"],
},
},
};

export const graph_data_http = {
version: 0.3,
nodes: {
echo: {
agent: "httpAgent",
Expand All @@ -117,22 +120,22 @@ export const graph_data_http = {
},
bypassAgent: {
agent: "httpAgent",
inputs: ["echo"],
inputs: [":echo"],
params: {
agent: "bypassAgent",
},
},
sleepAgent: {
agent: "httpAgent",
inputs: ["echo"],
inputs: [":echo"],
params: {
agent: "sleeperAgent",
duration: 1000,
},
},
bypassAgent2: {
agent: "httpAgent",
inputs: ["bypassAgent"],
inputs: [":bypassAgent"],
params: {
agent: "bypassAgent",
},
Expand All @@ -142,6 +145,7 @@ export const graph_data_http = {
};

export const graph_data_co2 = {
version: 0.3,
nodes: {
slashGPTAgent: {
agent: "httpAgent",
Expand Down Expand Up @@ -194,12 +198,12 @@ export const graph_data_co2 = {
function_data_key: "methods",
result_key: 0,
},
inputs: ["slashGPTAgent"],
inputs: [":slashGPTAgent"],
agent: "slashGPTFuncitons2TextAgent",
},
mapNode: {
agent: "mapAgent",
inputs: ["function2prompt0.$0", "function2prompt0.$1", "function2prompt0.$2", "function2prompt0.$3", "function2prompt0.$4", "function2prompt0.$5"],
inputs: [":function2prompt0.$0", ":function2prompt0.$1", ":function2prompt0.$2", ":function2prompt0.$3", ":function2prompt0.$4", ":function2prompt0.$5"],
params: {
injectionTo: ["memory"],
},
Expand All @@ -217,11 +221,11 @@ export const graph_data_co2 = {
prompt: "ユーザの問い合わせにある文章の専門家です。専門家として、ユーザのアイデアに対して実現可能なシナリオを100文字で書いてください。",
},
},
inputs: ["memory"],
inputs: [":memory"],
},
bypassAgent: {
agent: "bypassAgent",
inputs: ["slashGPTAgent0.$last.content"],
inputs: [":slashGPTAgent0.$last.content"],
isResult: true,
},
},
Expand All @@ -231,7 +235,7 @@ export const graph_data_co2 = {
};

export const graph_data_stream: GraphData = {
version: 0.2,
version: 0.3,
nodes: {
echo: {
agent: "echoAgent",
Expand Down
6 changes: 3 additions & 3 deletions src/utils/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const useGraphData = () => {
];

const graphdata_any: GraphData = {
version: 0.2,
version: 0.3,
concurrency: 3,
nodes: {
message: {
Expand All @@ -100,11 +100,11 @@ export const useGraphData = () => {
agent: (message: string) => {
return new WordStreamer(message);
},
inputs: ["message.$" + k],
inputs: [":message.$" + k],
};
graphdata_any.nodes["destination" + k] = {
agent: faucatGenerator("message" + k),
inputs: ["source" + k],
inputs: [":source" + k],
};
});

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1911,10 +1911,10 @@ graceful-fs@^4.1.6, graceful-fs@^4.2.0:
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3"
integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==

graphai@^0.2.7:
version "0.2.7"
resolved "https://registry.yarnpkg.com/graphai/-/graphai-0.2.7.tgz#05e46caf6c0e2ac832866cbb9033f82115753fb8"
integrity sha512-DoJhFKQyoVOO2oJxhJLx4Oy7mv4LTXcF6Ij286WWRs4uSf+m1NBVIGoaXXIHquWAthf2VmyoBIavBOaL80LQsg==
graphai@^0.3.1:
version "0.3.1"
resolved "https://registry.yarnpkg.com/graphai/-/graphai-0.3.1.tgz#c8677ad26bcaf6f71e1e6bb9880377a60cd07f1c"
integrity sha512-oZGsH1tqlkeUIYs58LFlFHVNL9GzoFxpLCY1FfX2UgrI5fxNZNymkaw5lkTykePOpo9AV4a6q50AWric4e+bfg==

graphemer@^1.4.0:
version "1.4.0"
Expand Down

0 comments on commit d477514

Please sign in to comment.