mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-02-02 16:45:08 +08:00
### What problem does this PR solve? Feat: The chat feature supports streaming output, displaying results one by one. ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -274,10 +274,23 @@ export const useSendMessageWithSse = (
|
|||||||
const val = JSON.parse(value?.data || '');
|
const val = JSON.parse(value?.data || '');
|
||||||
const d = val?.data;
|
const d = val?.data;
|
||||||
if (typeof d !== 'boolean') {
|
if (typeof d !== 'boolean') {
|
||||||
setAnswer({
|
setAnswer((prev) => {
|
||||||
...d,
|
let newAnswer = (prev.answer || '') + (d.answer || '');
|
||||||
conversationId: body?.conversation_id,
|
|
||||||
chatBoxId: body.chatBoxId,
|
if (d.start_to_think === true) {
|
||||||
|
newAnswer = newAnswer + '<think>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (d.end_to_think === true) {
|
||||||
|
newAnswer = newAnswer + '</think>';
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
...d,
|
||||||
|
answer: newAnswer,
|
||||||
|
conversationId: body?.conversation_id,
|
||||||
|
chatBoxId: body.chatBoxId,
|
||||||
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import {
|
|||||||
setLLMSettingEnabledValues,
|
setLLMSettingEnabledValues,
|
||||||
} from '@/utils/form';
|
} from '@/utils/form';
|
||||||
import { zodResolver } from '@hookform/resolvers/zod';
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
import { omit } from 'lodash';
|
import { isEmpty, omit } from 'lodash';
|
||||||
import { X } from 'lucide-react';
|
import { X } from 'lucide-react';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
@ -33,7 +33,7 @@ export function ChatSettings({ switchSettingVisible }: ChatSettingsProps) {
|
|||||||
|
|
||||||
const form = useForm<FormSchemaType>({
|
const form = useForm<FormSchemaType>({
|
||||||
resolver: zodResolver(formSchema),
|
resolver: zodResolver(formSchema),
|
||||||
shouldUnregister: true,
|
shouldUnregister: false,
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
name: '',
|
name: '',
|
||||||
icon: '',
|
icon: '',
|
||||||
@ -88,7 +88,10 @@ export function ChatSettings({ switchSettingVisible }: ChatSettingsProps) {
|
|||||||
...data,
|
...data,
|
||||||
...llmSettingEnabledValues,
|
...llmSettingEnabledValues,
|
||||||
};
|
};
|
||||||
form.reset(nextData as FormSchemaType);
|
|
||||||
|
if (!isEmpty(data)) {
|
||||||
|
form.reset(nextData as FormSchemaType);
|
||||||
|
}
|
||||||
}, [data, form]);
|
}, [data, form]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -22,6 +22,7 @@ export function DynamicVariableForm() {
|
|||||||
const { fields, remove, append } = useFieldArray({
|
const { fields, remove, append } = useFieldArray({
|
||||||
name,
|
name,
|
||||||
control: form.control,
|
control: form.control,
|
||||||
|
shouldUnregister: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const add = useCallback(() => {
|
const add = useCallback(() => {
|
||||||
|
|||||||
@ -24,12 +24,14 @@ export function useChatSettingSchema() {
|
|||||||
system: z.string().min(1, { message: t('systemMessage') }),
|
system: z.string().min(1, { message: t('systemMessage') }),
|
||||||
refine_multiturn: z.boolean(),
|
refine_multiturn: z.boolean(),
|
||||||
use_kg: z.boolean(),
|
use_kg: z.boolean(),
|
||||||
parameters: z.array(
|
parameters: z
|
||||||
z.object({
|
.array(
|
||||||
key: z.string(),
|
z.object({
|
||||||
optional: z.boolean(),
|
key: z.string(),
|
||||||
}),
|
optional: z.boolean(),
|
||||||
),
|
}),
|
||||||
|
)
|
||||||
|
.optional(),
|
||||||
tavily_api_key: z.string().optional(),
|
tavily_api_key: z.string().optional(),
|
||||||
reasoning: z.boolean().optional(),
|
reasoning: z.boolean().optional(),
|
||||||
cross_languages: z.array(z.string()).optional(),
|
cross_languages: z.array(z.string()).optional(),
|
||||||
|
|||||||
@ -59,7 +59,7 @@ export default defineConfig(({ mode, command }) => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
port: 9222,
|
port: Number(env.PORT) || 9222,
|
||||||
strictPort: false,
|
strictPort: false,
|
||||||
hmr: {
|
hmr: {
|
||||||
overlay: false,
|
overlay: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user