diff --git a/client/src/components/Prompts/Groups/VariableForm.tsx b/client/src/components/Prompts/Groups/VariableForm.tsx index d77d164f72b..793e278f8a4 100644 --- a/client/src/components/Prompts/Groups/VariableForm.tsx +++ b/client/src/components/Prompts/Groups/VariableForm.tsx @@ -1,5 +1,11 @@ import { useMemo } from 'react'; import { useForm, useFieldArray, Controller, useWatch } from 'react-hook-form'; +import ReactMarkdown from 'react-markdown'; +import remarkGfm from 'remark-gfm'; +import rehypeKatex from 'rehype-katex'; +import remarkMath from 'remark-math'; +import supersub from 'remark-supersub'; +import rehypeHighlight from 'rehype-highlight'; import type { TPromptGroup } from 'librechat-data-provider'; import { extractVariableInfo, wrapVariable, replaceSpecialVars } from '~/utils'; import { useAuthContext, useLocalize, useSubmitMessage } from '~/hooks'; @@ -50,31 +56,16 @@ export default function VariableForm({ return null; } - const generateHighlightedText = () => { + const generateHighlightedMarkdown = () => { let tempText = mainText; - const parts: JSX.Element[] = []; - allVariables.forEach((variable, index) => { const placeholder = `{{${variable}}}`; - const partsBeforePlaceholder = tempText.split(placeholder); const fieldIndex = variableIndexMap.get(variable) as string | number; const fieldValue = fieldValues[fieldIndex].value as string; - parts.push( - {partsBeforePlaceholder[0]}, - - {fieldValue !== '' ? fieldValue : placeholder} - , - ); - - tempText = partsBeforePlaceholder.slice(1).join(placeholder); + const highlightText = fieldValue !== '' ? fieldValue : placeholder; + tempText = tempText.replaceAll(placeholder, `**${highlightText}**`); }); - - parts.push({tempText}); - - return parts; + return tempText; }; const onSubmit = (data: FormValues) => { @@ -94,7 +85,13 @@ export default function VariableForm({