mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-11-13 23:01:11 +08:00
Fix: Enabling the opening message switch for the 'begin' operator will cause previously sent messages to be overwritten. (#19492)
This commit is contained in:
1 parent
2b8861ceb8
commit
23f4bb09fa
2 files changed
+40
-68
No files matched your search
@@ -705,6 +705,12 @@ export const useSelectDerivedMessages = () => {
|
||||
|
||||
const addPrologue = useCallback((prologue: string) => {
|
||||
setDerivedMessages((pre) => {
|
||||
// The prologue is the conversation opener. Once the user has said
|
||||
// something, the first message is real history — never overwrite or
|
||||
// retro-inject the prologue into it.
|
||||
if (pre.some((x) => x.role === MessageType.User)) {
|
||||
return pre;
|
||||
}
|
||||
if (pre.length > 0) {
|
||||
return [
|
||||
{
|
||||
|
||||
@@ -1,16 +1,10 @@
|
||||
import { Collapse } from '@/components/collapse';
|
||||
import { LayoutRecognizeFormField } from '@/components/layout-recognize-form-field';
|
||||
import { RAGFlowFormItem } from '@/components/ragflow-form';
|
||||
import { SwitchFormField } from '@/components/switch-fom-field';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
} from '@/components/ui/form';
|
||||
import { Form, FormField } from '@/components/ui/form';
|
||||
import { RAGFlowSelect } from '@/components/ui/select';
|
||||
import { Switch } from '@/components/ui/switch';
|
||||
import { Textarea } from '@/components/ui/textarea';
|
||||
import { FormTooltip } from '@/components/ui/tooltip';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
@@ -101,70 +95,42 @@ function BeginForm({ node }: INextOperatorForm) {
|
||||
return (
|
||||
<section className="px-5 space-y-5 pb-4">
|
||||
<Form {...form}>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={'mode'}
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel tooltip={t('flow.modeTip')}>
|
||||
{t('flow.mode')}
|
||||
</FormLabel>
|
||||
<FormControl>
|
||||
<RAGFlowSelect
|
||||
placeholder={t('common.pleaseSelect')}
|
||||
options={ModeOptions}
|
||||
{...field}
|
||||
onChange={(val) => {
|
||||
handleModeChange(val);
|
||||
field.onChange(val);
|
||||
}}
|
||||
></RAGFlowSelect>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
<RAGFlowFormItem
|
||||
name="mode"
|
||||
label={t('flow.mode')}
|
||||
tooltip={t('flow.modeTip')}
|
||||
>
|
||||
{(field) => (
|
||||
<RAGFlowSelect
|
||||
placeholder={t('common.pleaseSelect')}
|
||||
options={ModeOptions}
|
||||
{...field}
|
||||
onChange={(val) => {
|
||||
handleModeChange(val);
|
||||
field.onChange(val);
|
||||
}}
|
||||
></RAGFlowSelect>
|
||||
)}
|
||||
/>
|
||||
</RAGFlowFormItem>
|
||||
{mode === AgentDialogueMode.Conversational && (
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={'enablePrologue'}
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel tooltip={t('flow.openingSwitchTip')}>
|
||||
{t('flow.openingSwitch')}
|
||||
</FormLabel>
|
||||
<FormControl>
|
||||
<Switch
|
||||
checked={field.value}
|
||||
onCheckedChange={field.onChange}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
<SwitchFormField
|
||||
name="enablePrologue"
|
||||
label={t('flow.openingSwitch')}
|
||||
tooltip={t('flow.openingSwitchTip')}
|
||||
/>
|
||||
)}
|
||||
{mode === AgentDialogueMode.Conversational && enablePrologue && (
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={'prologue'}
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel tooltip={t('chat.setAnOpenerTip')}>
|
||||
{t('flow.openingCopy')}
|
||||
</FormLabel>
|
||||
<FormControl>
|
||||
<Textarea
|
||||
rows={5}
|
||||
{...field}
|
||||
className="overflow-auto"
|
||||
placeholder={t('common.pleaseInput')}
|
||||
></Textarea>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<RAGFlowFormItem
|
||||
name="prologue"
|
||||
label={t('flow.openingCopy')}
|
||||
tooltip={t('chat.setAnOpenerTip')}
|
||||
>
|
||||
<Textarea
|
||||
rows={5}
|
||||
className="overflow-auto"
|
||||
placeholder={t('common.pleaseInput')}
|
||||
></Textarea>
|
||||
</RAGFlowFormItem>
|
||||
)}
|
||||
{mode === AgentDialogueMode.Webhook && <WebHook></WebHook>}
|
||||
{mode !== AgentDialogueMode.Webhook && (
|
||||
|
||||
Reference in new issue
Block a user