refactor[modals]: Add types to functions that didnt have it
This commit is contained in:
parent
3a055b7411
commit
76a0a40656
22 changed files with 101 additions and 60 deletions
|
|
@ -1,4 +1,7 @@
|
||||||
export default function CrashErrorComponent({ error, resetErrorBoundary }): JSX.Element {
|
export default function CrashErrorComponent({
|
||||||
|
error,
|
||||||
|
resetErrorBoundary,
|
||||||
|
}): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<div className="fixed left-0 top-0 z-50 flex h-full w-full items-center justify-center bg-foreground bg-opacity-50">
|
<div className="fixed left-0 top-0 z-50 flex h-full w-full items-center justify-center bg-foreground bg-opacity-50">
|
||||||
<div className="flex h-1/3 min-h-fit max-w-4xl flex-col justify-evenly rounded-lg bg-background p-8 text-start shadow-lg">
|
<div className="flex h-1/3 min-h-fit max-w-4xl flex-col justify-evenly rounded-lg bg-background p-8 text-start shadow-lg">
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,15 @@ import {
|
||||||
FLOW_NOT_BUILT_TITLE,
|
FLOW_NOT_BUILT_TITLE,
|
||||||
} from "../../../constants/constants";
|
} from "../../../constants/constants";
|
||||||
import { alertContext } from "../../../contexts/alertContext";
|
import { alertContext } from "../../../contexts/alertContext";
|
||||||
import IconComponent from "../../genericIconComponent";
|
|
||||||
import { chatTriggerPropType } from "../../../types/components";
|
import { chatTriggerPropType } from "../../../types/components";
|
||||||
|
import IconComponent from "../../genericIconComponent";
|
||||||
|
|
||||||
export default function ChatTrigger({ open, setOpen, isBuilt, canOpen }: chatTriggerPropType): JSX.Element {
|
export default function ChatTrigger({
|
||||||
|
open,
|
||||||
|
setOpen,
|
||||||
|
isBuilt,
|
||||||
|
canOpen,
|
||||||
|
}: chatTriggerPropType): JSX.Element {
|
||||||
const { setErrorData } = useContext(alertContext);
|
const { setErrorData } = useContext(alertContext);
|
||||||
|
|
||||||
function handleClick(): void {
|
function handleClick(): void {
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,9 @@ import { Link, useNavigate } from "react-router-dom";
|
||||||
import { alertContext } from "../../../../contexts/alertContext";
|
import { alertContext } from "../../../../contexts/alertContext";
|
||||||
import { undoRedoContext } from "../../../../contexts/undoRedoContext";
|
import { undoRedoContext } from "../../../../contexts/undoRedoContext";
|
||||||
import FlowSettingsModal from "../../../../modals/flowSettingsModal";
|
import FlowSettingsModal from "../../../../modals/flowSettingsModal";
|
||||||
|
import { menuBarPropsType } from "../../../../types/components";
|
||||||
import IconComponent from "../../../genericIconComponent";
|
import IconComponent from "../../../genericIconComponent";
|
||||||
import { Button } from "../../../ui/button";
|
import { Button } from "../../../ui/button";
|
||||||
import { menuBarPropsType } from "../../../../types/components";
|
|
||||||
|
|
||||||
export const MenuBar = ({ flows, tabId }: menuBarPropsType): JSX.Element => {
|
export const MenuBar = ({ flows, tabId }: menuBarPropsType): JSX.Element => {
|
||||||
const { updateFlow, setTabId, addFlow } = useContext(TabsContext);
|
const { updateFlow, setTabId, addFlow } = useContext(TabsContext);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
import { LoadingComponentProps } from "../../types/components";
|
import { LoadingComponentProps } from "../../types/components";
|
||||||
|
|
||||||
export default function LoadingComponent({ remSize }: LoadingComponentProps): JSX.Element {
|
export default function LoadingComponent({
|
||||||
|
remSize,
|
||||||
|
}: LoadingComponentProps): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<div role="status" className="m-auto w-min">
|
<div role="status" className="m-auto w-min">
|
||||||
<svg
|
<svg
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ export default function ToggleComponent({
|
||||||
setEnabled,
|
setEnabled,
|
||||||
disabled,
|
disabled,
|
||||||
}: ToggleComponentType): JSX.Element {
|
}: ToggleComponentType): JSX.Element {
|
||||||
|
|
||||||
// set component state as disabled
|
// set component state as disabled
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (disabled) {
|
if (disabled) {
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ import {
|
||||||
getPythonApiCode,
|
getPythonApiCode,
|
||||||
getPythonCode,
|
getPythonCode,
|
||||||
} from "../../utils/utils";
|
} from "../../utils/utils";
|
||||||
export default function ApiModal({ flow }: { flow: FlowType }) {
|
export default function ApiModal({ flow }: { flow: FlowType }): JSX.Element {
|
||||||
const [open, setOpen] = useState(true);
|
const [open, setOpen] = useState(true);
|
||||||
const { dark } = useContext(darkContext);
|
const { dark } = useContext(darkContext);
|
||||||
const { closePopUp, closeEdit, setCloseEdit } = useContext(PopUpContext);
|
const { closePopUp, closeEdit, setCloseEdit } = useContext(PopUpContext);
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,11 @@ import { typesContext } from "../../contexts/typesContext";
|
||||||
import { NodeDataType } from "../../types/flow";
|
import { NodeDataType } from "../../types/flow";
|
||||||
import { classNames } from "../../utils/utils";
|
import { classNames } from "../../utils/utils";
|
||||||
|
|
||||||
export default function EditNodeModal({ data }: { data: NodeDataType }) {
|
export default function EditNodeModal({
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
data: NodeDataType;
|
||||||
|
}): JSX.Element {
|
||||||
const [open, setOpen] = useState(true);
|
const [open, setOpen] = useState(true);
|
||||||
const [nodeLength, setNodeLength] = useState(
|
const [nodeLength, setNodeLength] = useState(
|
||||||
Object.keys(data.node.template).filter(
|
Object.keys(data.node.template).filter(
|
||||||
|
|
@ -66,7 +70,7 @@ export default function EditNodeModal({ data }: { data: NodeDataType }) {
|
||||||
closePopUp();
|
closePopUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
function setModalOpen(x: boolean) {
|
function setModalOpen(x: boolean): void {
|
||||||
setOpen(x);
|
setOpen(x);
|
||||||
if (x === false) {
|
if (x === false) {
|
||||||
closePopUp();
|
closePopUp();
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,11 @@ import { nodeColors, nodeIconsLucide } from "../../utils/styleUtils";
|
||||||
import { classNames, toTitleCase } from "../../utils/utils";
|
import { classNames, toTitleCase } from "../../utils/utils";
|
||||||
import ModalField from "./components/ModalField";
|
import ModalField from "./components/ModalField";
|
||||||
|
|
||||||
export default function NodeModal({ data }: { data: NodeDataType }) {
|
export default function NodeModal({
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
data: NodeDataType;
|
||||||
|
}): JSX.Element {
|
||||||
const [open, setOpen] = useState(true);
|
const [open, setOpen] = useState(true);
|
||||||
const { closePopUp } = useContext(PopUpContext);
|
const { closePopUp } = useContext(PopUpContext);
|
||||||
const { types } = useContext(typesContext);
|
const { types } = useContext(typesContext);
|
||||||
|
|
|
||||||
|
|
@ -26,13 +26,13 @@ export default function CodeAreaModal({
|
||||||
value: string;
|
value: string;
|
||||||
nodeClass: APIClassType;
|
nodeClass: APIClassType;
|
||||||
setNodeClass: (Class: APIClassType) => void;
|
setNodeClass: (Class: APIClassType) => void;
|
||||||
}) {
|
}): JSX.Element {
|
||||||
const [code, setCode] = useState(value);
|
const [code, setCode] = useState(value);
|
||||||
const { dark } = useContext(darkContext);
|
const { dark } = useContext(darkContext);
|
||||||
const { closePopUp, setCloseEdit } = useContext(PopUpContext);
|
const { closePopUp, setCloseEdit } = useContext(PopUpContext);
|
||||||
const { setErrorData, setSuccessData } = useContext(alertContext);
|
const { setErrorData, setSuccessData } = useContext(alertContext);
|
||||||
|
|
||||||
function setModalOpen(x: boolean) {
|
function setModalOpen(x: boolean): void {
|
||||||
if (x === false) {
|
if (x === false) {
|
||||||
setCloseEdit("codearea");
|
setCloseEdit("codearea");
|
||||||
closePopUp();
|
closePopUp();
|
||||||
|
|
@ -40,7 +40,7 @@ export default function CodeAreaModal({
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for custom code errors
|
// Check for custom code errors
|
||||||
function handleClick() {
|
function handleClick(): void {
|
||||||
postValidateCode(code)
|
postValidateCode(code)
|
||||||
.then((apiReturn) => {
|
.then((apiReturn) => {
|
||||||
if (apiReturn.data) {
|
if (apiReturn.data) {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import { PopUpContext } from "../../contexts/popUpContext";
|
||||||
import { TabsContext } from "../../contexts/tabsContext";
|
import { TabsContext } from "../../contexts/tabsContext";
|
||||||
import { removeApiKeys } from "../../utils/reactflowUtils";
|
import { removeApiKeys } from "../../utils/reactflowUtils";
|
||||||
|
|
||||||
export default function ExportModal() {
|
export default function ExportModal(): JSX.Element {
|
||||||
const [open, setOpen] = useState(true);
|
const [open, setOpen] = useState(true);
|
||||||
const { closePopUp } = useContext(PopUpContext);
|
const { closePopUp } = useContext(PopUpContext);
|
||||||
const ref = useRef();
|
const ref = useRef();
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ import { alertContext } from "../../contexts/alertContext";
|
||||||
import { PopUpContext } from "../../contexts/popUpContext";
|
import { PopUpContext } from "../../contexts/popUpContext";
|
||||||
import { TabsContext } from "../../contexts/tabsContext";
|
import { TabsContext } from "../../contexts/tabsContext";
|
||||||
|
|
||||||
export default function FlowSettingsModal() {
|
export default function FlowSettingsModal(): JSX.Element {
|
||||||
const [open, setOpen] = useState(true);
|
const [open, setOpen] = useState(true);
|
||||||
const { closePopUp } = useContext(PopUpContext);
|
const { closePopUp } = useContext(PopUpContext);
|
||||||
const { setErrorData, setSuccessData } = useContext(alertContext);
|
const { setErrorData, setSuccessData } = useContext(alertContext);
|
||||||
|
|
@ -28,7 +28,7 @@ export default function FlowSettingsModal() {
|
||||||
const [description, setDescription] = useState(
|
const [description, setDescription] = useState(
|
||||||
flows.find((f) => f.id === tabId).description
|
flows.find((f) => f.id === tabId).description
|
||||||
);
|
);
|
||||||
function setModalOpen(x: boolean) {
|
function setModalOpen(x: boolean): void {
|
||||||
setOpen(x);
|
setOpen(x);
|
||||||
if (x === false) {
|
if (x === false) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
@ -36,7 +36,7 @@ export default function FlowSettingsModal() {
|
||||||
}, 300);
|
}, 300);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function handleClick() {
|
function handleClick(): void {
|
||||||
let savedFlow = flows.find((f) => f.id === tabId);
|
let savedFlow = flows.find((f) => f.id === tabId);
|
||||||
savedFlow.name = name;
|
savedFlow.name = name;
|
||||||
savedFlow.description = description;
|
savedFlow.description = description;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import IconComponent from "../../../components/genericIconComponent";
|
import IconComponent from "../../../components/genericIconComponent";
|
||||||
|
import { chatInputType } from "../../../types/components";
|
||||||
import { classNames } from "../../../utils/utils";
|
import { classNames } from "../../../utils/utils";
|
||||||
|
|
||||||
export default function ChatInput({
|
export default function ChatInput({
|
||||||
|
|
@ -9,7 +10,7 @@ export default function ChatInput({
|
||||||
setChatValue,
|
setChatValue,
|
||||||
inputRef,
|
inputRef,
|
||||||
noInput,
|
noInput,
|
||||||
}) {
|
}: chatInputType): JSX.Element {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!lockChat && inputRef.current) {
|
if (!lockChat && inputRef.current) {
|
||||||
inputRef.current.focus();
|
inputRef.current.focus();
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ interface Props {
|
||||||
value: string;
|
value: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function CodeBlock({ language, value }) {
|
export function CodeBlock({ language, value }: Props): JSX.Element {
|
||||||
const [isCopied, setIsCopied] = useState<Boolean>(false);
|
const [isCopied, setIsCopied] = useState<Boolean>(false);
|
||||||
|
|
||||||
const copyToClipboard = () => {
|
const copyToClipboard = () => {
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ export default function ChatMessage({
|
||||||
chat: ChatMessageType;
|
chat: ChatMessageType;
|
||||||
lockChat: boolean;
|
lockChat: boolean;
|
||||||
lastMessage: boolean;
|
lastMessage: boolean;
|
||||||
}) {
|
}): JSX.Element {
|
||||||
const convert = new Convert({ newline: true });
|
const convert = new Convert({ newline: true });
|
||||||
const [hidden, setHidden] = useState(true);
|
const [hidden, setHidden] = useState(true);
|
||||||
const template = chat.template;
|
const template = chat.template;
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ export default function FormModal({
|
||||||
open: boolean;
|
open: boolean;
|
||||||
setOpen: Function;
|
setOpen: Function;
|
||||||
flow: FlowType;
|
flow: FlowType;
|
||||||
}) {
|
}): JSX.Element {
|
||||||
const { tabsState, setTabsState } = useContext(TabsContext);
|
const { tabsState, setTabsState } = useContext(TabsContext);
|
||||||
const [chatValue, setChatValue] = useState(() => {
|
const [chatValue, setChatValue] = useState(() => {
|
||||||
try {
|
try {
|
||||||
|
|
@ -147,7 +147,7 @@ export default function FormModal({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleOnClose(event: CloseEvent) {
|
function handleOnClose(event: CloseEvent): void {
|
||||||
if (isOpen.current) {
|
if (isOpen.current) {
|
||||||
setErrorData({ title: event.reason });
|
setErrorData({ title: event.reason });
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
@ -157,7 +157,10 @@ export default function FormModal({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getWebSocketUrl(chatId, isDevelopment = false) {
|
function getWebSocketUrl(
|
||||||
|
chatId: string,
|
||||||
|
isDevelopment: boolean = false
|
||||||
|
): string {
|
||||||
const isSecureProtocol = window.location.protocol === "https:";
|
const isSecureProtocol = window.location.protocol === "https:";
|
||||||
const webSocketProtocol = isSecureProtocol ? "wss" : "ws";
|
const webSocketProtocol = isSecureProtocol ? "wss" : "ws";
|
||||||
const host = isDevelopment ? "localhost:7860" : window.location.host;
|
const host = isDevelopment ? "localhost:7860" : window.location.host;
|
||||||
|
|
@ -238,7 +241,7 @@ export default function FormModal({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function connectWS() {
|
function connectWS(): void {
|
||||||
try {
|
try {
|
||||||
const urlWs = getWebSocketUrl(
|
const urlWs = getWebSocketUrl(
|
||||||
id.current,
|
id.current,
|
||||||
|
|
@ -305,7 +308,7 @@ export default function FormModal({
|
||||||
// do not add connectWS on dependencies array
|
// do not add connectWS on dependencies array
|
||||||
}, [lockChat]);
|
}, [lockChat]);
|
||||||
|
|
||||||
async function sendAll(data: sendAllProps) {
|
async function sendAll(data: sendAllProps): Promise<void> {
|
||||||
try {
|
try {
|
||||||
if (ws) {
|
if (ws) {
|
||||||
ws.current.send(JSON.stringify(data));
|
ws.current.send(JSON.stringify(data));
|
||||||
|
|
@ -332,7 +335,7 @@ export default function FormModal({
|
||||||
}
|
}
|
||||||
}, [open]);
|
}, [open]);
|
||||||
|
|
||||||
function sendMessage() {
|
function sendMessage(): void {
|
||||||
let nodeValidationErrors = validateNodes(reactFlowInstance);
|
let nodeValidationErrors = validateNodes(reactFlowInstance);
|
||||||
if (nodeValidationErrors.length === 0) {
|
if (nodeValidationErrors.length === 0) {
|
||||||
setLockChat(true);
|
setLockChat(true);
|
||||||
|
|
@ -365,17 +368,17 @@ export default function FormModal({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function clearChat() {
|
function clearChat(): void {
|
||||||
setChatHistory([]);
|
setChatHistory([]);
|
||||||
ws.current.send(JSON.stringify({ clear_history: true }));
|
ws.current.send(JSON.stringify({ clear_history: true }));
|
||||||
if (lockChat) setLockChat(false);
|
if (lockChat) setLockChat(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setModalOpen(x: boolean) {
|
function setModalOpen(x: boolean): void {
|
||||||
setOpen(x);
|
setOpen(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleOnCheckedChange(checked: boolean, i: string) {
|
function handleOnCheckedChange(checked: boolean, i: string): void {
|
||||||
if (checked === true) {
|
if (checked === true) {
|
||||||
setChatKey(i);
|
setChatKey(i);
|
||||||
setChatValue(tabsState[flow.id].formKeysData.input_keys[i]);
|
setChatValue(tabsState[flow.id].formKeysData.input_keys[i]);
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ export default function GenericModal({
|
||||||
type: number;
|
type: number;
|
||||||
nodeClass?: APIClassType;
|
nodeClass?: APIClassType;
|
||||||
setNodeClass?: (Class: APIClassType) => void;
|
setNodeClass?: (Class: APIClassType) => void;
|
||||||
}) {
|
}): JSX.Element {
|
||||||
const [myButtonText] = useState(buttonText);
|
const [myButtonText] = useState(buttonText);
|
||||||
const [myModalTitle] = useState(modalTitle);
|
const [myModalTitle] = useState(modalTitle);
|
||||||
const [myModalType] = useState(type);
|
const [myModalType] = useState(type);
|
||||||
|
|
@ -56,7 +56,7 @@ export default function GenericModal({
|
||||||
useContext(alertContext);
|
useContext(alertContext);
|
||||||
const { closePopUp, setCloseEdit } = useContext(PopUpContext);
|
const { closePopUp, setCloseEdit } = useContext(PopUpContext);
|
||||||
const ref = useRef();
|
const ref = useRef();
|
||||||
function setModalOpen(x: boolean) {
|
function setModalOpen(x: boolean): void {
|
||||||
if (x === false) {
|
if (x === false) {
|
||||||
setCloseEdit("generic");
|
setCloseEdit("generic");
|
||||||
closePopUp();
|
closePopUp();
|
||||||
|
|
@ -65,7 +65,7 @@ export default function GenericModal({
|
||||||
const divRef = useRef(null);
|
const divRef = useRef(null);
|
||||||
const divRefPrompt = useRef(null);
|
const divRefPrompt = useRef(null);
|
||||||
|
|
||||||
function checkVariables(valueToCheck) {
|
function checkVariables(valueToCheck: string): void {
|
||||||
const regex = /\{([^{}]+)\}/g;
|
const regex = /\{([^{}]+)\}/g;
|
||||||
const matches = [];
|
const matches = [];
|
||||||
let match;
|
let match;
|
||||||
|
|
@ -111,7 +111,7 @@ export default function GenericModal({
|
||||||
.replace(regexHighlight, varHighlightHTML({ name: "$1" }))
|
.replace(regexHighlight, varHighlightHTML({ name: "$1" }))
|
||||||
.replace(/\n/g, "<br />");
|
.replace(/\n/g, "<br />");
|
||||||
|
|
||||||
const TextAreaContentView = () => {
|
const TextAreaContentView = (): JSX.Element => {
|
||||||
return (
|
return (
|
||||||
<SanitizedHTMLWrapper
|
<SanitizedHTMLWrapper
|
||||||
className={getClassByNumberLength()}
|
className={getClassByNumberLength()}
|
||||||
|
|
@ -124,7 +124,7 @@ export default function GenericModal({
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
function getClassByNumberLength() {
|
function getClassByNumberLength(): string {
|
||||||
let sumOfCaracteres: number = 0;
|
let sumOfCaracteres: number = 0;
|
||||||
wordsHighlight.forEach((element) => {
|
wordsHighlight.forEach((element) => {
|
||||||
sumOfCaracteres = sumOfCaracteres + element.replace(/[{}]/g, "").length;
|
sumOfCaracteres = sumOfCaracteres + element.replace(/[{}]/g, "").length;
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ export default function ButtonBox({
|
||||||
textColor: string;
|
textColor: string;
|
||||||
deactivate?: boolean;
|
deactivate?: boolean;
|
||||||
size: "small" | "medium" | "big";
|
size: "small" | "medium" | "big";
|
||||||
}) {
|
}): JSX.Element {
|
||||||
let bigCircle: string;
|
let bigCircle: string;
|
||||||
let smallCircle: string;
|
let smallCircle: string;
|
||||||
let titleFontSize: string;
|
let titleFontSize: string;
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import { FlowType } from "../../types/flow";
|
||||||
import { classNames } from "../../utils/utils";
|
import { classNames } from "../../utils/utils";
|
||||||
import ButtonBox from "./buttonBox";
|
import ButtonBox from "./buttonBox";
|
||||||
|
|
||||||
export default function ImportModal() {
|
export default function ImportModal(): JSX.Element {
|
||||||
const [open, setOpen] = useState(true);
|
const [open, setOpen] = useState(true);
|
||||||
const { setErrorData } = useContext(alertContext);
|
const { setErrorData } = useContext(alertContext);
|
||||||
const { closePopUp } = useContext(PopUpContext);
|
const { closePopUp } = useContext(PopUpContext);
|
||||||
|
|
@ -33,7 +33,7 @@ export default function ImportModal() {
|
||||||
const [loadingExamples, setLoadingExamples] = useState(false);
|
const [loadingExamples, setLoadingExamples] = useState(false);
|
||||||
const [examples, setExamples] = useState<FlowType[]>([]);
|
const [examples, setExamples] = useState<FlowType[]>([]);
|
||||||
const { uploadFlow, addFlow } = useContext(TabsContext);
|
const { uploadFlow, addFlow } = useContext(TabsContext);
|
||||||
function setModalOpen(x: boolean) {
|
function setModalOpen(x: boolean): void {
|
||||||
setOpen(x);
|
setOpen(x);
|
||||||
if (x === false) {
|
if (x === false) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
@ -42,7 +42,7 @@ export default function ImportModal() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleExamples() {
|
function handleExamples(): void {
|
||||||
setLoadingExamples(true);
|
setLoadingExamples(true);
|
||||||
getExamples()
|
getExamples()
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import IconComponent from "../../../../components/genericIconComponent";
|
||||||
import { TabsContext } from "../../../../contexts/tabsContext";
|
import { TabsContext } from "../../../../contexts/tabsContext";
|
||||||
import EditNodeModal from "../../../../modals/EditNodeModal";
|
import EditNodeModal from "../../../../modals/EditNodeModal";
|
||||||
import { classNames } from "../../../../utils/utils";
|
import { classNames } from "../../../../utils/utils";
|
||||||
import { nodeToolbarType } from "../../../../types/components";
|
|
||||||
|
|
||||||
const NodeToolbarComponent = (props): JSX.Element => {
|
const NodeToolbarComponent = (props): JSX.Element => {
|
||||||
const [nodeLength, setNodeLength] = useState(
|
const [nodeLength, setNodeLength] = useState(
|
||||||
|
|
|
||||||
|
|
@ -269,12 +269,12 @@ export type chainsType = {
|
||||||
LLMCheckerChain: dataObjType;
|
LLMCheckerChain: dataObjType;
|
||||||
LLMMathChain: dataObjType;
|
LLMMathChain: dataObjType;
|
||||||
MidJourneyPromptChain: dataObjType;
|
MidJourneyPromptChain: dataObjType;
|
||||||
RetrievalQA: dataObjType
|
RetrievalQA: dataObjType;
|
||||||
RetrievalQAWithSourcesChain: dataObjType;
|
RetrievalQAWithSourcesChain: dataObjType;
|
||||||
SQLDatabaseChain: dataObjType;
|
SQLDatabaseChain: dataObjType;
|
||||||
SeriesCharacterChain: dataObjType;
|
SeriesCharacterChain: dataObjType;
|
||||||
TimeTravelGuideChain: dataObjType;
|
TimeTravelGuideChain: dataObjType;
|
||||||
}
|
};
|
||||||
|
|
||||||
export type embeddingsType = {
|
export type embeddingsType = {
|
||||||
CohereEmbeddings: dataObjType;
|
CohereEmbeddings: dataObjType;
|
||||||
|
|
@ -292,7 +292,7 @@ export type llmsTypes = {
|
||||||
LlamaCpp: dataObjType;
|
LlamaCpp: dataObjType;
|
||||||
OpenAI: dataObjType;
|
OpenAI: dataObjType;
|
||||||
VertexAI: dataObjType;
|
VertexAI: dataObjType;
|
||||||
}
|
};
|
||||||
|
|
||||||
export type memoriesType = {
|
export type memoriesType = {
|
||||||
ConversationBufferMemory: dataObjType;
|
ConversationBufferMemory: dataObjType;
|
||||||
|
|
@ -316,7 +316,7 @@ export type promptsType = {
|
||||||
HumanMessagePromptTemplate: dataObjType;
|
HumanMessagePromptTemplate: dataObjType;
|
||||||
PromptTemplate: dataObjType;
|
PromptTemplate: dataObjType;
|
||||||
SystemMessagePromptTemplate: dataObjType;
|
SystemMessagePromptTemplate: dataObjType;
|
||||||
}
|
};
|
||||||
|
|
||||||
export type retrieversType = {
|
export type retrieversType = {
|
||||||
MultiQueryRetriever: dataObjType;
|
MultiQueryRetriever: dataObjType;
|
||||||
|
|
@ -347,7 +347,7 @@ export type toolsType = {
|
||||||
JsonSpec: dataObjType;
|
JsonSpec: dataObjType;
|
||||||
ListSQLDatabaseTool: dataObjType;
|
ListSQLDatabaseTool: dataObjType;
|
||||||
"News API": dataObjType;
|
"News API": dataObjType;
|
||||||
'PAL-MATH': dataObjType;
|
"PAL-MATH": dataObjType;
|
||||||
"Podcast API": dataObjType;
|
"Podcast API": dataObjType;
|
||||||
PythonAstREPLTool: dataObjType;
|
PythonAstREPLTool: dataObjType;
|
||||||
PythonFunction: dataObjType;
|
PythonFunction: dataObjType;
|
||||||
|
|
@ -360,7 +360,7 @@ export type toolsType = {
|
||||||
RequestsPostTool: dataObjType;
|
RequestsPostTool: dataObjType;
|
||||||
RequestsPutTool: dataObjType;
|
RequestsPutTool: dataObjType;
|
||||||
Search: dataObjType;
|
Search: dataObjType;
|
||||||
'TMDB API': dataObjType;
|
"TMDB API": dataObjType;
|
||||||
Tool: dataObjType;
|
Tool: dataObjType;
|
||||||
WikipediaQueryRun: dataObjType;
|
WikipediaQueryRun: dataObjType;
|
||||||
WolframAlphaQueryRun: dataObjType;
|
WolframAlphaQueryRun: dataObjType;
|
||||||
|
|
@ -403,7 +403,7 @@ export type dataType = {
|
||||||
retrievers?: retrieversType;
|
retrievers?: retrieversType;
|
||||||
textsplitters?: textSplittersType;
|
textsplitters?: textSplittersType;
|
||||||
toolkits?: toolkitsType;
|
toolkits?: toolkitsType;
|
||||||
tools?: toolsType
|
tools?: toolsType;
|
||||||
utilities?: utilitiesType;
|
utilities?: utilitiesType;
|
||||||
vectorstores?: vectorStoresType;
|
vectorstores?: vectorStoresType;
|
||||||
wrappers?: wrappersType;
|
wrappers?: wrappersType;
|
||||||
|
|
@ -414,7 +414,7 @@ export type tweakType = {
|
||||||
"LLMChain-zPC3w": object;
|
"LLMChain-zPC3w": object;
|
||||||
"PromptTemplate-iNj5W": object;
|
"PromptTemplate-iNj5W": object;
|
||||||
"ConversationBufferMemory-JnodM": object;
|
"ConversationBufferMemory-JnodM": object;
|
||||||
}
|
};
|
||||||
|
|
||||||
export type nodeToolbarType = {
|
export type nodeToolbarType = {
|
||||||
data: {
|
data: {
|
||||||
|
|
@ -438,7 +438,7 @@ export type chatTriggerPropType = {
|
||||||
isBuilt: boolean;
|
isBuilt: boolean;
|
||||||
canOpen: boolean;
|
canOpen: boolean;
|
||||||
setOpen: (can: boolean) => void;
|
setOpen: (can: boolean) => void;
|
||||||
}
|
};
|
||||||
|
|
||||||
export type headerFlowsType = {
|
export type headerFlowsType = {
|
||||||
data: object;
|
data: object;
|
||||||
|
|
@ -446,9 +446,20 @@ export type headerFlowsType = {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
style?: FlowStyleType;
|
style?: FlowStyleType;
|
||||||
}
|
};
|
||||||
|
|
||||||
export type menuBarPropsType = {
|
export type menuBarPropsType = {
|
||||||
flows: Array<headerFlowsType>;
|
flows: Array<headerFlowsType>;
|
||||||
tabId: string;
|
tabId: string;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
export type chatInputType = {
|
||||||
|
chatValue: string;
|
||||||
|
inputRef: {
|
||||||
|
current: any;
|
||||||
|
};
|
||||||
|
lockChat: boolean;
|
||||||
|
noInput: boolean;
|
||||||
|
sendMessage: () => void;
|
||||||
|
setChatValue: (value: string) => void;
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
import clsx, { ClassValue } from "clsx";
|
import clsx, { ClassValue } from "clsx";
|
||||||
import { twMerge } from "tailwind-merge";
|
import { twMerge } from "tailwind-merge";
|
||||||
import { ADJECTIVES, DESCRIPTIONS, NOUNS } from "../flow_constants";
|
import { ADJECTIVES, DESCRIPTIONS, NOUNS } from "../flow_constants";
|
||||||
import { IVarHighlightType, dataType, groupedObjType, tweakType } from "../types/components";
|
import {
|
||||||
|
IVarHighlightType,
|
||||||
|
dataType,
|
||||||
|
groupedObjType,
|
||||||
|
tweakType,
|
||||||
|
} from "../types/components";
|
||||||
import { FlowType } from "../types/flow";
|
import { FlowType } from "../types/flow";
|
||||||
import { TabsState } from "../types/tabs";
|
import { TabsState } from "../types/tabs";
|
||||||
import { buildTweaks } from "./reactflowUtils";
|
import { buildTweaks } from "./reactflowUtils";
|
||||||
|
|
@ -85,7 +90,12 @@ export function checkUpperWords(str: string): string {
|
||||||
return words.join(" ");
|
return words.join(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function groupByFamily(data: dataType, baseClasses: string, left: boolean, type: string): groupedObjType[] {
|
export function groupByFamily(
|
||||||
|
data: dataType,
|
||||||
|
baseClasses: string,
|
||||||
|
left: boolean,
|
||||||
|
type: string
|
||||||
|
): groupedObjType[] {
|
||||||
let parentOutput: string;
|
let parentOutput: string;
|
||||||
let arrOfParent: string[] = [];
|
let arrOfParent: string[] = [];
|
||||||
let arrOfType: { family: string; type: string; component: string }[] = [];
|
let arrOfType: { family: string; type: string; component: string }[] = [];
|
||||||
|
|
@ -259,7 +269,7 @@ export function getRandomKeyByssmm(): string {
|
||||||
export function varHighlightHTML({ name }: IVarHighlightType): string {
|
export function varHighlightHTML({ name }: IVarHighlightType): string {
|
||||||
const html = `<span class="font-semibold chat-message-highlight">{${name}}</span>`;
|
const html = `<span class="font-semibold chat-message-highlight">{${name}}</span>`;
|
||||||
return html;
|
return html;
|
||||||
};
|
}
|
||||||
|
|
||||||
export function buildTweakObject(tweak: tweakType[]): string {
|
export function buildTweakObject(tweak: tweakType[]): string {
|
||||||
tweak.forEach((el) => {
|
tweak.forEach((el) => {
|
||||||
|
|
@ -331,7 +341,7 @@ def run_flow(inputs: dict, flow_id: str, tweaks: Optional[dict] = None) -> dict:
|
||||||
# Setup any tweaks you want to apply to the flow
|
# Setup any tweaks you want to apply to the flow
|
||||||
inputs = ${inputs}
|
inputs = ${inputs}
|
||||||
print(run_flow(inputs, flow_id=FLOW_ID, tweaks=TWEAKS))`;
|
print(run_flow(inputs, flow_id=FLOW_ID, tweaks=TWEAKS))`;
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to get the curl code for the API
|
* Function to get the curl code for the API
|
||||||
|
|
@ -357,7 +367,7 @@ export function getCurlCode(
|
||||||
? buildTweakObject(tweak)
|
? buildTweakObject(tweak)
|
||||||
: JSON.stringify(tweaks, null, 2)
|
: JSON.stringify(tweaks, null, 2)
|
||||||
}}'`;
|
}}'`;
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to get the python code for the API
|
* Function to get the python code for the API
|
||||||
|
|
@ -382,4 +392,4 @@ flow = load_flow_from_json("${flowName}.json", tweaks=TWEAKS)
|
||||||
# Now you can use it like any chain
|
# Now you can use it like any chain
|
||||||
inputs = ${inputs}
|
inputs = ${inputs}
|
||||||
flow(inputs)`;
|
flow(inputs)`;
|
||||||
};
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue