Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
isamu committed Jun 20, 2024
1 parent e43efef commit cc9763c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 30 deletions.
46 changes: 24 additions & 22 deletions src/utils/setAgentToLiteGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,27 +107,29 @@ const format2output2 = (format: any) => {

const params2widget = (params: any) => {
if (params && params.properties) {
return Object.keys(params.properties).map((key) => {
const data = params.properties[key];
if (data.type === "string") {
return {
type: "string",
key,
};
}
if (data.type === "boolean") {
return {
type: "boolean",
key,
};
}
if (data.type === "number") {
return {
type: "number",
key,
return Object.keys(params.properties)
.map((key) => {
const data = params.properties[key];
if (data.type === "string") {
return {
type: "string",
key,
};
}
}
}).filter(a => a) as any[];
if (data.type === "boolean") {
return {
type: "boolean",
key,
};
}
if (data.type === "number") {
return {
type: "number",
key,
};
}
})
.filter((a) => a) as any[];
}
return [];
};
Expand All @@ -151,8 +153,8 @@ const setAgentToLiteGraph = (agents: AgentFunctionInfoDictionary) => {
const lite2agent: Record<string, AgentFunctionInfo> = {};
const lite2inputs: Record<string, string[]> = {};
const lite2output: Record<string, string[]> = {};
const lite2params: Record<string, {type: string, key: string}[]> = {};
const lite2params: Record<string, { type: string; key: string }[]> = {};

// TODO remove any after add format to AgentFunctionInfo
Object.values(agents).map((agent: any) => {
if (agent.category) {
Expand Down
10 changes: 5 additions & 5 deletions src/utils/toGraphAi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { serializedLGraph, LGraphNode } from "litegraph.js";
const liteGraph2GraphData = (
liteGraph: serializedLGraph,
ret: {
lite2agent: Record<string, AgentFunctionInfo>,
lite2inputs: Record<string, string[]>,
lite2output: Record<string, string[]>,
lite2params: Record<string, any[]>,
lite2agent: Record<string, AgentFunctionInfo>;
lite2inputs: Record<string, string[]>;
lite2output: Record<string, string[]>;
lite2params: Record<string, any[]>;
},
) => {
const { lite2agent, lite2inputs, lite2output, lite2params } = ret;
Expand Down Expand Up @@ -74,7 +74,7 @@ const liteGraph2GraphData = (

if ((node.type || "").startsWith("static/")) {
tmp[`node_${node.id}`] = {
value: node.widgets_values ? node.widgets_values[0] ?? "" : "",
value: node.widgets_values ? node.widgets_values[0] ?? "" : "",
};
} else {
const agent = lite2agent[node.type || ""];
Expand Down
5 changes: 2 additions & 3 deletions src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default defineComponent({
return tmp;
}, {});
ret = setAgentToLiteGraph(a);
new LGraphCanvas(canvasRef.value, graph);
const node_const = LiteGraph.createNode("data/copy");
Expand Down Expand Up @@ -85,8 +85,7 @@ export default defineComponent({
const data = graph.serialize();
const graphData = liteGraph2GraphData(data, ret);

Check failure on line 86 in src/views/Home.vue

View workflow job for this annotation

GitHub Actions / build (20.x)

Argument of type '{}' is not assignable to parameter of type '{ lite2agent: Record<string, AgentFunctionInfo>; lite2inputs: Record<string, string[]>; lite2output: Record<string, string[]>; lite2params: Record<...>; }'.
console.log(graphData);
console.log( JSON.stringify(graphData, 2, null));
console.log(JSON.stringify(graphData, 2, null));

Check failure on line 88 in src/views/Home.vue

View workflow job for this annotation

GitHub Actions / build (20.x)

No overload matches this call.
};
return {
Expand Down

0 comments on commit cc9763c

Please sign in to comment.