mirror of
https://github.com/labring/FastGPT.git
synced 2026-05-06 01:02:54 +08:00
fix: document deploy (#5868)
* mcp memory * Editor space parse error * fix: ts * fix: debug interactive * fix: templateId * fix: editor in debug * doc
This commit is contained in:
@@ -70,6 +70,7 @@ const InputRender = (props: InputRenderProps) => {
|
||||
maxLength={props.maxLength}
|
||||
minH={40}
|
||||
maxH={120}
|
||||
isRichText={props.isRichText}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ const RenderUserFormInteractive = React.memo(function RenderFormInput({
|
||||
const defaultValues = useMemo(() => {
|
||||
if (interactive.type === 'userInput') {
|
||||
return interactive.params.inputForm?.reduce((acc: Record<string, any>, item, index) => {
|
||||
acc[`field_${index}`] = !!item.value ? item.value : item.defaultValue;
|
||||
acc[item.key] = !!item.value ? item.value : item.defaultValue;
|
||||
return acc;
|
||||
}, {});
|
||||
}
|
||||
@@ -229,9 +229,8 @@ const RenderUserFormInteractive = React.memo(function RenderFormInput({
|
||||
(data: Record<string, any>) => {
|
||||
const finalData: Record<string, any> = {};
|
||||
interactive.params.inputForm?.forEach((item, index) => {
|
||||
const fieldName = `field_${index}`;
|
||||
if (fieldName in data) {
|
||||
finalData[item.label] = data[fieldName];
|
||||
if (item.key in data) {
|
||||
finalData[item.key] = data[item.key];
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+37
-47
@@ -1,10 +1,9 @@
|
||||
import React, { useCallback } from 'react';
|
||||
import React from 'react';
|
||||
import { Box, Flex } from '@chakra-ui/react';
|
||||
import { Controller, useForm, type UseFormHandleSubmit } from 'react-hook-form';
|
||||
import Markdown from '@/components/Markdown';
|
||||
import QuestionTip from '@fastgpt/web/components/common/MyTooltip/QuestionTip';
|
||||
import {
|
||||
type UserInputFormItemType,
|
||||
type UserInputInteractive,
|
||||
type UserSelectInteractive,
|
||||
type UserSelectOptionItemType
|
||||
@@ -64,7 +63,7 @@ export const SelectOptionsComponent = React.memo(function SelectOptionsComponent
|
||||
});
|
||||
|
||||
export const FormInputComponent = React.memo(function FormInputComponent({
|
||||
interactiveParams,
|
||||
interactiveParams: { description, inputForm, submitted },
|
||||
defaultValues = {},
|
||||
SubmitButton
|
||||
}: {
|
||||
@@ -72,58 +71,49 @@ export const FormInputComponent = React.memo(function FormInputComponent({
|
||||
defaultValues?: Record<string, any>;
|
||||
SubmitButton: (e: { onSubmit: UseFormHandleSubmit<Record<string, any>> }) => React.JSX.Element;
|
||||
}) {
|
||||
const { description, inputForm, submitted } = interactiveParams;
|
||||
|
||||
const { handleSubmit, control } = useForm({
|
||||
defaultValues
|
||||
});
|
||||
|
||||
const RenderFormInput = useCallback(
|
||||
({ input, index }: { input: UserInputFormItemType; index: number }) => {
|
||||
return (
|
||||
<Controller
|
||||
key={input.label}
|
||||
control={control}
|
||||
name={`field_${index}`}
|
||||
rules={{ required: input.required }}
|
||||
render={({ field: { onChange, value }, fieldState: { error } }) => {
|
||||
const inputType = nodeInputTypeToInputType([input.type]);
|
||||
|
||||
return (
|
||||
<InputRender
|
||||
inputType={inputType}
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
isDisabled={submitted}
|
||||
isInvalid={!!error}
|
||||
maxLength={input.maxLength}
|
||||
min={input.min}
|
||||
max={input.max}
|
||||
list={input.list}
|
||||
isRichText={false}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
},
|
||||
[control, submitted]
|
||||
);
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<DescriptionBox description={description} />
|
||||
<Flex flexDirection={'column'} gap={3}>
|
||||
{inputForm.map((input, index) => (
|
||||
<Box key={input.label}>
|
||||
<Flex alignItems={'center'} mb={1}>
|
||||
{input.required && <Box color={'red.500'}>*</Box>}
|
||||
<FormLabel>{input.label}</FormLabel>
|
||||
{input.description && <QuestionTip ml={1} label={input.description} />}
|
||||
</Flex>
|
||||
<RenderFormInput input={input} index={index} />
|
||||
</Box>
|
||||
))}
|
||||
{inputForm.map((input) => {
|
||||
const inputType = nodeInputTypeToInputType([input.type]);
|
||||
|
||||
return (
|
||||
<Box key={input.key}>
|
||||
<Flex alignItems={'center'} mb={1}>
|
||||
{input.required && <Box color={'red.500'}>*</Box>}
|
||||
<FormLabel>{input.label}</FormLabel>
|
||||
{input.description && <QuestionTip ml={1} label={input.description} />}
|
||||
</Flex>
|
||||
<Controller
|
||||
key={input.key} // 添加 key
|
||||
control={control}
|
||||
name={input.key}
|
||||
rules={{ required: input.required }}
|
||||
render={({ field: { onChange, value }, fieldState: { error } }) => {
|
||||
return (
|
||||
<InputRender
|
||||
inputType={inputType}
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
isDisabled={submitted}
|
||||
isInvalid={!!error}
|
||||
maxLength={input.maxLength}
|
||||
min={input.min}
|
||||
max={input.max}
|
||||
list={input.list}
|
||||
isRichText={false}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
})}
|
||||
</Flex>
|
||||
|
||||
{!submitted && (
|
||||
|
||||
+5
-10
@@ -11,14 +11,9 @@ import {
|
||||
SelectOptionsComponent
|
||||
} from '@/components/core/chat/components/Interactive/InteractiveComponents';
|
||||
import { type UserInputInteractive } from '@fastgpt/global/core/workflow/template/system/interactive/type';
|
||||
import {
|
||||
getLastInteractiveValue,
|
||||
storeEdges2RuntimeEdges
|
||||
} from '@fastgpt/global/core/workflow/runtime/utils';
|
||||
import { type ChatItemType, type UserChatItemValueItemType } from '@fastgpt/global/core/chat/type';
|
||||
import { ChatItemValueTypeEnum, ChatRoleEnum } from '@fastgpt/global/core/chat/constants';
|
||||
import PopoverConfirm from '@fastgpt/web/components/common/MyPopover/PopoverConfirm';
|
||||
import MyIconButton from '@fastgpt/web/components/common/Icon/button';
|
||||
import { WorkflowActionsContext } from '../../../../context/workflowActionsContext';
|
||||
import { WorkflowDebugContext } from '../../../../context/workflowDebugContext';
|
||||
|
||||
@@ -27,7 +22,7 @@ type NodeDebugResponseProps = {
|
||||
debugResult: FlowNodeItemType['debugResult'];
|
||||
};
|
||||
|
||||
const RenderUserFormInteractive = React.memo(function RenderFormInput({
|
||||
const RenderUserFormInteractive = function RenderFormInput({
|
||||
interactive,
|
||||
onNext
|
||||
}: {
|
||||
@@ -38,13 +33,13 @@ const RenderUserFormInteractive = React.memo(function RenderFormInput({
|
||||
|
||||
const defaultValues = useMemo(() => {
|
||||
return interactive.params.inputForm?.reduce((acc: Record<string, any>, item) => {
|
||||
acc[item.label] = !!item.value ? item.value : item.defaultValue;
|
||||
acc[item.key] = item.value !== undefined ? item.value : item.defaultValue;
|
||||
return acc;
|
||||
}, {});
|
||||
}, [interactive.params.inputForm]);
|
||||
|
||||
return (
|
||||
<Box px={4} py={4} bg="white" borderRadius="md">
|
||||
<Box className="nodrag" px={4} py={4} bg="white" borderRadius="md">
|
||||
<FormInputComponent
|
||||
defaultValues={defaultValues}
|
||||
interactiveParams={interactive.params}
|
||||
@@ -63,7 +58,7 @@ const RenderUserFormInteractive = React.memo(function RenderFormInput({
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
const NodeDebugResponse = ({ nodeId, debugResult }: NodeDebugResponseProps) => {
|
||||
const { t } = useTranslation();
|
||||
@@ -120,8 +115,8 @@ const NodeDebugResponse = ({ nodeId, debugResult }: NodeDebugResponseProps) => {
|
||||
type: ChatItemValueTypeEnum.interactive,
|
||||
interactive: {
|
||||
...interactive,
|
||||
entryNodeIds: workflowDebugData.entryNodeIds || [],
|
||||
memoryEdges: interactive.memoryEdges || [],
|
||||
entryNodeIds: interactive.entryNodeIds || [],
|
||||
nodeOutputs: interactive.nodeOutputs || []
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,8 @@ async function handler(req: ApiRequestProps<CreateAppBody>) {
|
||||
teamId,
|
||||
tmbId,
|
||||
userAvatar: tmb?.avatar,
|
||||
username: tmb?.user?.username
|
||||
username: tmb?.user?.username,
|
||||
templateId
|
||||
});
|
||||
|
||||
pushTrack.createApp({
|
||||
|
||||
@@ -27,7 +27,7 @@ async function handler(
|
||||
})
|
||||
});
|
||||
|
||||
return mcpClient.toolCall(toolName, params);
|
||||
return mcpClient.toolCall({ toolName, params });
|
||||
}
|
||||
|
||||
export default NextAPI(handler);
|
||||
|
||||
Reference in New Issue
Block a user