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
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 ValidatorNode from "../../CustomNodes/ValidatorNode";
|
||||
import MemoryNode from "../../CustomNodes/MemoryNode";
|
||||
import axios from "axios";
|
||||
import {getPrompts, getChains,getAgents,getMemories} from "../../controllers/jsonConverter";
|
||||
|
||||
const nodeTypes = {
|
||||
promptNode: PromptNode,
|
||||
|
|
@ -25,6 +27,11 @@ const nodeTypes = {
|
|||
};
|
||||
|
||||
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
|
||||
|
||||
const reactFlowWrapper = useRef(null);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue