From a430284aa21e3ae1f0d5654e55b2ad2852519cc2 Mon Sep 17 00:00:00 2001 From: wwf <yearningwang@iqtogether.com> Date: 星期三, 04 六月 2025 15:17:49 +0800 Subject: [PATCH] 初始化 --- app/components/app/configuration/debug/debug-with-single-model/index.tsx | 35 +++++++++++++++-------------------- 1 files changed, 15 insertions(+), 20 deletions(-) diff --git a/app/components/app/configuration/debug/debug-with-single-model/index.tsx b/app/components/app/configuration/debug/debug-with-single-model/index.tsx index d439b00..2b3c3b8 100644 --- a/app/components/app/configuration/debug/debug-with-single-model/index.tsx +++ b/app/components/app/configuration/debug/debug-with-single-model/index.tsx @@ -1,4 +1,10 @@ -import { memo, useCallback, useImperativeHandle, useMemo } from 'react' +import { + forwardRef, + memo, + useCallback, + useImperativeHandle, + useMemo, +} from 'react' import { useConfigFromDebugContext, useFormattingChangedSubscription, @@ -20,8 +26,6 @@ import { useFeatures } from '@/app/components/base/features/hooks' import { getLastAnswer, isValidGeneratedAnswer } from '@/app/components/base/chat/utils' import type { InputForm } from '@/app/components/base/chat/chat/type' -import { canFindTool } from '@/utils' -import type { FileEntity } from '@/app/components/base/file-uploader/types' type DebugWithSingleModelProps = { checkCanSend?: () => boolean @@ -29,14 +33,9 @@ export type DebugWithSingleModelRefType = { handleRestart: () => void } -const DebugWithSingleModel = ( - { - ref, - checkCanSend, - }: DebugWithSingleModelProps & { - ref: React.RefObject<DebugWithSingleModelRefType>; - }, -) => { +const DebugWithSingleModel = forwardRef<DebugWithSingleModelRefType, DebugWithSingleModelProps>(({ + checkCanSend, +}, ref) => { const { userProfile } = useAppContext() const { modelConfig, @@ -126,20 +125,16 @@ ) }, [appId, chatList, checkCanSend, completionParams, config, handleSend, inputs, modelConfig.mode, modelConfig.model_id, modelConfig.provider, textGenerationModelList]) - const doRegenerate = useCallback((chatItem: ChatItemInTree, editedQuestion?: { message: string, files?: FileEntity[] }) => { - const question = editedQuestion ? chatItem : chatList.find(item => item.id === chatItem.parentMessageId)! + const doRegenerate = useCallback((chatItem: ChatItemInTree) => { + const question = chatList.find(item => item.id === chatItem.parentMessageId)! const parentAnswer = chatList.find(item => item.id === question.parentMessageId) - doSend(editedQuestion ? editedQuestion.message : question.content, - editedQuestion ? editedQuestion.files : question.message_files, - true, - isValidGeneratedAnswer(parentAnswer) ? parentAnswer : null, - ) + doSend(question.content, question.message_files, true, isValidGeneratedAnswer(parentAnswer) ? parentAnswer : null) }, [chatList, doSend]) const allToolIcons = useMemo(() => { const icons: Record<string, any> = {} modelConfig.agentConfig.tools?.forEach((item: any) => { - icons[item.tool_name] = collectionList.find((collection: any) => canFindTool(collection.id, item.provider_id))?.icon + icons[item.tool_name] = collectionList.find((collection: any) => collection.id === item.provider_id)?.icon }) return icons }, [collectionList, modelConfig.agentConfig.tools]) @@ -178,7 +173,7 @@ noSpacing /> ) -} +}) DebugWithSingleModel.displayName = 'DebugWithSingleModel' -- Gitblit v1.8.0