diff --git a/packages/web/components/common/Textarea/PromptEditor/index.tsx b/packages/web/components/common/Textarea/PromptEditor/index.tsx
index cb56c923c..60b4fecb0 100644
--- a/packages/web/components/common/Textarea/PromptEditor/index.tsx
+++ b/packages/web/components/common/Textarea/PromptEditor/index.tsx
@@ -1,6 +1,6 @@
import type { BoxProps } from '@chakra-ui/react';
import { Box, Button, ModalBody, ModalFooter, useDisclosure } from '@chakra-ui/react';
-import React from 'react';
+import React, { useMemo } from 'react';
import { editorStateToText } from './utils';
import Editor from './Editor';
import MyModal from '../../MyModal';
@@ -58,6 +58,12 @@ const PromptEditor = ({
},
[onBlur]
);
+ const formattedValue = useMemo(() => {
+ if (typeof value === 'object') {
+ return JSON.stringify(value);
+ }
+ return value;
+ }, [value]);
return (
<>
@@ -70,7 +76,7 @@ const PromptEditor = ({
minH={minH}
maxH={maxH}
maxLength={maxLength}
- value={value}
+ value={formattedValue}
onChange={onChangeInput}
onBlur={onBlurInput}
placeholder={placeholder}
diff --git a/projects/app/src/components/core/app/formRender/utils.ts b/projects/app/src/components/core/app/formRender/utils.ts
index ab60ce74a..d4fdd6362 100644
--- a/projects/app/src/components/core/app/formRender/utils.ts
+++ b/projects/app/src/components/core/app/formRender/utils.ts
@@ -6,11 +6,15 @@ import { InputTypeEnum } from './constant';
import { FlowNodeInputTypeEnum } from '@fastgpt/global/core/workflow/node/constant';
import type { InputConfigType } from '@fastgpt/global/core/workflow/type/io';
-export const variableInputTypeToInputType = (inputType: VariableInputEnum) => {
+export const variableInputTypeToInputType = (
+ inputType: VariableInputEnum,
+ valueType?: WorkflowIOValueTypeEnum
+) => {
if (inputType === VariableInputEnum.input) return InputTypeEnum.input;
if (inputType === VariableInputEnum.textarea) return InputTypeEnum.textarea;
if (inputType === VariableInputEnum.numberInput) return InputTypeEnum.numberInput;
if (inputType === VariableInputEnum.select) return InputTypeEnum.select;
+ if (inputType === VariableInputEnum.custom) return valueTypeToInputType(valueType);
return InputTypeEnum.JSONEditor;
};
diff --git a/projects/app/src/components/core/chat/ChatContainer/ChatBox/Provider.tsx b/projects/app/src/components/core/chat/ChatContainer/ChatBox/Provider.tsx
index d02d9f230..a89df6388 100644
--- a/projects/app/src/components/core/chat/ChatContainer/ChatBox/Provider.tsx
+++ b/projects/app/src/components/core/chat/ChatContainer/ChatBox/Provider.tsx
@@ -23,13 +23,14 @@ import { getChatResData } from '@/web/core/chat/api';
import { ChatItemContext } from '@/web/core/chat/context/chatItemContext';
import { ChatRecordContext } from '@/web/core/chat/context/chatRecordContext';
import { useCreation } from 'ahooks';
+import type { ChatTypeEnum } from './constants';
export type ChatProviderProps = {
appId: string;
chatId: string;
outLinkAuthData?: OutLinkChatAuthProps;
- chatType: 'log' | 'chat' | 'share' | 'team';
+ chatType: ChatTypeEnum;
};
type useChatStoreType = ChatProviderProps & {
@@ -130,7 +131,7 @@ const Provider = ({
appId,
chatId,
outLinkAuthData,
- chatType = 'chat',
+ chatType,
children,
...props
}: ChatProviderProps & {
diff --git a/projects/app/src/components/core/chat/ChatContainer/ChatBox/components/VariableInputForm.tsx b/projects/app/src/components/core/chat/ChatContainer/ChatBox/components/VariableInputForm.tsx
index 01c816b59..fc539c4d2 100644
--- a/projects/app/src/components/core/chat/ChatContainer/ChatBox/components/VariableInputForm.tsx
+++ b/projects/app/src/components/core/chat/ChatContainer/ChatBox/components/VariableInputForm.tsx
@@ -79,17 +79,19 @@ const VariableInput = ({
{t('chat:variable_invisable_in_share')}
- {externalVariableList.map((item) => (
-
- ))}
+ {externalVariableList.map((item) => {
+ return (
+
+ );
+ })}
{variableList.length === 0 && !chatStarted && (
}
diff --git a/projects/app/src/components/core/chat/ChatContainer/ChatBox/constants.ts b/projects/app/src/components/core/chat/ChatContainer/ChatBox/constants.ts
index 6c8e4349a..3b3ab5f46 100644
--- a/projects/app/src/components/core/chat/ChatContainer/ChatBox/constants.ts
+++ b/projects/app/src/components/core/chat/ChatContainer/ChatBox/constants.ts
@@ -17,3 +17,10 @@ export enum FeedbackTypeEnum {
admin = 'admin',
hidden = 'hidden'
}
+
+export enum ChatTypeEnum {
+ chat = 'chat',
+ log = 'log',
+ share = 'share',
+ team = 'team'
+}
diff --git a/projects/app/src/components/core/chat/ChatContainer/ChatBox/index.tsx b/projects/app/src/components/core/chat/ChatContainer/ChatBox/index.tsx
index 5d030a799..2a881d3ce 100644
--- a/projects/app/src/components/core/chat/ChatContainer/ChatBox/index.tsx
+++ b/projects/app/src/components/core/chat/ChatContainer/ChatBox/index.tsx
@@ -47,7 +47,7 @@ import {
formatChatValue2InputType,
setUserSelectResultToHistories
} from './utils';
-import { textareaMinH } from './constants';
+import { ChatTypeEnum, textareaMinH } from './constants';
import { SseResponseEventEnum } from '@fastgpt/global/core/workflow/runtime/constants';
import ChatProvider, { ChatBoxContext, type ChatProviderProps } from './Provider';
@@ -155,7 +155,7 @@ const ChatBox = ({
const isInteractive = useMemo(() => checkIsInteractiveByHistories(chatRecords), [chatRecords]);
const externalVariableList = useMemo(() => {
- if (chatType === 'chat') {
+ if ([ChatTypeEnum.log, ChatTypeEnum.chat].includes(chatType)) {
return allVariableList.filter((item) => item.type === VariableInputEnum.custom);
}
return [];
@@ -972,7 +972,7 @@ const ChatBox = ({
)}
diff --git a/projects/app/src/pageComponents/app/detail/Logs/DetailLogsModal.tsx b/projects/app/src/pageComponents/app/detail/Logs/DetailLogsModal.tsx
index 16c4bcbc6..4e778c4e8 100644
--- a/projects/app/src/pageComponents/app/detail/Logs/DetailLogsModal.tsx
+++ b/projects/app/src/pageComponents/app/detail/Logs/DetailLogsModal.tsx
@@ -20,6 +20,7 @@ import ChatRecordContextProvider, {
import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
import { useContextSelector } from 'use-context-selector';
import ChatQuoteList from '@/pageComponents/chat/ChatQuoteList';
+import { ChatTypeEnum } from '@/components/core/chat/ChatContainer/ChatBox/constants';
const PluginRunBox = dynamic(() => import('@/components/core/chat/ChatContainer/PluginRunBox'));
const ChatBox = dynamic(() => import('@/components/core/chat/ChatContainer/ChatBox'));
@@ -164,7 +165,7 @@ const DetailLogsModal = ({ appId, chatId, onClose }: Props) => {
feedbackType={'admin'}
showMarkIcon
showVoiceIcon={false}
- chatType="log"
+ chatType={ChatTypeEnum.log}
/>
)}
diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeVariableUpdate.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeVariableUpdate.tsx
index f513831cc..040bbfd44 100644
--- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeVariableUpdate.tsx
+++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeVariableUpdate.tsx
@@ -31,6 +31,7 @@ import { WorkflowNodeEdgeContext } from '../../context/workflowInitContext';
import { useSystemStore } from '@/web/common/system/useSystemStore';
import InputRender from '@/components/core/app/formRender';
import { valueTypeToInputType } from '@/components/core/app/formRender/utils';
+import { isValidReferenceValueFormat } from '@fastgpt/global/core/workflow/utils';
const NodeVariableUpdate = ({ data, selected }: NodeProps) => {
const { inputs = [], nodeId } = data;
@@ -110,19 +111,19 @@ const NodeVariableUpdate = ({ data, selected }: NodeProps) =>
(item) => item.renderType === updateItem.renderType
);
- const onUpdateNewValue = (newValue?: ReferenceValueType | string) => {
- if (typeof newValue === 'string') {
- onUpdateList(
- updateList.map((update, i) =>
- i === index ? { ...update, value: ['', newValue] } : update
- )
- );
- } else if (newValue) {
+ const onUpdateNewValue = (newValue: any) => {
+ if (isValidReferenceValueFormat(newValue)) {
onUpdateList(
updateList.map((update, i) =>
i === index ? { ...update, value: newValue as ReferenceItemValueType } : update
)
);
+ } else {
+ onUpdateList(
+ updateList.map((update, i) =>
+ i === index ? { ...update, value: ['', newValue] } : update
+ )
+ );
}
};
@@ -224,7 +225,7 @@ const NodeVariableUpdate = ({ data, selected }: NodeProps) =>
const inputValue = isArray(updateItem.value?.[1]) ? '' : updateItem.value?.[1];
return (
-
+
import('@/components/core/chat/ChatContainer/PluginRunBox'));
@@ -140,7 +141,7 @@ export const useChatTest = ({
appId={appId}
chatId={chatId}
showMarkIcon
- chatType={'chat'}
+ chatType={ChatTypeEnum.chat}
onStartChat={startChat}
/>
)
diff --git a/projects/app/src/pages/chat/index.tsx b/projects/app/src/pages/chat/index.tsx
index 5df56ae7e..f9a4d7c36 100644
--- a/projects/app/src/pages/chat/index.tsx
+++ b/projects/app/src/pages/chat/index.tsx
@@ -37,6 +37,7 @@ import ChatRecordContextProvider, {
ChatRecordContext
} from '@/web/core/chat/context/chatRecordContext';
import ChatQuoteList from '@/pageComponents/chat/ChatQuoteList';
+import { ChatTypeEnum } from '@/components/core/chat/ChatContainer/ChatBox/constants';
const CustomPluginRunBox = dynamic(() => import('@/pageComponents/chat/CustomPluginRunBox'));
@@ -212,7 +213,7 @@ const Chat = ({ myApps }: { myApps: AppListItemType[] }) => {
showEmptyIntro
feedbackType={'user'}
onStartChat={onStartChat}
- chatType={'chat'}
+ chatType={ChatTypeEnum.chat}
isReady={!loading}
/>
)}
diff --git a/projects/app/src/pages/chat/share.tsx b/projects/app/src/pages/chat/share.tsx
index bf71617a1..70438dc1d 100644
--- a/projects/app/src/pages/chat/share.tsx
+++ b/projects/app/src/pages/chat/share.tsx
@@ -39,6 +39,7 @@ import { useI18nLng } from '@fastgpt/web/hooks/useI18n';
import { type AppSchema } from '@fastgpt/global/core/app/type';
import ChatQuoteList from '@/pageComponents/chat/ChatQuoteList';
import { useToast } from '@fastgpt/web/hooks/useToast';
+import { ChatTypeEnum } from '@/components/core/chat/ChatContainer/ChatBox/constants';
const CustomPluginRunBox = dynamic(() => import('@/pageComponents/chat/CustomPluginRunBox'));
@@ -294,7 +295,7 @@ const OutLink = (props: Props) => {
outLinkAuthData={outLinkAuthData}
feedbackType={'user'}
onStartChat={startChat}
- chatType="share"
+ chatType={ChatTypeEnum.share}
/>
)}
diff --git a/projects/app/src/pages/chat/team.tsx b/projects/app/src/pages/chat/team.tsx
index 9501c0151..e99d892a7 100644
--- a/projects/app/src/pages/chat/team.tsx
+++ b/projects/app/src/pages/chat/team.tsx
@@ -34,6 +34,7 @@ import { useChatStore } from '@/web/core/chat/context/useChatStore';
import { useMount } from 'ahooks';
import { ChatSourceEnum } from '@fastgpt/global/core/chat/constants';
import ChatQuoteList from '@/pageComponents/chat/ChatQuoteList';
+import { ChatTypeEnum } from '@/components/core/chat/ChatContainer/ChatBox/constants';
const CustomPluginRunBox = dynamic(() => import('@/pageComponents/chat/CustomPluginRunBox'));
type Props = { appId: string; chatId: string; teamId: string; teamToken: string };
@@ -228,7 +229,7 @@ const Chat = ({ myApps }: { myApps: AppListItemType[] }) => {
outLinkAuthData={outLinkAuthData}
feedbackType={'user'}
onStartChat={startChat}
- chatType="team"
+ chatType={ChatTypeEnum.team}
/>
)}