Merge branch 'dev' of https://github.com/logspace-ai/langflow into dev
This commit is contained in:
commit
b4ea2478e8
29 changed files with 494 additions and 181 deletions
|
|
@ -107,7 +107,6 @@ export default function GenericNode({
|
|||
setValidationStatus(null);
|
||||
}
|
||||
}, [sseData, data.id]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<NodeToolbar>
|
||||
|
|
|
|||
|
|
@ -37,7 +37,10 @@ export default function BuildTrigger({
|
|||
if (isBuilding) {
|
||||
return;
|
||||
}
|
||||
const errors = validateNodes(reactFlowInstance!);
|
||||
const errors = validateNodes(
|
||||
reactFlowInstance!.getNodes(),
|
||||
reactFlowInstance!.getEdges()
|
||||
);
|
||||
if (errors.length > 0) {
|
||||
setErrorData({
|
||||
title: "Oops! Looks like you missed something",
|
||||
|
|
|
|||
|
|
@ -256,7 +256,7 @@ const EditNodeModal = forwardRef(
|
|||
</div>
|
||||
) : myData.current.node?.template[templateParam]
|
||||
.type === "dict" ? (
|
||||
<div className="mt-2 w-full max-h-48 overflow-auto custom-scroll">
|
||||
<div className="mt-2 max-h-48 w-full overflow-auto custom-scroll">
|
||||
<KeypairListComponent
|
||||
disabled={disabled}
|
||||
editNode={true}
|
||||
|
|
|
|||
|
|
@ -356,7 +356,10 @@ export default function FormModal({
|
|||
}, [open]);
|
||||
|
||||
function sendMessage(): void {
|
||||
let nodeValidationErrors = validateNodes(reactFlowInstance!);
|
||||
let nodeValidationErrors = validateNodes(
|
||||
reactFlowInstance!.getNodes(),
|
||||
reactFlowInstance!.getEdges()
|
||||
);
|
||||
if (nodeValidationErrors.length === 0) {
|
||||
setLockChat(true);
|
||||
let inputs = tabsState[id.current].formKeysData.input_keys;
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ export default function NodeToolbarComponent({
|
|||
setShowNode((prev) => !prev);
|
||||
updateNodeInternals(data.id);
|
||||
}
|
||||
if(event.includes("disabled")){
|
||||
if (event.includes("disabled")) {
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
|
@ -156,8 +156,20 @@ export default function NodeToolbarComponent({
|
|||
</SelectTrigger>
|
||||
</ShadTooltip>
|
||||
<SelectContent>
|
||||
<SelectItem value={getRandomKeyByssmm() + (nodeLength==0?"disabled":"advanced")}>
|
||||
<div className={"flex "+(nodeLength==0?"text-muted-foreground":"text-primary")}>
|
||||
<SelectItem
|
||||
value={
|
||||
getRandomKeyByssmm() +
|
||||
(nodeLength == 0 ? "disabled" : "advanced")
|
||||
}
|
||||
>
|
||||
<div
|
||||
className={
|
||||
"flex " +
|
||||
(nodeLength == 0
|
||||
? "text-muted-foreground"
|
||||
: "text-primary")
|
||||
}
|
||||
>
|
||||
<IconComponent
|
||||
name="Settings2"
|
||||
className="relative top-0.5 mr-2 h-4 w-4"
|
||||
|
|
@ -182,7 +194,7 @@ export default function NodeToolbarComponent({
|
|||
<ShadTooltip content="Edit" side="top">
|
||||
<div>
|
||||
<button
|
||||
disabled={nodeLength === 0}
|
||||
disabled={nodeLength === 0}
|
||||
onClick={() => setShowModalAdvanced(true)}
|
||||
className={classNames(
|
||||
"relative -ml-px inline-flex items-center rounded-r-md bg-background px-2 py-2 text-foreground shadow-md ring-1 ring-inset ring-ring transition-all duration-500 ease-in-out hover:bg-muted focus:z-10" +
|
||||
|
|
|
|||
|
|
@ -41,13 +41,13 @@ export default function HomePage(): JSX.Element {
|
|||
|
||||
const dragOver = (e) => {
|
||||
e.preventDefault();
|
||||
if(e.dataTransfer.types.some((types) => types === "Files")){
|
||||
if (e.dataTransfer.types.some((types) => types === "Files")) {
|
||||
setIsDragging(true);
|
||||
}
|
||||
};
|
||||
|
||||
const dragEnter = (e) => {
|
||||
if(e.dataTransfer.types.some((types) => types === "Files")){
|
||||
if (e.dataTransfer.types.some((types) => types === "Files")) {
|
||||
setIsDragging(true);
|
||||
}
|
||||
e.preventDefault();
|
||||
|
|
|
|||
|
|
@ -134,18 +134,18 @@ export type TooltipComponentType = {
|
|||
children: ReactElement;
|
||||
title: string | ReactElement;
|
||||
placement?:
|
||||
| "bottom-end"
|
||||
| "bottom-start"
|
||||
| "bottom"
|
||||
| "left-end"
|
||||
| "left-start"
|
||||
| "left"
|
||||
| "right-end"
|
||||
| "right-start"
|
||||
| "right"
|
||||
| "top-end"
|
||||
| "top-start"
|
||||
| "top";
|
||||
| "bottom-end"
|
||||
| "bottom-start"
|
||||
| "bottom"
|
||||
| "left-end"
|
||||
| "left-start"
|
||||
| "left"
|
||||
| "right-end"
|
||||
| "right-start"
|
||||
| "right"
|
||||
| "top-end"
|
||||
| "top-start"
|
||||
| "top";
|
||||
};
|
||||
|
||||
export type ProgressBarType = {
|
||||
|
|
|
|||
|
|
@ -189,10 +189,7 @@ export function buildTweaks(flow: FlowType) {
|
|||
}, {});
|
||||
}
|
||||
|
||||
export function validateNode(
|
||||
node: NodeType,
|
||||
reactFlowInstance: ReactFlowInstance
|
||||
): Array<string> {
|
||||
export function validateNode(node: NodeType, edges: Edge[]): Array<string> {
|
||||
if (!node.data?.node?.template || !Object.keys(node.data.node.template)) {
|
||||
return [
|
||||
"We've noticed a potential issue with a node in the flow. Please review it and, if necessary, submit a bug report with your exported flow file. Thank you for your help!",
|
||||
|
|
@ -211,13 +208,11 @@ export function validateNode(
|
|||
(template[t].value === undefined ||
|
||||
template[t].value === null ||
|
||||
template[t].value === "") &&
|
||||
!reactFlowInstance
|
||||
.getEdges()
|
||||
.some(
|
||||
(edge) =>
|
||||
edge.targetHandle?.split("|")[1] === t &&
|
||||
edge.targetHandle.split("|")[2] === node.id
|
||||
)
|
||||
!edges.some(
|
||||
(edge) =>
|
||||
edge.targetHandle?.split("|")[1] === t &&
|
||||
edge.targetHandle.split("|")[2] === node.id
|
||||
)
|
||||
) {
|
||||
errors.push(
|
||||
`${type} is missing ${
|
||||
|
|
@ -249,15 +244,13 @@ export function validateNode(
|
|||
}, [] as string[]);
|
||||
}
|
||||
|
||||
export function validateNodes(reactFlowInstance: ReactFlowInstance) {
|
||||
if (reactFlowInstance.getNodes().length === 0) {
|
||||
export function validateNodes(nodes: Node[], edges: Edge[]) {
|
||||
if (nodes.length === 0) {
|
||||
return [
|
||||
"No nodes found in the flow. Please add at least one node to the flow.",
|
||||
];
|
||||
}
|
||||
return reactFlowInstance
|
||||
.getNodes()
|
||||
.flatMap((n: NodeType) => validateNode(n, reactFlowInstance));
|
||||
return nodes.flatMap((n: NodeType) => validateNode(n, edges));
|
||||
}
|
||||
|
||||
export function addVersionToDuplicates(flow: FlowType, flows: FlowType[]) {
|
||||
|
|
@ -311,15 +304,20 @@ export function getConnectedNodes(
|
|||
return nodes.filter((node) => node.id === targetId || node.id === sourceId);
|
||||
}
|
||||
|
||||
export function convertObjToArray(singleObject) {
|
||||
export function convertObjToArray(singleObject: object | string) {
|
||||
if (typeof singleObject === "string") {
|
||||
singleObject = JSON.parse(singleObject);
|
||||
}
|
||||
if (Array.isArray(singleObject)) return singleObject;
|
||||
|
||||
let arrConverted: any = [];
|
||||
for (const key in singleObject) {
|
||||
if (singleObject.hasOwnProperty(key)) {
|
||||
const newObj = {};
|
||||
newObj[key] = singleObject[key];
|
||||
arrConverted.push(newObj);
|
||||
let arrConverted: any[] = [];
|
||||
if (typeof singleObject === "object") {
|
||||
for (const key in singleObject) {
|
||||
if (Object.prototype.hasOwnProperty.call(singleObject, key)) {
|
||||
const newObj = {};
|
||||
newObj[key] = singleObject[key];
|
||||
arrConverted.push(newObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
return arrConverted;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue