format code
This commit is contained in:
parent
7aa437e92f
commit
bba2942d37
13 changed files with 210 additions and 226 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
from langflow.database.models.flow import Flow
|
from langflow.database.models.flow import Flow
|
||||||
from langflow.processing.process import process_graph_cached, process_tweaks
|
from langflow.processing.process import process_graph_cached, process_tweaks
|
||||||
from langflow.utils.logger import logger
|
from langflow.utils.logger import logger
|
||||||
from importlib.metadata import version
|
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends, HTTPException
|
from fastapi import APIRouter, Depends, HTTPException
|
||||||
from fastapi.security import HTTPBearer
|
from fastapi.security import HTTPBearer
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ from langflow.graph.vertex.types import (
|
||||||
)
|
)
|
||||||
from langflow.interface.tools.constants import FILE_TOOLS
|
from langflow.interface.tools.constants import FILE_TOOLS
|
||||||
from langflow.utils import payload
|
from langflow.utils import payload
|
||||||
from langflow.utils.logger import logger
|
|
||||||
|
|
||||||
|
|
||||||
class Graph:
|
class Graph:
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,6 @@ export default function ParameterComponent({
|
||||||
}
|
}
|
||||||
onChange={(t: string[]) => {
|
onChange={(t: string[]) => {
|
||||||
data.node.template[name].value = t;
|
data.node.template[name].value = t;
|
||||||
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
) : data.node.template[name].multiline ? (
|
) : data.node.template[name].multiline ? (
|
||||||
|
|
@ -176,7 +175,6 @@ export default function ParameterComponent({
|
||||||
value={data.node.template[name].value ?? ""}
|
value={data.node.template[name].value ?? ""}
|
||||||
onChange={(t: string) => {
|
onChange={(t: string) => {
|
||||||
data.node.template[name].value = t;
|
data.node.template[name].value = t;
|
||||||
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
|
|
@ -187,7 +185,6 @@ export default function ParameterComponent({
|
||||||
value={data.node.template[name].value ?? ""}
|
value={data.node.template[name].value ?? ""}
|
||||||
onChange={(t) => {
|
onChange={(t) => {
|
||||||
data.node.template[name].value = t;
|
data.node.template[name].value = t;
|
||||||
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
@ -200,7 +197,6 @@ export default function ParameterComponent({
|
||||||
setEnabled={(t) => {
|
setEnabled={(t) => {
|
||||||
data.node.template[name].value = t;
|
data.node.template[name].value = t;
|
||||||
setEnabled(t);
|
setEnabled(t);
|
||||||
|
|
||||||
}}
|
}}
|
||||||
size="large"
|
size="large"
|
||||||
/>
|
/>
|
||||||
|
|
@ -234,7 +230,6 @@ export default function ParameterComponent({
|
||||||
value={data.node.template[name].value ?? ""}
|
value={data.node.template[name].value ?? ""}
|
||||||
onChange={(t: string) => {
|
onChange={(t: string) => {
|
||||||
data.node.template[name].value = t;
|
data.node.template[name].value = t;
|
||||||
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
) : left === true && type === "file" ? (
|
) : left === true && type === "file" ? (
|
||||||
|
|
@ -248,7 +243,6 @@ export default function ParameterComponent({
|
||||||
suffixes={data.node.template[name].suffixes}
|
suffixes={data.node.template[name].suffixes}
|
||||||
onFileChange={(t: string) => {
|
onFileChange={(t: string) => {
|
||||||
data.node.template[name].content = t;
|
data.node.template[name].content = t;
|
||||||
|
|
||||||
}}
|
}}
|
||||||
></InputFileComponent>
|
></InputFileComponent>
|
||||||
) : left === true && type === "int" ? (
|
) : left === true && type === "int" ? (
|
||||||
|
|
@ -259,7 +253,6 @@ export default function ParameterComponent({
|
||||||
value={data.node.template[name].value ?? ""}
|
value={data.node.template[name].value ?? ""}
|
||||||
onChange={(t) => {
|
onChange={(t) => {
|
||||||
data.node.template[name].value = t;
|
data.node.template[name].value = t;
|
||||||
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -269,7 +262,6 @@ export default function ParameterComponent({
|
||||||
value={data.node.template[name].value ?? ""}
|
value={data.node.template[name].value ?? ""}
|
||||||
onChange={(t: string) => {
|
onChange={(t: string) => {
|
||||||
data.node.template[name].value = t;
|
data.node.template[name].value = t;
|
||||||
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,3 @@
|
||||||
import {
|
|
||||||
BugAntIcon,
|
|
||||||
Cog6ToothIcon,
|
|
||||||
InformationCircleIcon,
|
|
||||||
TrashIcon,
|
|
||||||
} from "@heroicons/react/24/outline";
|
|
||||||
|
|
||||||
import {
|
|
||||||
CheckCircleIcon,
|
|
||||||
EllipsisHorizontalCircleIcon,
|
|
||||||
ExclamationCircleIcon,
|
|
||||||
} from "@heroicons/react/24/solid";
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
classNames,
|
classNames,
|
||||||
nodeColors,
|
nodeColors,
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,25 @@ import { Link } from "react-router-dom";
|
||||||
import { TabsContext } from "../../contexts/tabsContext";
|
import { TabsContext } from "../../contexts/tabsContext";
|
||||||
import { FlowType } from "../../types/flow";
|
import { FlowType } from "../../types/flow";
|
||||||
import { gradients } from "../../utils";
|
import { gradients } from "../../utils";
|
||||||
import { CardTitle, CardDescription, CardFooter, Card, CardHeader } from "../ui/card";
|
import {
|
||||||
|
CardTitle,
|
||||||
|
CardDescription,
|
||||||
|
CardFooter,
|
||||||
|
Card,
|
||||||
|
CardHeader,
|
||||||
|
} from "../ui/card";
|
||||||
|
|
||||||
|
export const CardComponent = ({
|
||||||
export const CardComponent = ({ flow, id, onDelete, button }: { flow: FlowType; id: string, onDelete?: () => void, button?: JSX.Element }) => {
|
flow,
|
||||||
|
id,
|
||||||
|
onDelete,
|
||||||
|
button,
|
||||||
|
}: {
|
||||||
|
flow: FlowType;
|
||||||
|
id: string;
|
||||||
|
onDelete?: () => void;
|
||||||
|
button?: JSX.Element;
|
||||||
|
}) => {
|
||||||
const { removeFlow } = useContext(TabsContext);
|
const { removeFlow } = useContext(TabsContext);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -20,19 +35,14 @@ export const CardComponent = ({ flow, id, onDelete, button }: { flow: FlowType;
|
||||||
"rounded-full w-8 h-8 flex items-center justify-center text-2xl " +
|
"rounded-full w-8 h-8 flex items-center justify-center text-2xl " +
|
||||||
gradients[parseInt(flow.id.slice(0, 6), 16) % gradients.length]
|
gradients[parseInt(flow.id.slice(0, 6), 16) % gradients.length]
|
||||||
}
|
}
|
||||||
>
|
></span>
|
||||||
</span>
|
<span className="flex-1 truncate-doubleline">{flow.name}</span>
|
||||||
<span className="flex-1 truncate-doubleline">
|
|
||||||
{flow.name}
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
{onDelete &&
|
{onDelete && (
|
||||||
<button
|
<button onClick={onDelete}>
|
||||||
onClick={onDelete}
|
|
||||||
>
|
|
||||||
<Trash2 className="w-4 h-4 text-primary opacity-0 group-hover:opacity-100 transition-all" />
|
<Trash2 className="w-4 h-4 text-primary opacity-0 group-hover:opacity-100 transition-all" />
|
||||||
</button>
|
</button>
|
||||||
}
|
)}
|
||||||
</CardTitle>
|
</CardTitle>
|
||||||
<CardDescription className="pt-2 pb-2">
|
<CardDescription className="pt-2 pb-2">
|
||||||
<div className="truncate-doubleline">
|
<div className="truncate-doubleline">
|
||||||
|
|
@ -53,10 +63,7 @@ export const CardComponent = ({ flow, id, onDelete, button }: { flow: FlowType;
|
||||||
<span className="text-base"> </span>OpenAI+
|
<span className="text-base"> </span>OpenAI+
|
||||||
</Badge> */}
|
</Badge> */}
|
||||||
</div>
|
</div>
|
||||||
{button &&
|
{button && button}
|
||||||
button
|
|
||||||
}
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</CardFooter>
|
</CardFooter>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
|
||||||
|
|
@ -28,10 +28,7 @@ export default function Header() {
|
||||||
<span className="text-2xl ml-4">⛓️</span>
|
<span className="text-2xl ml-4">⛓️</span>
|
||||||
</Link>
|
</Link>
|
||||||
{flows.findIndex((f) => tabId === f.id) !== -1 && tabId !== "" && (
|
{flows.findIndex((f) => tabId === f.id) !== -1 && tabId !== "" && (
|
||||||
<MenuBar
|
<MenuBar flows={flows} tabId={tabId} />
|
||||||
flows={flows}
|
|
||||||
tabId={tabId}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex gap-2 items-center">
|
<div className="flex gap-2 items-center">
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ export default function ToggleShadComponent({
|
||||||
enabled,
|
enabled,
|
||||||
setEnabled,
|
setEnabled,
|
||||||
disabled,
|
disabled,
|
||||||
size
|
size,
|
||||||
}: ToggleComponentType) {
|
}: ToggleComponentType) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (disabled) {
|
if (disabled) {
|
||||||
|
|
|
||||||
|
|
@ -126,4 +126,3 @@ export const EXPORT_CODE_DIALOG =
|
||||||
*/
|
*/
|
||||||
export const INPUT_STYLE =
|
export const INPUT_STYLE =
|
||||||
" focus:ring-1 focus:ring-offset-1 focus:ring-ring focus:outline-none ";
|
" focus:ring-1 focus:ring-offset-1 focus:ring-ring focus:outline-none ";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,10 @@
|
||||||
import { createContext, useCallback, useContext, useEffect, useState } from "react";
|
import {
|
||||||
|
createContext,
|
||||||
|
useCallback,
|
||||||
|
useContext,
|
||||||
|
useEffect,
|
||||||
|
useState,
|
||||||
|
} from "react";
|
||||||
import { Edge, Node, useReactFlow } from "reactflow";
|
import { Edge, Node, useReactFlow } from "reactflow";
|
||||||
import { cloneDeep } from "lodash";
|
import { cloneDeep } from "lodash";
|
||||||
import { TabsContext } from "./tabsContext";
|
import { TabsContext } from "./tabsContext";
|
||||||
|
|
@ -45,14 +51,15 @@ export function UndoRedoProvider({ children }) {
|
||||||
|
|
||||||
const [past, setPast] = useState<HistoryItem[][]>(flows.map(() => []));
|
const [past, setPast] = useState<HistoryItem[][]>(flows.map(() => []));
|
||||||
const [future, setFuture] = useState<HistoryItem[][]>(flows.map(() => []));
|
const [future, setFuture] = useState<HistoryItem[][]>(flows.map(() => []));
|
||||||
const [tabIndex, setTabIndex] = useState(flows.findIndex((f) => f.id === tabId));
|
const [tabIndex, setTabIndex] = useState(
|
||||||
|
flows.findIndex((f) => f.id === tabId)
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// whenever the flows variable changes, we need to add one array to the past and future states
|
// whenever the flows variable changes, we need to add one array to the past and future states
|
||||||
setPast((old) => flows.map((f, i) => (old[i] ? old[i] : [])));
|
setPast((old) => flows.map((f, i) => (old[i] ? old[i] : [])));
|
||||||
setFuture((old) => flows.map((f, i) => (old[i] ? old[i] : [])));
|
setFuture((old) => flows.map((f, i) => (old[i] ? old[i] : [])));
|
||||||
setTabIndex(flows.findIndex((f) => f.id === tabId));
|
setTabIndex(flows.findIndex((f) => f.id === tabId));
|
||||||
|
|
||||||
}, [flows, tabId]);
|
}, [flows, tabId]);
|
||||||
|
|
||||||
const { setNodes, setEdges, getNodes, getEdges } = useReactFlow();
|
const { setNodes, setEdges, getNodes, getEdges } = useReactFlow();
|
||||||
|
|
@ -77,16 +84,7 @@ export function UndoRedoProvider({ children }) {
|
||||||
newFuture[tabIndex] = [];
|
newFuture[tabIndex] = [];
|
||||||
return newFuture;
|
return newFuture;
|
||||||
});
|
});
|
||||||
}, [
|
}, [getNodes, getEdges, past, future, flows, tabId, setPast, setFuture]);
|
||||||
getNodes,
|
|
||||||
getEdges,
|
|
||||||
past,
|
|
||||||
future,
|
|
||||||
flows,
|
|
||||||
tabId,
|
|
||||||
setPast,
|
|
||||||
setFuture,
|
|
||||||
]);
|
|
||||||
|
|
||||||
const undo = useCallback(() => {
|
const undo = useCallback(() => {
|
||||||
// get the last state that we want to go back to
|
// get the last state that we want to go back to
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import { PromptTypeAPI, errorsTypeAPI } from "./../../types/api/index";
|
||||||
import { APIObjectType, sendAllProps } from "../../types/api/index";
|
import { APIObjectType, sendAllProps } from "../../types/api/index";
|
||||||
import axios, { AxiosResponse } from "axios";
|
import axios, { AxiosResponse } from "axios";
|
||||||
import { FlowStyleType, FlowType } from "../../types/flow";
|
import { FlowStyleType, FlowType } from "../../types/flow";
|
||||||
|
import { ReactFlowJsonObject } from "reactflow";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches all objects from the API endpoint.
|
* Fetches all objects from the API endpoint.
|
||||||
|
|
@ -76,7 +77,13 @@ export async function getExamples(): Promise<FlowType[]> {
|
||||||
* @returns {Promise<any>} The saved flow data.
|
* @returns {Promise<any>} The saved flow data.
|
||||||
* @throws Will throw an error if saving fails.
|
* @throws Will throw an error if saving fails.
|
||||||
*/
|
*/
|
||||||
export async function saveFlowToDatabase(newFlow: FlowType): Promise<FlowType> {
|
export async function saveFlowToDatabase(newFlow: {
|
||||||
|
name: string;
|
||||||
|
id: string;
|
||||||
|
data: ReactFlowJsonObject;
|
||||||
|
description: string;
|
||||||
|
style?: FlowStyleType;
|
||||||
|
}): Promise<FlowType> {
|
||||||
try {
|
try {
|
||||||
const response = await axios.post("/api/v1/flows/", {
|
const response = await axios.post("/api/v1/flows/", {
|
||||||
name: newFlow.name,
|
name: newFlow.name,
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,6 @@ export default function FlowSettingsModal() {
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle className="flex items-center">
|
<DialogTitle className="flex items-center">
|
||||||
<span className="pr-2">Settings</span>
|
<span className="pr-2">Settings</span>
|
||||||
|
|
||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
<DialogDescription>{SETTINGS_DIALOG_SUBTITLE}</DialogDescription>
|
<DialogDescription>{SETTINGS_DIALOG_SUBTITLE}</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { Route, Routes } from "react-router-dom"
|
import { Route, Routes } from "react-router-dom";
|
||||||
import HomePage from "./pages/MainPage";
|
import HomePage from "./pages/MainPage";
|
||||||
import FlowPage from "./pages/FlowPage";
|
import FlowPage from "./pages/FlowPage";
|
||||||
import CommunityPage from "./pages/CommunityPage";
|
import CommunityPage from "./pages/CommunityPage";
|
||||||
|
|
@ -12,7 +12,7 @@ const Router = () => {
|
||||||
<Route path="" element={<FlowPage />} />
|
<Route path="" element={<FlowPage />} />
|
||||||
</Route>
|
</Route>
|
||||||
</Routes>
|
</Routes>
|
||||||
)
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default Router;
|
export default Router;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue