mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-19 01:40:15 +01:00
🗨️ fix: respect line breaks in prompt variables (#3459)
* fix: always display new lines in PromptEditor * fix: allow multiline inputs in prompt template
This commit is contained in:
parent
14eff23b57
commit
d4d56281e3
2 changed files with 11 additions and 4 deletions
|
|
@ -3,7 +3,7 @@ import { useForm, useFieldArray, Controller, useWatch } from 'react-hook-form';
|
||||||
import type { TPromptGroup } from 'librechat-data-provider';
|
import type { TPromptGroup } from 'librechat-data-provider';
|
||||||
import { extractVariableInfo, wrapVariable, replaceSpecialVars } from '~/utils';
|
import { extractVariableInfo, wrapVariable, replaceSpecialVars } from '~/utils';
|
||||||
import { useAuthContext, useLocalize, useSubmitMessage } from '~/hooks';
|
import { useAuthContext, useLocalize, useSubmitMessage } from '~/hooks';
|
||||||
import { Input } from '~/components/ui';
|
import { Textarea } from '~/components/ui';
|
||||||
|
|
||||||
type FormValues = {
|
type FormValues = {
|
||||||
fields: { variable: string; value: string }[];
|
fields: { variable: string; value: string }[];
|
||||||
|
|
@ -103,11 +103,18 @@ export default function VariableForm({
|
||||||
name={`fields.${index}.value`}
|
name={`fields.${index}.value`}
|
||||||
control={control}
|
control={control}
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<Input
|
<Textarea
|
||||||
{...field}
|
{...field}
|
||||||
id={`fields.${index}.value`}
|
id={`fields.${index}.value`}
|
||||||
className="input text-grey-darker rounded border px-3 py-2 focus:bg-white dark:border-gray-500 dark:focus:bg-gray-700"
|
className="input text-grey-darker h-10 rounded border px-3 py-2 focus:bg-white dark:border-gray-500 dark:focus:bg-gray-700"
|
||||||
placeholder={uniqueVariables[index]}
|
placeholder={uniqueVariables[index]}
|
||||||
|
onKeyDown={(e) => {
|
||||||
|
// Submit the form on enter like you would with an Input component
|
||||||
|
if (e.key === 'Enter' && !e.shiftKey) {
|
||||||
|
e.preventDefault();
|
||||||
|
handleSubmit((data) => onSubmit(data))();
|
||||||
|
}
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ const PromptEditor: React.FC<Props> = ({ name, isEditing, setIsEditing }) => {
|
||||||
onBlur={() => setIsEditing(false)}
|
onBlur={() => setIsEditing(false)}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<span className="block break-words px-2 py-1 dark:text-gray-200">{field.value}</span>
|
<pre className="block break-words px-2 py-1 dark:text-gray-200">{field.value}</pre>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue