mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-03 22:30:31 +08:00
Fix: The multi-model comparison page cannot output messages. (#17507)
This commit is contained in:
@@ -39,6 +39,7 @@ import {
|
||||
useCallback,
|
||||
useEffect,
|
||||
useImperativeHandle,
|
||||
useLayoutEffect,
|
||||
useRef,
|
||||
useState,
|
||||
} from 'react';
|
||||
@@ -60,7 +61,6 @@ import { useUploadFile } from '../../hooks/use-upload-file';
|
||||
import { buildMessageItemReference } from '../../utils';
|
||||
import { useAddChatBox } from '../use-add-box';
|
||||
import { useShowInternet } from '../use-show-internet';
|
||||
import { useSetDefaultModel } from './use-set-default-model';
|
||||
|
||||
type MultipleChatBoxProps = {
|
||||
controller: AbortController;
|
||||
@@ -153,7 +153,9 @@ const ChatCard = forwardRef(function ChatCard(
|
||||
const { data: currentDialog } = useFetchChat();
|
||||
const findLlmByUuid = useFindLlmByUuid();
|
||||
|
||||
useSetDefaultModel(form);
|
||||
useLayoutEffect(() => {
|
||||
form.setValue('llm_id', currentDialog?.llm_id || '');
|
||||
}, [currentDialog?.llm_id, form]);
|
||||
|
||||
const isLatestChat = idx === chatBoxIds.length - 1;
|
||||
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
import { ModelTypeMap } from '@/components/model-tree-select';
|
||||
import { useFetchAllAddedModels } from '@/hooks/use-llm-request';
|
||||
import { getRealModelName } from '@/utils/llm-util';
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { UseFormReturn } from 'react-hook-form';
|
||||
|
||||
export function useSetDefaultModel(form: UseFormReturn<any>) {
|
||||
const { data: allAddedModels } = useFetchAllAddedModels();
|
||||
const hasSet = useRef(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (hasSet.current || !allAddedModels.length) return;
|
||||
const chatModels = allAddedModels.filter((m) =>
|
||||
m.model_type?.some((t) => ModelTypeMap.llm_id.includes(t)),
|
||||
);
|
||||
const first = chatModels[0];
|
||||
if (first) {
|
||||
const modelName = getRealModelName(first.name);
|
||||
form.setValue(
|
||||
'llm_id',
|
||||
`${modelName}@${first.instance_name}@${first.provider_name}`,
|
||||
);
|
||||
hasSet.current = true;
|
||||
}
|
||||
}, [allAddedModels, form]);
|
||||
}
|
||||
Reference in New Issue
Block a user