mirror of
https://github.com/labring/FastGPT.git
synced 2025-10-18 17:51:24 +00:00
feat: flow data type check
This commit is contained in:
@@ -7,6 +7,8 @@
|
|||||||
"App Detail": "App Detail",
|
"App Detail": "App Detail",
|
||||||
"Confirm Del App Tip": "Confirm to delete the app and all its chats",
|
"Confirm Del App Tip": "Confirm to delete the app and all its chats",
|
||||||
"Confirm Save App Tip": "After saving, the advanced orchestration configuration will be overwritten. Make sure that the application does not use advanced orchestration.",
|
"Confirm Save App Tip": "After saving, the advanced orchestration configuration will be overwritten. Make sure that the application does not use advanced orchestration.",
|
||||||
|
"Connection is invalid": "Connecting is invalid",
|
||||||
|
"Connection type is different": "Connection type is different",
|
||||||
"My Apps": "My Apps"
|
"My Apps": "My Apps"
|
||||||
},
|
},
|
||||||
"chat": {
|
"chat": {
|
||||||
|
@@ -7,6 +7,8 @@
|
|||||||
"App Detail": "应用详情",
|
"App Detail": "应用详情",
|
||||||
"Confirm Del App Tip": "确认删除该应用及其所有聊天记录?",
|
"Confirm Del App Tip": "确认删除该应用及其所有聊天记录?",
|
||||||
"Confirm Save App Tip": "保存后将会覆盖高级编排配置,请确保该应用未使用高级编排功能。",
|
"Confirm Save App Tip": "保存后将会覆盖高级编排配置,请确保该应用未使用高级编排功能。",
|
||||||
|
"Connection is invalid": "连接无效",
|
||||||
|
"Connection type is different": "连接的类型不一致",
|
||||||
"My Apps": "我的应用"
|
"My Apps": "我的应用"
|
||||||
},
|
},
|
||||||
"chat": {
|
"chat": {
|
||||||
|
@@ -1,5 +0,0 @@
|
|||||||
import { CSSProperties } from 'react';
|
|
||||||
|
|
||||||
export const nodeDefaultStyle: CSSProperties = {
|
|
||||||
border: '1px solid #DEE0E2'
|
|
||||||
};
|
|
@@ -41,8 +41,8 @@ export enum FlowValueTypeEnum {
|
|||||||
'string' = 'string',
|
'string' = 'string',
|
||||||
'number' = 'number',
|
'number' = 'number',
|
||||||
'boolean' = 'boolean',
|
'boolean' = 'boolean',
|
||||||
'chatHistory' = 'chatHistory',
|
'chatHistory' = 'chat_history',
|
||||||
'kbQuote' = 'kbQuote',
|
'kbQuote' = 'kb_quote',
|
||||||
'other' = 'other'
|
'other' = 'other'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -40,7 +40,7 @@ const defaultSystemEnv = {
|
|||||||
const defaultFeConfigs = {
|
const defaultFeConfigs = {
|
||||||
show_emptyChat: true,
|
show_emptyChat: true,
|
||||||
show_register: true,
|
show_register: true,
|
||||||
show_appStore: true,
|
show_appStore: false,
|
||||||
show_userDetail: true,
|
show_userDetail: true,
|
||||||
show_git: true,
|
show_git: true,
|
||||||
systemTitle: 'FastAI',
|
systemTitle: 'FastAI',
|
||||||
|
@@ -2,6 +2,7 @@ import React, { useMemo } from 'react';
|
|||||||
import { Box, BoxProps } from '@chakra-ui/react';
|
import { Box, BoxProps } from '@chakra-ui/react';
|
||||||
import { Handle, Position } from 'reactflow';
|
import { Handle, Position } from 'reactflow';
|
||||||
import { FlowValueTypeEnum, FlowValueTypeStyle } from '@/constants/flow';
|
import { FlowValueTypeEnum, FlowValueTypeStyle } from '@/constants/flow';
|
||||||
|
import MyTooltip from '@/components/MyTooltip';
|
||||||
|
|
||||||
interface Props extends BoxProps {
|
interface Props extends BoxProps {
|
||||||
handleKey: string;
|
handleKey: string;
|
||||||
@@ -25,6 +26,7 @@ const SourceHandle = ({ handleKey, valueType, ...props }: Props) => {
|
|||||||
transform={'translate(50%,-50%)'}
|
transform={'translate(50%,-50%)'}
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
|
<MyTooltip label={`${valueType}类型`}>
|
||||||
<Handle
|
<Handle
|
||||||
style={{
|
style={{
|
||||||
width: '12px',
|
width: '12px',
|
||||||
@@ -35,6 +37,7 @@ const SourceHandle = ({ handleKey, valueType, ...props }: Props) => {
|
|||||||
id={handleKey}
|
id={handleKey}
|
||||||
position={Position.Right}
|
position={Position.Right}
|
||||||
/>
|
/>
|
||||||
|
</MyTooltip>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@@ -2,6 +2,7 @@ import React, { useMemo } from 'react';
|
|||||||
import { Box, BoxProps } from '@chakra-ui/react';
|
import { Box, BoxProps } from '@chakra-ui/react';
|
||||||
import { Handle, OnConnect, Position } from 'reactflow';
|
import { Handle, OnConnect, Position } from 'reactflow';
|
||||||
import { FlowValueTypeEnum, FlowValueTypeStyle } from '@/constants/flow';
|
import { FlowValueTypeEnum, FlowValueTypeStyle } from '@/constants/flow';
|
||||||
|
import MyTooltip from '@/components/MyTooltip';
|
||||||
|
|
||||||
interface Props extends BoxProps {
|
interface Props extends BoxProps {
|
||||||
handleKey: string;
|
handleKey: string;
|
||||||
@@ -26,6 +27,7 @@ const TargetHandle = ({ handleKey, valueType, onConnect, ...props }: Props) => {
|
|||||||
transform={'translate(50%,-50%)'}
|
transform={'translate(50%,-50%)'}
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
|
<MyTooltip label={`${valueType}类型`}>
|
||||||
<Handle
|
<Handle
|
||||||
style={{
|
style={{
|
||||||
width: '12px',
|
width: '12px',
|
||||||
@@ -37,6 +39,7 @@ const TargetHandle = ({ handleKey, valueType, onConnect, ...props }: Props) => {
|
|||||||
datatype={valueStyle}
|
datatype={valueStyle}
|
||||||
position={Position.Left}
|
position={Position.Left}
|
||||||
/>
|
/>
|
||||||
|
</MyTooltip>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@@ -30,6 +30,8 @@ import { customAlphabet } from 'nanoid';
|
|||||||
import { useRequest } from '@/hooks/useRequest';
|
import { useRequest } from '@/hooks/useRequest';
|
||||||
import type { AppSchema } from '@/types/mongoSchema';
|
import type { AppSchema } from '@/types/mongoSchema';
|
||||||
import { useUserStore } from '@/store/user';
|
import { useUserStore } from '@/store/user';
|
||||||
|
import { useToast } from '@/hooks/useToast';
|
||||||
|
import { useTranslation } from 'next-i18next';
|
||||||
import dynamic from 'next/dynamic';
|
import dynamic from 'next/dynamic';
|
||||||
|
|
||||||
import MyIcon from '@/components/Icon';
|
import MyIcon from '@/components/Icon';
|
||||||
@@ -90,6 +92,8 @@ type Props = { app: AppSchema; fullScreen: boolean; onFullScreen: (val: boolean)
|
|||||||
|
|
||||||
const AppEdit = ({ app, fullScreen, onFullScreen }: Props) => {
|
const AppEdit = ({ app, fullScreen, onFullScreen }: Props) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
const { toast } = useToast();
|
||||||
|
const { t } = useTranslation();
|
||||||
const reactFlowWrapper = useRef<HTMLDivElement>(null);
|
const reactFlowWrapper = useRef<HTMLDivElement>(null);
|
||||||
const ChatTestRef = useRef<ChatTestComponentRef>(null);
|
const ChatTestRef = useRef<ChatTestComponentRef>(null);
|
||||||
const { updateAppDetail } = useUserStore();
|
const { updateAppDetail } = useUserStore();
|
||||||
@@ -227,6 +231,26 @@ const AppEdit = ({ app, fullScreen, onFullScreen }: Props) => {
|
|||||||
);
|
);
|
||||||
const onConnect = useCallback(
|
const onConnect = useCallback(
|
||||||
({ connect }: { connect: Connection }) => {
|
({ connect }: { connect: Connection }) => {
|
||||||
|
const sourceType = nodes
|
||||||
|
.find((node) => node.id === connect.source)
|
||||||
|
?.data?.outputs.find((output) => output.key === connect.sourceHandle)?.valueType;
|
||||||
|
const targetType = nodes
|
||||||
|
.find((node) => node.id === connect.target)
|
||||||
|
?.data?.inputs.find((input) => input.key === connect.targetHandle)?.valueType;
|
||||||
|
|
||||||
|
if (!sourceType || !targetType) {
|
||||||
|
return toast({
|
||||||
|
status: 'warning',
|
||||||
|
title: t('app.Connection is invalid')
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (sourceType !== targetType) {
|
||||||
|
return toast({
|
||||||
|
status: 'warning',
|
||||||
|
title: t('app.Connection type is different')
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
setEdges((state) =>
|
setEdges((state) =>
|
||||||
addEdge(
|
addEdge(
|
||||||
{
|
{
|
||||||
@@ -241,7 +265,7 @@ const AppEdit = ({ app, fullScreen, onFullScreen }: Props) => {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
[onDelConnect, setEdges]
|
[onDelConnect, setEdges, nodes]
|
||||||
);
|
);
|
||||||
|
|
||||||
const { mutate: onclickSave, isLoading } = useRequest({
|
const { mutate: onclickSave, isLoading } = useRequest({
|
||||||
|
@@ -1,8 +1,9 @@
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import Payment from 'wxpay-v3';
|
import Payment from 'wxpay-v3';
|
||||||
|
|
||||||
export const getPayment = () =>
|
export const getPayment = () => {
|
||||||
new Payment({
|
try {
|
||||||
|
return new Payment({
|
||||||
appid: process.env.WX_APPID,
|
appid: process.env.WX_APPID,
|
||||||
mchid: process.env.WX_MCHID,
|
mchid: process.env.WX_MCHID,
|
||||||
private_key: process.env.WX_PRIVATE_KEY?.replace(/\\n/g, '\n'),
|
private_key: process.env.WX_PRIVATE_KEY?.replace(/\\n/g, '\n'),
|
||||||
@@ -10,6 +11,10 @@ export const getPayment = () =>
|
|||||||
apiv3_private_key: process.env.WX_V3_CODE,
|
apiv3_private_key: process.env.WX_V3_CODE,
|
||||||
notify_url: process.env.WX_NOTIFY_URL
|
notify_url: process.env.WX_NOTIFY_URL
|
||||||
});
|
});
|
||||||
|
} catch (error) {
|
||||||
|
return Promise.reject(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export const nativePay = async (amount: number, payId: string) => {
|
export const nativePay = async (amount: number, payId: string) => {
|
||||||
try {
|
try {
|
||||||
|
Reference in New Issue
Block a user