mirror of
https://github.com/labring/FastGPT.git
synced 2026-04-17 02:06:41 +08:00
fix: deal with undefined valueType (#6684)
* fix: deal with undefined valueType * fix * fix * fix key
This commit is contained in:
@@ -232,6 +232,16 @@ export const FlowValueTypeMap: Record<
|
||||
}
|
||||
};
|
||||
|
||||
export const getFlowValueTypeMeta = (
|
||||
valueType?: WorkflowIOValueTypeEnum | string | null
|
||||
): (typeof FlowValueTypeMap)[WorkflowIOValueTypeEnum] => {
|
||||
if (valueType == null || valueType === '') {
|
||||
return FlowValueTypeMap[WorkflowIOValueTypeEnum.any];
|
||||
}
|
||||
const meta = FlowValueTypeMap[valueType as WorkflowIOValueTypeEnum];
|
||||
return meta ?? FlowValueTypeMap[WorkflowIOValueTypeEnum.any];
|
||||
};
|
||||
|
||||
export const EDGE_TYPE = 'default';
|
||||
|
||||
export const chatHistoryValueDesc = `{
|
||||
|
||||
@@ -14,7 +14,7 @@ import MyIconButton from '@fastgpt/web/components/common/Icon/button';
|
||||
import { useToast } from '@fastgpt/web/hooks/useToast';
|
||||
import {
|
||||
FlowNodeInputTypeEnum,
|
||||
FlowValueTypeMap
|
||||
getFlowValueTypeMeta
|
||||
} from '@fastgpt/global/core/workflow/node/constant';
|
||||
import { WorkflowIOValueTypeEnum } from '@fastgpt/global/core/workflow/constants';
|
||||
import { useMemoEnhance } from '@fastgpt/web/hooks/useMemoEnhance';
|
||||
@@ -255,7 +255,7 @@ const Reference = ({
|
||||
fontSize={'sm'}
|
||||
fontWeight={'medium'}
|
||||
>
|
||||
{t(FlowValueTypeMap[inputChildren.valueType || WorkflowIOValueTypeEnum.any].label)}
|
||||
{t(getFlowValueTypeMeta(inputChildren.valueType).label)}
|
||||
</Flex>
|
||||
</Flex>
|
||||
{!isEmptyItem && (
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { FlowNodeOutputItemType } from '@fastgpt/global/core/workflow/type/
|
||||
import { Box, Flex, Input, HStack } from '@chakra-ui/react';
|
||||
import {
|
||||
FlowNodeOutputTypeEnum,
|
||||
FlowValueTypeMap
|
||||
getFlowValueTypeMeta
|
||||
} from '@fastgpt/global/core/workflow/node/constant';
|
||||
import { WorkflowIOValueTypeEnum } from '@fastgpt/global/core/workflow/constants';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
@@ -90,7 +90,7 @@ const DynamicOutputs = ({ nodeId, outputs, addOutput }: DynamicOutputsProps) =>
|
||||
{outputs.length > 0 && <Box w={6} />}
|
||||
</Flex>
|
||||
{[...outputs, defaultOutput].map((output, index) => (
|
||||
<Box key={output.key} _notLast={{ mb: 1.5 }}>
|
||||
<Box key={output.key || index} _notLast={{ mb: 1.5 }}>
|
||||
<DynamicOutputItem
|
||||
output={output}
|
||||
outputs={outputs}
|
||||
@@ -135,7 +135,7 @@ const DynamicOutputItem = ({
|
||||
type !== WorkflowIOValueTypeEnum.selectApp && type !== WorkflowIOValueTypeEnum.dynamic
|
||||
)
|
||||
.map((item) => ({
|
||||
label: t(FlowValueTypeMap[item].label),
|
||||
label: t(getFlowValueTypeMeta(item).label),
|
||||
value: item
|
||||
}));
|
||||
}, [t]);
|
||||
@@ -178,6 +178,8 @@ const DynamicOutputItem = ({
|
||||
[output, onUpdate, onAdd, isEmptyItem, outputs]
|
||||
);
|
||||
|
||||
const selectValueType = getFlowValueTypeMeta(output?.valueType).value;
|
||||
|
||||
return (
|
||||
<Flex alignItems={'center'} mb={1} gap={2}>
|
||||
<Flex flex={'1'} bg={'white'} rounded={'md'}>
|
||||
@@ -198,7 +200,7 @@ const DynamicOutputItem = ({
|
||||
h={10}
|
||||
borderLeftRadius={'none'}
|
||||
borderColor={'myGray.200'}
|
||||
value={output?.valueType}
|
||||
value={selectValueType}
|
||||
list={valueTypeList}
|
||||
onChange={onChangeValueType}
|
||||
isDisabled={isEmptyItem}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { FlowValueTypeMap } from '@fastgpt/global/core/workflow/node/constant';
|
||||
import { getFlowValueTypeMeta } from '@fastgpt/global/core/workflow/node/constant';
|
||||
import type { BoxProps } from '@chakra-ui/react';
|
||||
import { Box } from '@chakra-ui/react';
|
||||
import type { WorkflowIOValueTypeEnum } from '@fastgpt/global/core/workflow/constants';
|
||||
@@ -14,9 +14,8 @@ const ValueTypeLabel = ({
|
||||
valueType?: WorkflowIOValueTypeEnum;
|
||||
valueDesc?: string;
|
||||
} & BoxProps) => {
|
||||
const valueTypeData = valueType ? FlowValueTypeMap[valueType] : undefined;
|
||||
const { t } = useTranslation();
|
||||
const label = valueTypeData?.label || '';
|
||||
const label = valueType ? getFlowValueTypeMeta(valueType).label : '';
|
||||
|
||||
return !!label ? (
|
||||
<MyTooltip label={valueDesc}>
|
||||
|
||||
Reference in New Issue
Block a user