Fix: The multi-model comparison page cannot output messages. (#17507)

This commit is contained in:
balibabu
2026-07-29 15:16:40 +08:00
committed by GitHub
parent 3c59b707c2
commit 1140db3b8c
3 changed files with 35 additions and 28 deletions

View File

@@ -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;

View File

@@ -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]);
}