null safety working properly
This commit is contained in:
parent
5680645ec0
commit
fb96ccd878
4 changed files with 24 additions and 18 deletions
|
|
@ -56,5 +56,5 @@
|
||||||
"last 1 safari version"
|
"last 1 safari version"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"proxy": "http://localhost:7860"
|
"proxy": "http://backend:7860"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,18 +19,19 @@ export default function GenericNode({
|
||||||
selected: boolean;
|
selected: boolean;
|
||||||
}) {
|
}) {
|
||||||
const { setErrorData } = useContext(alertContext);
|
const { setErrorData } = useContext(alertContext);
|
||||||
const showError = useRef(true)
|
const showError = useRef(true);
|
||||||
const { types, deleteNode } = useContext(typesContext);
|
const { types, deleteNode } = useContext(typesContext);
|
||||||
const Icon = nodeIcons[types[data.type]];
|
const Icon = nodeIcons[types[data.type]];
|
||||||
if (!Icon) {
|
if (!Icon) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
if(showError.current){
|
if (showError.current) {
|
||||||
setErrorData({
|
setErrorData({
|
||||||
title: data.type?`The ${data.type} node could not be rendered, please review your json file`:
|
title: data.type
|
||||||
"There was a node that can't be rendered, please review your json file",
|
? `The ${data.type} node could not be rendered, please review your json file`
|
||||||
});
|
: "There was a node that can't be rendered, please review your json file",
|
||||||
showError.current=false
|
});
|
||||||
}
|
showError.current = false;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -45,7 +46,9 @@ export default function GenericNode({
|
||||||
<div className="w-full flex items-center truncate gap-4 text-lg">
|
<div className="w-full flex items-center truncate gap-4 text-lg">
|
||||||
<Icon
|
<Icon
|
||||||
className="w-10 h-10 p-1 rounded"
|
className="w-10 h-10 p-1 rounded"
|
||||||
style={{ color: nodeColors[types[data.type]] }}
|
style={{
|
||||||
|
color: nodeColors[types[data.type]] ?? nodeColors.unknown,
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<div className="truncate">{data.type}</div>
|
<div className="truncate">{data.type}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -80,8 +83,7 @@ export default function GenericNode({
|
||||||
data={data}
|
data={data}
|
||||||
color={
|
color={
|
||||||
nodeColors[types[data.node.template[t].type]] ??
|
nodeColors[types[data.node.template[t].type]] ??
|
||||||
nodeColors[types[data.node.template[t].type]] ??
|
nodeColors.unknown
|
||||||
"black"
|
|
||||||
}
|
}
|
||||||
title={snakeToNormalCase(t)}
|
title={snakeToNormalCase(t)}
|
||||||
name={t}
|
name={t}
|
||||||
|
|
@ -105,7 +107,7 @@ export default function GenericNode({
|
||||||
</div>
|
</div>
|
||||||
<ParameterComponent
|
<ParameterComponent
|
||||||
data={data}
|
data={data}
|
||||||
color={nodeColors[types[data.type]]}
|
color={nodeColors[types[data.type]] ?? nodeColors.unknown}
|
||||||
title={data.type}
|
title={data.type}
|
||||||
tooltipTitle={`Type: ${data.node.base_classes.join(" | ")}`}
|
tooltipTitle={`Type: ${data.node.base_classes.join(" | ")}`}
|
||||||
id={[data.type, data.id, ...data.node.base_classes].join("|")}
|
id={[data.type, data.id, ...data.node.base_classes].join("|")}
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ export default function ExtraSidebar() {
|
||||||
{Object.keys(data).map((d:keyof APIObjectType, i) => (
|
{Object.keys(data).map((d:keyof APIObjectType, i) => (
|
||||||
<DisclosureComponent
|
<DisclosureComponent
|
||||||
key={i}
|
key={i}
|
||||||
button={{ title: nodeNames[d], Icon: nodeIcons[d] }}
|
button={{ title: nodeNames[d]??nodeNames.unknown, Icon: nodeIcons[d]??nodeIcons.unknown }}
|
||||||
>
|
>
|
||||||
<div className="p-2 flex flex-col gap-2">
|
<div className="p-2 flex flex-col gap-2">
|
||||||
{Object.keys(data[d]).map((t: string, k) => (
|
{Object.keys(data[d]).map((t: string, k) => (
|
||||||
|
|
@ -63,7 +63,7 @@ export default function ExtraSidebar() {
|
||||||
<div
|
<div
|
||||||
draggable
|
draggable
|
||||||
className={" cursor-grab border-l-8 rounded-l-md"}
|
className={" cursor-grab border-l-8 rounded-l-md"}
|
||||||
style={{ borderLeftColor: nodeColors[d] }}
|
style={{ borderLeftColor: nodeColors[d]??nodeColors.unknown }}
|
||||||
onDragStart={(event) =>
|
onDragStart={(event) =>
|
||||||
onDragStart(event, {
|
onDragStart(event, {
|
||||||
type: t,
|
type: t,
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import {
|
||||||
ComputerDesktopIcon,
|
ComputerDesktopIcon,
|
||||||
Bars3CenterLeftIcon,
|
Bars3CenterLeftIcon,
|
||||||
PaperClipIcon,
|
PaperClipIcon,
|
||||||
|
QuestionMarkCircleIcon,
|
||||||
} from "@heroicons/react/24/outline";
|
} from "@heroicons/react/24/outline";
|
||||||
import { Connection, Edge, Node, ReactFlowInstance } from "reactflow";
|
import { Connection, Edge, Node, ReactFlowInstance } from "reactflow";
|
||||||
import { FlowType } from "./types/flow";
|
import { FlowType } from "./types/flow";
|
||||||
|
|
@ -73,7 +74,8 @@ export const nodeColors: {[char: string]: string} = {
|
||||||
advanced: "#000000",
|
advanced: "#000000",
|
||||||
chat: "#454173",
|
chat: "#454173",
|
||||||
thought:"#272541",
|
thought:"#272541",
|
||||||
docloaders:"#10B981"
|
docloaders:"#FF9135",
|
||||||
|
unknown:"#9CA3AF"
|
||||||
};
|
};
|
||||||
|
|
||||||
export const nodeNames:{[char: string]: string} = {
|
export const nodeNames:{[char: string]: string} = {
|
||||||
|
|
@ -85,7 +87,8 @@ export const nodeNames:{[char: string]: string} = {
|
||||||
memories: "Memories",
|
memories: "Memories",
|
||||||
advanced: "Advanced",
|
advanced: "Advanced",
|
||||||
chat: "Chat",
|
chat: "Chat",
|
||||||
docloaders:"Document Loader"
|
docloaders:"Document Loader",
|
||||||
|
unknown:"Unknown"
|
||||||
};
|
};
|
||||||
|
|
||||||
export const nodeIcons:{[char: string]: React.ForwardRefExoticComponent<React.SVGProps<SVGSVGElement>>} = {
|
export const nodeIcons:{[char: string]: React.ForwardRefExoticComponent<React.SVGProps<SVGSVGElement>>} = {
|
||||||
|
|
@ -97,7 +100,8 @@ export const nodeIcons:{[char: string]: React.ForwardRefExoticComponent<React.SV
|
||||||
tools: WrenchScrewdriverIcon,
|
tools: WrenchScrewdriverIcon,
|
||||||
advanced: ComputerDesktopIcon,
|
advanced: ComputerDesktopIcon,
|
||||||
chat: Bars3CenterLeftIcon,
|
chat: Bars3CenterLeftIcon,
|
||||||
docloaders:PaperClipIcon
|
docloaders:Bars3CenterLeftIcon,
|
||||||
|
unknown:QuestionMarkCircleIcon
|
||||||
};
|
};
|
||||||
|
|
||||||
export const bgColors = {
|
export const bgColors = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue