added api consuming for generating sidebar based on json
This commit is contained in:
parent
5b3ff43a40
commit
7aeac0648a
5 changed files with 102 additions and 0 deletions
29
space_flow/package-lock.json
generated
29
space_flow/package-lock.json
generated
|
|
@ -17,6 +17,7 @@
|
||||||
"@types/node": "^16.18.12",
|
"@types/node": "^16.18.12",
|
||||||
"@types/react": "^18.0.27",
|
"@types/react": "^18.0.27",
|
||||||
"@types/react-dom": "^18.0.10",
|
"@types/react-dom": "^18.0.10",
|
||||||
|
"axios": "^1.3.2",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-icons": "^4.7.1",
|
"react-icons": "^4.7.1",
|
||||||
|
|
@ -5061,6 +5062,29 @@
|
||||||
"node": ">=4"
|
"node": ">=4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/axios": {
|
||||||
|
"version": "1.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/axios/-/axios-1.3.2.tgz",
|
||||||
|
"integrity": "sha512-1M3O703bYqYuPhbHeya5bnhpYVsDDRyQSabNja04mZtboLNSuZ4YrltestrLXfHgmzua4TpUqRiVKbiQuo2epw==",
|
||||||
|
"dependencies": {
|
||||||
|
"follow-redirects": "^1.15.0",
|
||||||
|
"form-data": "^4.0.0",
|
||||||
|
"proxy-from-env": "^1.1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/axios/node_modules/form-data": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
|
||||||
|
"dependencies": {
|
||||||
|
"asynckit": "^0.4.0",
|
||||||
|
"combined-stream": "^1.0.8",
|
||||||
|
"mime-types": "^2.1.12"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 6"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/axobject-query": {
|
"node_modules/axobject-query": {
|
||||||
"version": "3.1.1",
|
"version": "3.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.1.1.tgz",
|
||||||
|
|
@ -14139,6 +14163,11 @@
|
||||||
"node": ">= 0.10"
|
"node": ">= 0.10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/proxy-from-env": {
|
||||||
|
"version": "1.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
|
||||||
|
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
|
||||||
|
},
|
||||||
"node_modules/psl": {
|
"node_modules/psl": {
|
||||||
"version": "1.9.0",
|
"version": "1.9.0",
|
||||||
"resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz",
|
"resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz",
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
"@types/node": "^16.18.12",
|
"@types/node": "^16.18.12",
|
||||||
"@types/react": "^18.0.27",
|
"@types/react": "^18.0.27",
|
||||||
"@types/react-dom": "^18.0.10",
|
"@types/react-dom": "^18.0.10",
|
||||||
|
"axios": "^1.3.2",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-icons": "^4.7.1",
|
"react-icons": "^4.7.1",
|
||||||
|
|
|
||||||
61
space_flow/src/controllers/jsonConverter/index.ts
Normal file
61
space_flow/src/controllers/jsonConverter/index.ts
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
|
export async function getPrompts() {
|
||||||
|
const jsons = [];
|
||||||
|
let prompts = await axios.get("http://localhost:5003/list/prompts");
|
||||||
|
(prompts.data as Array<any>).forEach((value, index) => {
|
||||||
|
axios
|
||||||
|
.get("http://localhost:5003/templates/prompt", {
|
||||||
|
params: { name: value },
|
||||||
|
})
|
||||||
|
.then((prompt) => {
|
||||||
|
jsons.push({ name: value, type: "promptNode", ...prompt.data });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return jsons;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getChains() {
|
||||||
|
const jsons = [];
|
||||||
|
let chains = await axios.get("http://localhost:5003/list/chains");
|
||||||
|
(chains.data as Array<any>).forEach((value, index) => {
|
||||||
|
axios
|
||||||
|
.get("http://localhost:5003/templates/chain", {
|
||||||
|
params: { name: value },
|
||||||
|
})
|
||||||
|
.then((chain) => {
|
||||||
|
jsons.push({ name: value, type: "chainNode", ...chain.data });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return jsons;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getAgents() {
|
||||||
|
const jsons = [];
|
||||||
|
let chains = await axios.get("http://localhost:5003/list/agents");
|
||||||
|
(chains.data as Array<any>).forEach((value, index) => {
|
||||||
|
axios
|
||||||
|
.get("http://localhost:5003/templates/agent", {
|
||||||
|
params: { name: value },
|
||||||
|
})
|
||||||
|
.then((chain) => {
|
||||||
|
jsons.push({ name: value, type: "agentNode", ...chain.data });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return jsons;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getMemories() {
|
||||||
|
const jsons = [];
|
||||||
|
let memories = await axios.get("http://localhost:5003/list/memories");
|
||||||
|
(memories.data as Array<any>).forEach((value, index) => {
|
||||||
|
axios
|
||||||
|
.get("http://localhost:5003/templates/memory", {
|
||||||
|
params: { name: value },
|
||||||
|
})
|
||||||
|
.then((memory) => {
|
||||||
|
jsons.push({ name: value, type: "memoryNode", ...memory.data });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return jsons;
|
||||||
|
}
|
||||||
4
space_flow/src/entities/apiEnum.ts
Normal file
4
space_flow/src/entities/apiEnum.ts
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
export enum apiEnum
|
||||||
|
{
|
||||||
|
PromptTemplate="PromptTemplate"
|
||||||
|
}
|
||||||
|
|
@ -14,6 +14,8 @@ import AgentNode from "../../CustomNodes/AgentNode";
|
||||||
import ChainNode from "../../CustomNodes/ChainNode";
|
import ChainNode from "../../CustomNodes/ChainNode";
|
||||||
import ValidatorNode from "../../CustomNodes/ValidatorNode";
|
import ValidatorNode from "../../CustomNodes/ValidatorNode";
|
||||||
import MemoryNode from "../../CustomNodes/MemoryNode";
|
import MemoryNode from "../../CustomNodes/MemoryNode";
|
||||||
|
import axios from "axios";
|
||||||
|
import {getPrompts, getChains,getAgents,getMemories} from "../../controllers/jsonConverter";
|
||||||
|
|
||||||
const nodeTypes = {
|
const nodeTypes = {
|
||||||
promptNode: PromptNode,
|
promptNode: PromptNode,
|
||||||
|
|
@ -25,6 +27,11 @@ const nodeTypes = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function FlowPage() {
|
export default function FlowPage() {
|
||||||
|
getPrompts().then(result=>console.log(result))
|
||||||
|
getChains().then(result=>console.log(result))
|
||||||
|
getAgents().then(result=>console.log(result))
|
||||||
|
getMemories().then(result=>console.log(result))
|
||||||
|
|
||||||
// outside component to avoid render trigger
|
// outside component to avoid render trigger
|
||||||
|
|
||||||
const reactFlowWrapper = useRef(null);
|
const reactFlowWrapper = useRef(null);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue