Fix: add model_type into llm_setting (#15141)

### What problem does this PR solve?

Add model_type into llm_setting

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
Lynn
2026-05-22 15:23:07 +08:00
committed by GitHub
parent 71a52d579c
commit 893980ed8f
3 changed files with 24 additions and 4 deletions

View File

@@ -5,6 +5,7 @@ import { Separator } from '@/components/ui/separator';
import { DatasetMetadata } from '@/constants/chat';
import { useSetModalState } from '@/hooks/common-hooks';
import { useFetchChat, useUpdateChat } from '@/hooks/use-chat-request';
import { useFindLlmByUuid } from '@/hooks/use-llm-request';
import { cn } from '@/lib/utils';
import {
removeUselessFieldsFromValues,
@@ -30,6 +31,7 @@ export function ChatSettings({ hasSingleChatBox }: ChatSettingsProps) {
const formSchema = useChatSettingSchema();
const { data } = useFetchChat();
const { updateChat, loading } = useUpdateChat();
const findLlmByUuid = useFindLlmByUuid();
const { id } = useParams();
const { t } = useTranslation();
@@ -87,6 +89,14 @@ export function ChatSettings({ hasSingleChatBox }: ChatSettingsProps) {
referenceMetadata.fields = undefined;
}
// Add model_type to llm_setting based on the selected llm_id
if (nextValues.llm_id) {
nextValues.llm_setting = {
...nextValues.llm_setting,
model_type: findLlmByUuid(nextValues.llm_id)?.model_type || 'chat',
};
}
updateChat({
chatId: id!,
params: {

View File

@@ -25,6 +25,7 @@ import {
useGetChatSearchParams,
usePatchChat,
} from '@/hooks/use-chat-request';
import { useFindLlmByUuid } from '@/hooks/use-llm-request';
import { useFetchUserInfo } from '@/hooks/use-user-setting-request';
import { IClientConversation } from '@/interfaces/database/chat';
import { buildMessageUuidWithRole } from '@/utils/chat';
@@ -132,6 +133,7 @@ const ChatCard = forwardRef(function ChatCard(
const { data: userInfo } = useFetchUserInfo();
const { data: currentDialog } = useFetchChat();
const findLlmByUuid = useFindLlmByUuid();
useSetDefaultModel(form);
@@ -143,12 +145,16 @@ const ChatCard = forwardRef(function ChatCard(
const handleApplyConfig = useCallback(() => {
const values = form.getValues();
const llmId = values.llm_id;
patchChat({
chatId: dialogId!,
params: {
...currentDialog,
llm_id: values.llm_id,
llm_setting: omit(values, 'llm_id'),
llm_id: llmId,
llm_setting: {
...omit(values, 'llm_id'),
model_type: findLlmByUuid(llmId)?.model_type || 'chat',
},
},
});
}, [currentDialog, dialogId, form, patchChat]);

View File

@@ -1,5 +1,6 @@
import { useSetModalState } from '@/hooks/common-hooks';
import { useCreateChat, usePatchChat } from '@/hooks/use-chat-request';
import { useFindLlmByUuid } from '@/hooks/use-llm-request';
import { useFetchTenantInfo } from '@/hooks/use-user-setting-request';
import { IDialog } from '@/interfaces/database/chat';
import { isEmpty } from 'lodash';
@@ -17,6 +18,7 @@ export const useRenameChat = () => {
const { patchChat, loading: patchLoading } = usePatchChat();
const { t } = useTranslation();
const tenantInfo = useFetchTenantInfo();
const findLlmByUuid = useFindLlmByUuid();
const InitialData = useMemo(
() => ({
@@ -39,13 +41,15 @@ export const useRenameChat = () => {
toc_enhance: false,
},
llm_id: tenantInfo.data.llm_id,
llm_setting: {},
llm_setting: {
model_type: findLlmByUuid(tenantInfo.data.llm_id)?.model_type || 'chat',
},
similarity_threshold: 0.2,
vector_similarity_weight: 0.3,
top_n: 8,
top_k: 1024,
}),
[t, tenantInfo.data.llm_id],
[t, tenantInfo.data.llm_id, findLlmByUuid],
);
const onChatRenameOk = useCallback(