Fix more type errors
This commit is contained in:
parent
565a62d87c
commit
1c74ad7a65
18 changed files with 38 additions and 33 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
import { cloneDeep } from "lodash";
|
import { cloneDeep } from "lodash";
|
||||||
import React, { useContext, useEffect, useRef, useState } from "react";
|
import React, { ReactNode, useContext, useEffect, useRef, useState } from "react";
|
||||||
import { Handle, Position, useUpdateNodeInternals } from "reactflow";
|
import { Handle, Position, useUpdateNodeInternals } from "reactflow";
|
||||||
import ShadTooltip from "../../../../components/ShadTooltipComponent";
|
import ShadTooltip from "../../../../components/ShadTooltipComponent";
|
||||||
import CodeAreaComponent from "../../../../components/codeAreaComponent";
|
import CodeAreaComponent from "../../../../components/codeAreaComponent";
|
||||||
|
|
@ -40,8 +40,8 @@ export default function ParameterComponent({
|
||||||
info = "",
|
info = "",
|
||||||
}: ParameterComponentType): JSX.Element {
|
}: ParameterComponentType): JSX.Element {
|
||||||
const ref = useRef<HTMLDivElement>(null);
|
const ref = useRef<HTMLDivElement>(null);
|
||||||
const refHtml = useRef<HTMLDivElement>(null);
|
const refHtml = useRef<HTMLDivElement & ReactNode>(null);
|
||||||
const infoHtml = useRef<HTMLDivElement>(null);
|
const infoHtml = useRef<HTMLDivElement & ReactNode>(null);
|
||||||
const updateNodeInternals = useUpdateNodeInternals();
|
const updateNodeInternals = useUpdateNodeInternals();
|
||||||
const [position, setPosition] = useState(0);
|
const [position, setPosition] = useState(0);
|
||||||
const { setTabsState, tabId, save, flows } = useContext(TabsContext);
|
const { setTabsState, tabId, save, flows } = useContext(TabsContext);
|
||||||
|
|
@ -86,6 +86,7 @@ export default function ParameterComponent({
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (name === "openai_api_base") console.log(info);
|
if (name === "openai_api_base") console.log(info);
|
||||||
|
// @ts-ignore
|
||||||
infoHtml.current = (
|
infoHtml.current = (
|
||||||
<div className="h-full w-full break-words">
|
<div className="h-full w-full break-words">
|
||||||
{info.split("\n").map((line, i) => (
|
{info.split("\n").map((line, i) => (
|
||||||
|
|
@ -98,9 +99,10 @@ export default function ParameterComponent({
|
||||||
}, [info]);
|
}, [info]);
|
||||||
|
|
||||||
function renderTooltips() {
|
function renderTooltips() {
|
||||||
let groupedObj = groupByFamily(myData, tooltipTitle, left, flow);
|
let groupedObj = groupByFamily(myData, tooltipTitle!, left, flow!);
|
||||||
|
|
||||||
if (groupedObj && groupedObj.length > 0) {
|
if (groupedObj && groupedObj.length > 0) {
|
||||||
|
//@ts-ignore
|
||||||
refHtml.current = groupedObj.map((item, i) => {
|
refHtml.current = groupedObj.map((item, i) => {
|
||||||
const Icon: any =
|
const Icon: any =
|
||||||
nodeIconsLucide[item.family] ?? nodeIconsLucide["unknown"];
|
nodeIconsLucide[item.family] ?? nodeIconsLucide["unknown"];
|
||||||
|
|
@ -148,6 +150,7 @@ export default function ParameterComponent({
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
//@ts-ignore
|
||||||
refHtml.current = <span>{TOOLTIP_EMPTY}</span>;
|
refHtml.current = <span>{TOOLTIP_EMPTY}</span>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,10 +44,10 @@ export default function Chat({ flow }: ChatType): JSX.Element {
|
||||||
}, [flow]);
|
}, [flow]);
|
||||||
|
|
||||||
const prevNodesRef = useRef<any[] | undefined>();
|
const prevNodesRef = useRef<any[] | undefined>();
|
||||||
const nodes = useNodes();
|
const nodes: NodeType[] = useNodes();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const prevNodes = prevNodesRef.current;
|
const prevNodes = prevNodesRef.current;
|
||||||
const currentNodes = nodes.map((node: NodeType) =>
|
const currentNodes = nodes.map((node: NodeType) =>
|
||||||
_.cloneDeep(node.data.node?.template)
|
_.cloneDeep(node.data.node?.template)
|
||||||
);
|
);
|
||||||
if (
|
if (
|
||||||
|
|
|
||||||
|
|
@ -26,12 +26,12 @@ export const MenuBar = ({ flows, tabId }: menuBarPropsType): JSX.Element => {
|
||||||
|
|
||||||
function handleAddFlow() {
|
function handleAddFlow() {
|
||||||
try {
|
try {
|
||||||
addFlow(null!, true).then((id) => {
|
addFlow(null, true).then((id) => {
|
||||||
navigate("/flow/" + id);
|
navigate("/flow/" + id);
|
||||||
});
|
});
|
||||||
// saveFlowStyleInDataBase();
|
// saveFlowStyleInDataBase();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setErrorData(err);
|
setErrorData(err as { title: string; list?: Array<string> });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let current_flow = flows.find((flow) => flow.id === tabId);
|
let current_flow = flows.find((flow) => flow.id === tabId);
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ export default function RenameLabel(props) {
|
||||||
resizeInput();
|
resizeInput();
|
||||||
}, [isRename]);
|
}, [isRename]);
|
||||||
|
|
||||||
const inputRef = useRef(null);
|
const inputRef = useRef<HTMLInputElement | null>(null);
|
||||||
|
|
||||||
const resizeInput = () => {
|
const resizeInput = () => {
|
||||||
const input = inputRef.current;
|
const input = inputRef.current;
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ export function AlertProvider({ children }: { children: ReactNode }) {
|
||||||
});
|
});
|
||||||
const [successOpen, setSuccessOpen] = useState(false);
|
const [successOpen, setSuccessOpen] = useState(false);
|
||||||
const [notificationCenter, setNotificationCenter] = useState(false);
|
const [notificationCenter, setNotificationCenter] = useState(false);
|
||||||
const [notificationList, setNotificationList] = useState([]);
|
const [notificationList, setNotificationList] = useState<AlertItemType[]>([]);
|
||||||
const pushNotificationList = (notification: AlertItemType) => {
|
const pushNotificationList = (notification: AlertItemType) => {
|
||||||
setNotificationList((old) => {
|
setNotificationList((old) => {
|
||||||
let newNotificationList = _.cloneDeep(old);
|
let newNotificationList = _.cloneDeep(old);
|
||||||
|
|
|
||||||
|
|
@ -382,8 +382,8 @@ export function TabsProvider({ children }: { children: ReactNode }) {
|
||||||
id: newId,
|
id: newId,
|
||||||
type: "genericNode",
|
type: "genericNode",
|
||||||
position: {
|
position: {
|
||||||
x: insidePosition.x + n.position.x - minimumX,
|
x: insidePosition.x + n.position!.x - minimumX,
|
||||||
y: insidePosition.y + n.position.y - minimumY,
|
y: insidePosition.y + n.position!.y - minimumY,
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
..._.cloneDeep(n.data),
|
..._.cloneDeep(n.data),
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { createContext, ReactNode, useEffect, useState } from "react";
|
import { createContext, ReactNode, useEffect, useState } from "react";
|
||||||
import { Node } from "reactflow";
|
import { Node, ReactFlowInstance } from "reactflow";
|
||||||
import { getAll } from "../controllers/API";
|
import { getAll } from "../controllers/API";
|
||||||
import { APIKindType } from "../types/api";
|
import { APIKindType } from "../types/api";
|
||||||
import { typesContextType } from "../types/typesContext";
|
import { typesContextType } from "../types/typesContext";
|
||||||
|
|
@ -22,13 +22,13 @@ export const typesContext = createContext<typesContextType>(initialValue);
|
||||||
|
|
||||||
export function TypesProvider({ children }: { children: ReactNode }) {
|
export function TypesProvider({ children }: { children: ReactNode }) {
|
||||||
const [types, setTypes] = useState({});
|
const [types, setTypes] = useState({});
|
||||||
const [reactFlowInstance, setReactFlowInstance] = useState(null);
|
const [reactFlowInstance, setReactFlowInstance] = useState<ReactFlowInstance | null>(null);
|
||||||
const [templates, setTemplates] = useState({});
|
const [templates, setTemplates] = useState({});
|
||||||
const [data, setData] = useState({});
|
const [data, setData] = useState({});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let delay = 1000; // Start delay of 1 second
|
let delay = 1000; // Start delay of 1 second
|
||||||
let intervalId = null;
|
let intervalId;
|
||||||
let retryCount = 0; // Count of retry attempts
|
let retryCount = 0; // Count of retry attempts
|
||||||
const maxRetryCount = 5; // Max retry attempts
|
const maxRetryCount = 5; // Max retry attempts
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ import {
|
||||||
getWidgetCode,
|
getWidgetCode,
|
||||||
} from "../../utils/utils";
|
} from "../../utils/utils";
|
||||||
import BaseModal from "../baseModal";
|
import BaseModal from "../baseModal";
|
||||||
|
import { tweakType } from "../../types/components";
|
||||||
|
|
||||||
const ApiModal = forwardRef(
|
const ApiModal = forwardRef(
|
||||||
(
|
(
|
||||||
|
|
@ -40,7 +41,7 @@ const ApiModal = forwardRef(
|
||||||
) => {
|
) => {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const [activeTab, setActiveTab] = useState("0");
|
const [activeTab, setActiveTab] = useState("0");
|
||||||
const tweak = useRef([]);
|
const tweak = useRef<tweakType[]>([]);
|
||||||
const tweaksList = useRef([]);
|
const tweaksList = useRef([]);
|
||||||
const { setTweak, getTweak, tabsState } = useContext(TabsContext);
|
const { setTweak, getTweak, tabsState } = useContext(TabsContext);
|
||||||
const pythonApiCode = getPythonApiCode(flow, tweak.current, tabsState);
|
const pythonApiCode = getPythonApiCode(flow, tweak.current, tabsState);
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ export default function FlowSettingsModal({
|
||||||
}: FlowSettingsPropsType): JSX.Element {
|
}: FlowSettingsPropsType): JSX.Element {
|
||||||
const { setErrorData, setSuccessData } = useContext(alertContext);
|
const { setErrorData, setSuccessData } = useContext(alertContext);
|
||||||
const ref = useRef();
|
const ref = useRef();
|
||||||
const { flows, tabId, updateFlow, setTabsState, saveFlow } =
|
const { flows, tabId, updateFlow, saveFlow } =
|
||||||
useContext(TabsContext);
|
useContext(TabsContext);
|
||||||
const maxLength = 50;
|
const maxLength = 50;
|
||||||
const [name, setName] = useState(flows.find((f) => f.id === tabId)!.name);
|
const [name, setName] = useState(flows.find((f) => f.id === tabId)!.name);
|
||||||
|
|
|
||||||
|
|
@ -189,7 +189,7 @@ export default function ChatMessage({
|
||||||
? template?.split("\n")?.map((line, index) => {
|
? template?.split("\n")?.map((line, index) => {
|
||||||
const regex = /{([^}]+)}/g;
|
const regex = /{([^}]+)}/g;
|
||||||
let match;
|
let match;
|
||||||
let parts = [];
|
let parts: Array<JSX.Element | string> = [];
|
||||||
let lastIndex = 0;
|
let lastIndex = 0;
|
||||||
while ((match = regex.exec(line)) !== null) {
|
while ((match = regex.exec(line)) !== null) {
|
||||||
// Push text up to the match
|
// Push text up to the match
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ export default function FormModal({
|
||||||
const ws = useRef<WebSocket | null>(null);
|
const ws = useRef<WebSocket | null>(null);
|
||||||
const [lockChat, setLockChat] = useState(false);
|
const [lockChat, setLockChat] = useState(false);
|
||||||
const isOpen = useRef(open);
|
const isOpen = useRef(open);
|
||||||
const messagesRef = useRef(null);
|
const messagesRef = useRef<HTMLDivElement | null>(null);
|
||||||
const id = useRef(flow.id);
|
const id = useRef(flow.id);
|
||||||
const tabsStateFlowId = tabsState[flow.id];
|
const tabsStateFlowId = tabsState[flow.id];
|
||||||
const tabsStateFlowIdFormKeysData = tabsStateFlowId.formKeysData;
|
const tabsStateFlowIdFormKeysData = tabsStateFlowId.formKeysData;
|
||||||
|
|
@ -326,7 +326,7 @@ export default function FormModal({
|
||||||
if (ref.current) ref.current.scrollIntoView({ behavior: "smooth" });
|
if (ref.current) ref.current.scrollIntoView({ behavior: "smooth" });
|
||||||
}, [chatHistory]);
|
}, [chatHistory]);
|
||||||
|
|
||||||
const ref = useRef(null);
|
const ref = useRef<HTMLDivElement | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (open && ref.current) {
|
if (open && ref.current) {
|
||||||
|
|
@ -348,8 +348,8 @@ export default function FormModal({
|
||||||
tabsState[flow.id].formKeysData.template
|
tabsState[flow.id].formKeysData.template
|
||||||
);
|
);
|
||||||
sendAll({
|
sendAll({
|
||||||
...reactFlowInstance?.toObject(),
|
...reactFlowInstance?.toObject()!,
|
||||||
inputs: inputs,
|
inputs: inputs!,
|
||||||
chatHistory,
|
chatHistory,
|
||||||
name: flow.name,
|
name: flow.name,
|
||||||
description: flow.description,
|
description: flow.description,
|
||||||
|
|
@ -579,7 +579,7 @@ export default function FormModal({
|
||||||
setTabsState((old) => {
|
setTabsState((old) => {
|
||||||
let newTabsState = _.cloneDeep(old);
|
let newTabsState = _.cloneDeep(old);
|
||||||
newTabsState[id.current].formKeysData.input_keys![
|
newTabsState[id.current].formKeysData.input_keys![
|
||||||
chatKey
|
chatKey!
|
||||||
] = value;
|
] = value;
|
||||||
return newTabsState;
|
return newTabsState;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ export default function GenericModal({
|
||||||
const [wordsHighlight, setWordsHighlight] = useState<string[]>([]);
|
const [wordsHighlight, setWordsHighlight] = useState<string[]>([]);
|
||||||
const { setErrorData, setSuccessData, setNoticeData } =
|
const { setErrorData, setSuccessData, setNoticeData } =
|
||||||
useContext(alertContext);
|
useContext(alertContext);
|
||||||
const ref = useRef();
|
const ref = useRef<HTMLDivElement>();
|
||||||
const divRef = useRef(null);
|
const divRef = useRef(null);
|
||||||
const divRefPrompt = useRef(null);
|
const divRefPrompt = useRef(null);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ export default function ExtraSidebar(): JSX.Element {
|
||||||
const flow = flows.find((f) => f.id === tabId);
|
const flow = flows.find((f) => f.id === tabId);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// show components with error on load
|
// show components with error on load
|
||||||
let errors = [];
|
let errors: string[] = [];
|
||||||
Object.keys(templates).forEach((component) => {
|
Object.keys(templates).forEach((component) => {
|
||||||
if (templates[component].error) {
|
if (templates[component].error) {
|
||||||
errors.push(component);
|
errors.push(component);
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ export type sendAllProps = {
|
||||||
name: string;
|
name: string;
|
||||||
description: string;
|
description: string;
|
||||||
viewport: Viewport;
|
viewport: Viewport;
|
||||||
inputs: { text: string };
|
inputs: { text?: string };
|
||||||
|
|
||||||
chatHistory: { message: string | object; isSend: boolean }[];
|
chatHistory: { message: string | object; isSend: boolean }[];
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ export type ShadTooltipProps = {
|
||||||
style?: string;
|
style?: string;
|
||||||
};
|
};
|
||||||
export type ShadToolTipType = {
|
export type ShadToolTipType = {
|
||||||
content?: ReactNode;
|
content?: ReactNode | null;
|
||||||
side?: "top" | "right" | "bottom" | "left";
|
side?: "top" | "right" | "bottom" | "left";
|
||||||
asChild?: boolean;
|
asChild?: boolean;
|
||||||
children?: ReactElement;
|
children?: ReactElement;
|
||||||
|
|
@ -383,7 +383,7 @@ type tabsArrayType = {
|
||||||
language: string;
|
language: string;
|
||||||
mode: string;
|
mode: string;
|
||||||
name: string;
|
name: string;
|
||||||
description: string;
|
description?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type getValueNodeType = {
|
type getValueNodeType = {
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ export type NodeType = {
|
||||||
position: XYPosition | undefined;
|
position: XYPosition | undefined;
|
||||||
data: NodeDataType;
|
data: NodeDataType;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type NodeDataType = {
|
export type NodeDataType = {
|
||||||
type: string;
|
type: string;
|
||||||
node?: APIClassType;
|
node?: APIClassType;
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ export type TabsContextType = {
|
||||||
setTabId: (index: string) => void;
|
setTabId: (index: string) => void;
|
||||||
flows: Array<FlowType>;
|
flows: Array<FlowType>;
|
||||||
removeFlow: (id: string) => void;
|
removeFlow: (id: string) => void;
|
||||||
addFlow: (flowData?: FlowType, newProject?: boolean) => Promise<String>;
|
addFlow: (flowData?: FlowType | undefined | null, newProject?: boolean) => Promise<String>;
|
||||||
updateFlow: (newFlow: FlowType) => void;
|
updateFlow: (newFlow: FlowType) => void;
|
||||||
incrementNodeId: () => string;
|
incrementNodeId: () => string;
|
||||||
downloadFlow: (
|
downloadFlow: (
|
||||||
|
|
@ -24,12 +24,12 @@ export type TabsContextType = {
|
||||||
hardReset: () => void;
|
hardReset: () => void;
|
||||||
getNodeId: (nodeType: string) => string;
|
getNodeId: (nodeType: string) => string;
|
||||||
tabsState: TabsState;
|
tabsState: TabsState;
|
||||||
setTabsState: Dispatch<SetStateAction<TabsState>>;
|
setTabsState: (state: TabsState) => void;
|
||||||
paste: (
|
paste: (
|
||||||
selection: { nodes: any; edges: any },
|
selection: { nodes: any; edges: any },
|
||||||
position: { x: number; y: number; paneX?: number; paneY?: number }
|
position: { x: number; y: number; paneX?: number; paneY?: number }
|
||||||
) => void;
|
) => void;
|
||||||
lastCopiedSelection: { nodes: any; edges: any };
|
lastCopiedSelection: { nodes: any; edges: any } | null;
|
||||||
setLastCopiedSelection: (selection: { nodes: any; edges: any }) => void;
|
setLastCopiedSelection: (selection: { nodes: any; edges: any }) => void;
|
||||||
setTweak: (tweak: TweaksType) => void;
|
setTweak: (tweak: TweaksType) => void;
|
||||||
getTweak: TweaksType[];
|
getTweak: TweaksType[];
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ export function groupByFamily(data, baseClasses: string, left: boolean, flow?: N
|
||||||
let tempInputs: string[] = [],
|
let tempInputs: string[] = [],
|
||||||
tempOutputs: string[] = [];
|
tempOutputs: string[] = [];
|
||||||
|
|
||||||
for (const [n, node] of Object.entries(nodes)) {
|
for (const [n, node] of Object.entries(nodes!)) {
|
||||||
let foundNode = checkedNodes.get(n);
|
let foundNode = checkedNodes.get(n);
|
||||||
if (!foundNode) {
|
if (!foundNode) {
|
||||||
foundNode = {
|
foundNode = {
|
||||||
|
|
@ -147,7 +147,7 @@ export function groupByFamily(data, baseClasses: string, left: boolean, flow?: N
|
||||||
if (foundNode.hasBaseClassInBaseClasses) tempOutputs.push(n);
|
if (foundNode.hasBaseClassInBaseClasses) tempOutputs.push(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
const totalNodes = Object.keys(nodes).length;
|
const totalNodes = Object.keys(nodes!).length;
|
||||||
if (tempInputs.length)
|
if (tempInputs.length)
|
||||||
arrOfPossibleInputs.push({
|
arrOfPossibleInputs.push({
|
||||||
category: d,
|
category: d,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue