got data from server
This commit is contained in:
parent
990033f860
commit
8df0bd56cc
6 changed files with 57 additions and 99 deletions
|
|
@ -120,7 +120,7 @@ export default function ExtraSidebar() {
|
|||
</nav>
|
||||
</div>
|
||||
) : (
|
||||
<>{extraComponent}</>
|
||||
extraComponent
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ const initialValue= {
|
|||
setShowSideBar:()=>{},
|
||||
extraNavigation: {title:""},
|
||||
setExtraNavigation:()=>{},
|
||||
extraComponent: null,
|
||||
extraComponent: <></>,
|
||||
setExtraComponent:()=>{},
|
||||
}
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ export function LocationProvider({children}){
|
|||
const [isStackedOpen,setIsStackedOpen] = useState(initialValue.isStackedOpen)
|
||||
const [showSideBar,setShowSideBar] = useState(initialValue.showSideBar)
|
||||
const [extraNavigation, setExtraNavigation] = useState({title:""})
|
||||
const [extraComponent, setExtraComponent] = useState(null)
|
||||
const [extraComponent, setExtraComponent] = useState(<></>)
|
||||
return (
|
||||
<locationContext.Provider value={{isStackedOpen,setIsStackedOpen,atual,setAtual, showSideBar, setShowSideBar,extraNavigation, setExtraNavigation, extraComponent, setExtraComponent}}>
|
||||
{children}
|
||||
|
|
|
|||
|
|
@ -1,61 +1,5 @@
|
|||
import axios from "axios";
|
||||
|
||||
export async function getPrompts() {
|
||||
const promises = (await axios.get("http://localhost:5003/list/prompts")).data.map(async (value, index) => {
|
||||
const prompt = await axios.get("http://localhost:5003/signatures/prompt", {
|
||||
params: { name: value },
|
||||
});
|
||||
return { name: value, type: "promptNode", ...prompt.data };
|
||||
});
|
||||
return Promise.all(promises);
|
||||
}
|
||||
|
||||
export async function getChains() {
|
||||
const promises = (await axios.get("http://localhost:5003/list/chains")).data.map(async (value, index) => {
|
||||
const chain = await axios.get("http://localhost:5003/signatures/chain", {
|
||||
params: { name: value },
|
||||
});
|
||||
return { name: value, type: "chainNode", ...chain.data };
|
||||
});
|
||||
return Promise.all(promises);
|
||||
}
|
||||
|
||||
export async function getAgents() {
|
||||
const promises = (await axios.get("http://localhost:5003/list/agents")).data.map(async (value, index) => {
|
||||
const chain = await axios.get("http://localhost:5003/signatures/agent", {
|
||||
params: { name: value },
|
||||
});
|
||||
return { name: value, type: "agentNode", ...chain.data };
|
||||
});
|
||||
return Promise.all(promises);
|
||||
}
|
||||
|
||||
export async function getMemories() {
|
||||
const promises = (await axios.get("http://localhost:5003/list/memories")).data.map(async (value, index) => {
|
||||
const chain = await axios.get("http://localhost:5003/signatures/memory", {
|
||||
params: { name: value },
|
||||
});
|
||||
return { name: value, type: "memoryNode", ...chain.data };
|
||||
});
|
||||
return Promise.all(promises);
|
||||
}
|
||||
|
||||
export async function getTools() {
|
||||
const promises = (await axios.get("http://localhost:5003/list/tools")).data.map(async (value, index) => {
|
||||
const prompt = await axios.get("http://localhost:5003/signatures/tool", {
|
||||
params: { name: value },
|
||||
});
|
||||
return { name: value, type: "toolNode", ...prompt.data };
|
||||
});
|
||||
return Promise.all(promises);
|
||||
}
|
||||
|
||||
export async function getModels() {
|
||||
const promises = (await axios.get("http://localhost:5003/list/llms")).data.map(async (value, index) => {
|
||||
const prompt = await axios.get("http://localhost:5003/signatures/llm", {
|
||||
params: { name: value },
|
||||
});
|
||||
return { name: value, type: "modelNode", ...prompt.data };
|
||||
});
|
||||
return Promise.all(promises);
|
||||
export async function getAll() {
|
||||
return await axios.get("http://localhost:5003/");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,19 @@
|
|||
import { Bars2Icon, CommandLineIcon, CpuChipIcon, LightBulbIcon, LinkIcon, RocketLaunchIcon, WrenchScrewdriverIcon, ViewColumnsIcon } from "@heroicons/react/24/outline";
|
||||
import { Bars2Icon, ChartBarIcon } from "@heroicons/react/24/outline";
|
||||
import { llm_chain } from "../../../../data_assets/llm_chain";
|
||||
import { prompt } from "../../../../data_assets/prompt";
|
||||
import DisclosureComponent from "../DisclosureComponent";
|
||||
import { borderLColors, nodeColors, nodeIcons } from "../../../../utils";
|
||||
import { nodeColors, nodeIcons, toFirstUpperCase } from "../../../../utils";
|
||||
import { useEffect, useState } from "react";
|
||||
import { getAll } from "../../../../controllers/NodesServices";
|
||||
|
||||
export default function ExtraSidebar() {
|
||||
|
||||
const [data, setData] = useState({});
|
||||
|
||||
useEffect(() => {
|
||||
getAll().then((d) => { setData(d.data);});
|
||||
}, []);
|
||||
|
||||
export function ExtraSidebar() {
|
||||
|
||||
function onDragStart(event: React.DragEvent<any>, nodeType) {
|
||||
let json;
|
||||
event.dataTransfer.setData("application/reactflow", nodeType);
|
||||
|
|
@ -32,23 +40,28 @@ export function ExtraSidebar() {
|
|||
}
|
||||
|
||||
return (
|
||||
<div className="mt-4">
|
||||
<DisclosureComponent
|
||||
button={{ title: "Prompts", Icon: nodeIcons['prompt'] }}
|
||||
>
|
||||
<div className="p-2">
|
||||
<div draggable className={" cursor-grab border-l-8 rounded-l-md"} style={{borderLeftColor: nodeColors['prompt']}} onDragStart={(event) => onDragStart(event, "promptNode")}>
|
||||
<div
|
||||
|
||||
className="flex justify-between text-sm p-4 items-center h-12 border-dashed border-gray-400 border-l-0 rounded-md rounded-l-none border-2"
|
||||
|
||||
>
|
||||
<span className="text-black">Prompt</span>
|
||||
<Bars2Icon className="w-6 text-gray-400" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</DisclosureComponent>
|
||||
<div className="mt-4">
|
||||
{Object.keys(data).map((d, i) => (
|
||||
<DisclosureComponent
|
||||
key={i} button={{ title: toFirstUpperCase(d), Icon: nodeIcons[d] }}
|
||||
>
|
||||
{Object.keys(data[d]).map((t, k) => (
|
||||
<div key={k} className="p-2 pb-0">
|
||||
<div
|
||||
draggable
|
||||
className={" cursor-grab border-l-8 rounded-l-md"}
|
||||
style={{ borderLeftColor: nodeColors[d] }}
|
||||
onDragStart={(event) => onDragStart(event, "promptNode")}
|
||||
>
|
||||
<div className="flex justify-between text-sm px-4 py-3 items-center border-dashed border-gray-400 border-l-0 rounded-md rounded-l-none border-2">
|
||||
<span className="text-black truncate">{t}</span>
|
||||
<Bars2Icon className="ml-3 w-6 h-6 text-gray-400" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</DisclosureComponent>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,15 +9,15 @@ import ReactFlow, {
|
|||
import PromptNode from "../../CustomNodes/PromptNode";
|
||||
import ModelNode from "../../CustomNodes/ModelNode";
|
||||
import { locationContext } from "../../contexts/locationContext";
|
||||
import { ExtraSidebar } from "./components/extraSidebarComponent";
|
||||
import ExtraSidebar from "./components/extraSidebarComponent";
|
||||
import AgentNode from "../../CustomNodes/AgentNode";
|
||||
import ChainNode from "../../CustomNodes/ChainNode";
|
||||
import ToolsNode from "../../CustomNodes/ToolsNode";
|
||||
import MemoryNode from "../../CustomNodes/MemoryNode";
|
||||
import axios from "axios";
|
||||
import {getPrompts, getChains,getAgents,getMemories, getModels,getTools} from "../../controllers/NodesServices";
|
||||
import { generateUiNode } from "../../controllers/UiGenerator";
|
||||
import Chat from "../../components/chatComponent";
|
||||
import { getAll } from "../../controllers/NodesServices";
|
||||
|
||||
const nodeTypes = {
|
||||
promptNode: PromptNode,
|
||||
|
|
@ -34,10 +34,11 @@ export default function FlowPage() {
|
|||
// getAgents().then(result=>console.log(result))
|
||||
// getMemories().then(result=>console.log(result))
|
||||
// getModels().then(result=>result.forEach(model=>console.log(model)))
|
||||
getTools().then(result=>result.forEach(tool=>console.log(tool)))
|
||||
|
||||
// outside component to avoid render trigger
|
||||
|
||||
|
||||
|
||||
const reactFlowWrapper = useRef(null);
|
||||
|
||||
const rfStyle = {
|
||||
|
|
@ -51,9 +52,9 @@ export default function FlowPage() {
|
|||
const { setExtraComponent, setExtraNavigation } = useContext(locationContext);
|
||||
|
||||
useEffect(() => {
|
||||
setExtraComponent(ExtraSidebar);
|
||||
setExtraComponent(<ExtraSidebar />);
|
||||
setExtraNavigation({title: "Nodes"})
|
||||
}, []);
|
||||
}, [setExtraComponent, setExtraNavigation]);
|
||||
|
||||
const [nodes, setNodes, onNodesChange] = useNodesState([]);
|
||||
const [edges, setEdges, onEdgesChange] = useEdgesState([]);
|
||||
|
|
|
|||
|
|
@ -87,22 +87,22 @@ export function classNames(...classes) {
|
|||
} */
|
||||
|
||||
export const nodeColors = {
|
||||
prompt: "#7C7C7C",
|
||||
model: "#35ADAE",
|
||||
chain: "#FFDC35",
|
||||
agent: "#903BBE",
|
||||
tool: "#FF3434",
|
||||
memory: "#FF9135",
|
||||
prompts: "#7C7C7C",
|
||||
llms: "#35ADAE",
|
||||
chains: "#FFDC35",
|
||||
agents: "#903BBE",
|
||||
tools: "#FF3434",
|
||||
memories: "#FF9135",
|
||||
}
|
||||
|
||||
|
||||
export const nodeIcons = {
|
||||
agent: RocketLaunchIcon,
|
||||
chain: LinkIcon,
|
||||
memory: CpuChipIcon,
|
||||
model: LightBulbIcon,
|
||||
prompt: CommandLineIcon,
|
||||
tool: WrenchScrewdriverIcon,
|
||||
agents: RocketLaunchIcon,
|
||||
chains: LinkIcon,
|
||||
memories: CpuChipIcon,
|
||||
llms: LightBulbIcon,
|
||||
prompts: CommandLineIcon,
|
||||
tools: WrenchScrewdriverIcon,
|
||||
}
|
||||
|
||||
export const bgColors = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue