diff --git a/packages/global/core/workflow/utils.ts b/packages/global/core/workflow/utils.ts index dfbcab8de..460b73d1f 100644 --- a/packages/global/core/workflow/utils.ts +++ b/packages/global/core/workflow/utils.ts @@ -240,7 +240,7 @@ export function replaceVariableLabel({ variables: Record; runningNode: RuntimeNodeItemType; }) { - if (!(typeof text === 'string')) return text; + if (typeof text !== 'string') return text; const globalVariables = Object.keys(variables).map((key) => { return { diff --git a/packages/service/core/workflow/dispatch/tools/http468.ts b/packages/service/core/workflow/dispatch/tools/http468.ts index 036f51eda..4cbc6b373 100644 --- a/packages/service/core/workflow/dispatch/tools/http468.ts +++ b/packages/service/core/workflow/dispatch/tools/http468.ts @@ -292,14 +292,14 @@ async function fetchData({ function replaceVariable(text: string, obj: Record) { for (const [key, value] of Object.entries(obj)) { if (value === undefined) { - text = text.replace(new RegExp(`{{${key}}}`, 'g'), UNDEFINED_SIGN); + text = text.replace(new RegExp(`{{(${key})}}`, 'g'), UNDEFINED_SIGN); } else { const replacement = JSON.stringify(value); const unquotedReplacement = replacement.startsWith('"') && replacement.endsWith('"') ? replacement.slice(1, -1) : replacement; - text = text.replace(new RegExp(`{{${key}}}`, 'g'), unquotedReplacement); + text = text.replace(new RegExp(`{{(${key})}}`, 'g'), unquotedReplacement); } } return text || ''; diff --git a/packages/web/components/common/Textarea/PromptEditor/Editor.tsx b/packages/web/components/common/Textarea/PromptEditor/Editor.tsx index e90d14ae5..758a85558 100644 --- a/packages/web/components/common/Textarea/PromptEditor/Editor.tsx +++ b/packages/web/components/common/Textarea/PromptEditor/Editor.tsx @@ -129,7 +129,7 @@ export default function Editor({ }); }} /> - + diff --git a/packages/web/components/common/Textarea/PromptEditor/plugins/VariableLabelPickerPlugin/index.tsx b/packages/web/components/common/Textarea/PromptEditor/plugins/VariableLabelPickerPlugin/index.tsx index 0e704e4fa..5d241e2dc 100644 --- a/packages/web/components/common/Textarea/PromptEditor/plugins/VariableLabelPickerPlugin/index.tsx +++ b/packages/web/components/common/Textarea/PromptEditor/plugins/VariableLabelPickerPlugin/index.tsx @@ -27,13 +27,18 @@ interface TransformedParent { } export default function VariableLabelPickerPlugin({ - variables + variables, + isFocus }: { variables: EditorVariablePickerType[]; + isFocus: boolean; }) { const { t } = useTranslation(); const [editor] = useLexicalComposerContext(); const [queryString, setQueryString] = useState(null); + const [currentIndex, setCurrentIndex] = useState(0); + const [highlightIndex, setHighlightIndex] = useState(null); + const highlightedItemRef = React.useRef(null); const checkForTriggerMatch = useBasicTypeaheadTriggerMatch('/', { minLength: 0 @@ -58,6 +63,15 @@ export default function VariableLabelPickerPlugin({ [editor] ); + React.useEffect(() => { + if (highlightedItemRef.current) { + highlightedItemRef.current.scrollIntoView({ + behavior: 'auto', + block: 'end' + }); + } + }, [currentIndex]); + return ( - {item.children?.map((child, index) => ( + {item.children?.map((child) => ( { - setHighlightedIndex(child.index); + onMouseDown={() => { selectOptionAndCleanUp({ ...child, parent: item }); }} onMouseEnter={() => { - setHighlightedIndex(child.index); + setHighlightIndex(child.index); }} > diff --git a/packages/web/components/common/Textarea/PromptEditor/plugins/VariableLabelPlugin/utils.ts b/packages/web/components/common/Textarea/PromptEditor/plugins/VariableLabelPlugin/utils.ts index cc74e6298..c942d31f5 100644 --- a/packages/web/components/common/Textarea/PromptEditor/plugins/VariableLabelPlugin/utils.ts +++ b/packages/web/components/common/Textarea/PromptEditor/plugins/VariableLabelPlugin/utils.ts @@ -221,7 +221,7 @@ export function getHashtagRegexString(): string { const hashtag = `(${hashLeftCharList})` + `(${hashLeftCharList})` + - `(${hashMiddleCharList})([a-zA-Z0-9_\\.]{0,29})(${hashMiddleCharList})` + + `(${hashMiddleCharList})([a-zA-Z0-9_\\.]{0,100})(${hashMiddleCharList})` + `(${hashRightCharList})(${hashRightCharList})`; return hashtag; 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 a15f526a7..2c5ee40d0 100644 --- a/projects/app/src/components/core/chat/ChatContainer/ChatBox/Provider.tsx +++ b/projects/app/src/components/core/chat/ChatContainer/ChatBox/Provider.tsx @@ -35,6 +35,7 @@ type useChatStoreType = OutLinkChatAuthProps & ChatProviderProps & { welcomeText: string; variableList: VariableItemType[]; + allVariableList: VariableItemType[]; questionGuide: boolean; ttsConfig: AppTTSConfigType; whisperConfig: AppWhisperConfigType; @@ -189,6 +190,7 @@ const Provider = ({ teamToken, welcomeText, variableList: variables.filter((item) => item.type !== VariableInputEnum.custom), + allVariableList: variables, questionGuide, ttsConfig, whisperConfig, diff --git a/projects/app/src/components/core/chat/ChatContainer/ChatBox/components/VariableInput.tsx b/projects/app/src/components/core/chat/ChatContainer/ChatBox/components/VariableInput.tsx index df9c6d4f1..641603a54 100644 --- a/projects/app/src/components/core/chat/ChatContainer/ChatBox/components/VariableInput.tsx +++ b/projects/app/src/components/core/chat/ChatContainer/ChatBox/components/VariableInput.tsx @@ -21,7 +21,7 @@ const VariableInput = ({ const { t } = useTranslation(); const { appAvatar, variableList, variablesForm } = useContextSelector(ChatBoxContext, (v) => v); - const { register, getValues, setValue, handleSubmit: handleSubmitChat, control } = variablesForm; + const { register, setValue, handleSubmit: handleSubmitChat, control } = variablesForm; return ( 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 1edaa850f..bb8866ce4 100644 --- a/projects/app/src/components/core/chat/ChatContainer/ChatBox/index.tsx +++ b/projects/app/src/components/core/chat/ChatContainer/ChatBox/index.tsx @@ -140,6 +140,7 @@ const ChatBox = ( const { welcomeText, variableList, + allVariableList, questionGuide, startSegmentedAudio, finishSegmentedAudio, @@ -390,7 +391,7 @@ const ChatBox = ( // delete invalid variables, 只保留在 variableList 中的变量 const requestVariables: Record = {}; - variableList?.forEach((item) => { + allVariableList?.forEach((item) => { requestVariables[item.key] = variables[item.key] || ''; }); diff --git a/projects/app/src/pages/app/detail/components/useChatTest.tsx b/projects/app/src/pages/app/detail/components/useChatTest.tsx index 67a4b9ce1..0845fff78 100644 --- a/projects/app/src/pages/app/detail/components/useChatTest.tsx +++ b/projects/app/src/pages/app/detail/components/useChatTest.tsx @@ -10,7 +10,6 @@ import { storeNodes2RuntimeNodes } from '@fastgpt/global/core/workflow/runtime/utils'; import { useMemoizedFn } from 'ahooks'; -import { AppChatConfigType } from '@fastgpt/global/core/app/type'; import { useContextSelector } from 'use-context-selector'; import { AppContext } from './context'; import { StoreNodeItemType } from '@fastgpt/global/core/workflow/type/node'; @@ -21,6 +20,7 @@ import dynamic from 'next/dynamic'; import { useChat } from '@/components/core/chat/ChatContainer/useChat'; import { Box } from '@chakra-ui/react'; import ChatBox from '@/components/core/chat/ChatContainer/ChatBox'; +import { AppChatConfigType } from '@fastgpt/global/core/app/type'; const PluginRunBox = dynamic(() => import('@/components/core/chat/ChatContainer/PluginRunBox')); diff --git a/projects/app/src/pages/app/list/index.tsx b/projects/app/src/pages/app/list/index.tsx index 2ac1b2f0a..20b9073fa 100644 --- a/projects/app/src/pages/app/list/index.tsx +++ b/projects/app/src/pages/app/list/index.tsx @@ -132,8 +132,9 @@ const MyApps = () => { )} - { - + {/* Folder slider */} {!!folderDetail && isPc && (