Merge branch 'consumingApi' into dev

This commit is contained in:
Lucas Oliveira 2023-02-14 16:41:35 -03:00
commit 3d01321a09
8 changed files with 124 additions and 16 deletions

View file

@ -18,6 +18,7 @@
"@types/node": "^16.18.12",
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
"axios": "^1.3.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^4.7.1",
@ -5073,6 +5074,29 @@
"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": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.1.1.tgz",
@ -14159,6 +14183,11 @@
"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": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz",

View file

@ -13,6 +13,7 @@
"@types/node": "^16.18.12",
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
"axios": "^1.3.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^4.7.1",

View file

@ -1,7 +1,7 @@
import { Transition } from "@headlessui/react";
import { Handle, Position } from "reactflow";
export default function ValidatorNode({ data }) {
export default function ToolsNode({ data }) {
console.log(data);
return (
<Transition
@ -20,9 +20,9 @@ export default function ValidatorNode({ data }) {
>
<Handle type="source" position={Position.Left}></Handle>
<label className="absolute cursor-grab text-sm -top-3 left-1 bg-white w-14 text-center">
Validator
Tools
</label>
<div className="w-full h-min text-xs text-center">validator data</div>
<div className="w-full h-min text-xs text-center">Tools data</div>
<Handle type="target" position={Position.Right}></Handle>
</div>
</Transition>

View file

@ -0,0 +1,61 @@
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);
}

View file

@ -0,0 +1,11 @@
import axios from "axios";
export function generateUiNode(data: Object) {
const fields = [];
Object.keys(data).forEach((field) => {
if (data[field].required) {
fields.push(data[field])
}
});
return fields
}

View file

@ -0,0 +1,4 @@
export enum apiEnum
{
PromptTemplate="PromptTemplate"
}

View file

@ -1,12 +1,4 @@
import {
Bars2Icon,
CommandLineIcon,
CpuChipIcon,
LightBulbIcon,
LinkIcon,
RocketLaunchIcon,
ShieldCheckIcon,
} from "@heroicons/react/24/outline";
import { Bars2Icon, CommandLineIcon, CpuChipIcon, LightBulbIcon, LinkIcon, RocketLaunchIcon, WrenchScrewdriverIcon, ViewColumnsIcon } from "@heroicons/react/24/outline";
import { llm_chain } from "../../../../data_assets/llm_chain";
import { prompt } from "../../../../data_assets/prompt";
import DisclosureComponent from "../DisclosureComponent";
@ -29,7 +21,7 @@ export function ExtraSidebar() {
if (nodeType === "agentNode") {
json = JSON.stringify({ content: "" });
}
if (nodeType === "validatorNode") {
if (nodeType === "toolNode") {
json = JSON.stringify({ content: "" });
}
if (nodeType === "memoryNode") {
@ -90,7 +82,7 @@ export function ExtraSidebar() {
</div>
</DisclosureComponent>
<DisclosureComponent
button={{ title: "Validators", Icon: ShieldCheckIcon }}
button={{ title: "Tools", Icon: WrenchScrewdriverIcon }}
>
<div className="p-2">
<div draggable className={" cursor-grab border-l-8 rounded-l-md"} style={{borderLeftColor: nodeColors['validator']}} onDragStart={(event) => onDragStart(event, "promptNode")}>

View file

@ -12,8 +12,11 @@ import { locationContext } from "../../contexts/locationContext";
import { ExtraSidebar } from "./components/extraSidebarComponent";
import AgentNode from "../../CustomNodes/AgentNode";
import ChainNode from "../../CustomNodes/ChainNode";
import ValidatorNode from "../../CustomNodes/ValidatorNode";
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";
const nodeTypes = {
@ -21,11 +24,18 @@ const nodeTypes = {
modelNode: ModelNode,
chainNode: ChainNode,
agentNode: AgentNode,
validatorNode: ValidatorNode,
toolNode: ToolsNode,
memoryNode:MemoryNode
};
export default function FlowPage() {
// getPrompts().then(result=>result.forEach(prompt=>console.log(prompt)))
// getChains().then(result=>console.log(result))
// 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);