From 70698b553e0ddfcb63a4c4db2c973a30a0897130 Mon Sep 17 00:00:00 2001 From: JzoNg Date: Wed, 20 Mar 2024 11:08:15 +0800 Subject: [PATCH] fix prompt log in completion debug --- .../app/configuration/debug/index.tsx | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/web/app/components/app/configuration/debug/index.tsx b/web/app/components/app/configuration/debug/index.tsx index d4f3a78076..3005618818 100644 --- a/web/app/components/app/configuration/debug/index.tsx +++ b/web/app/components/app/configuration/debug/index.tsx @@ -2,7 +2,7 @@ import type { FC } from 'react' import useSWR from 'swr' import { useTranslation } from 'react-i18next' -import React, { useCallback, useEffect, useState } from 'react' +import React, { useCallback, useEffect, useRef, useState } from 'react' import { setAutoFreeze } from 'immer' import { useBoolean } from 'ahooks' import { useContext } from 'use-context-selector' @@ -36,6 +36,8 @@ import type { ModelParameterModalProps } from '@/app/components/header/account-s import { Plus } from '@/app/components/base/icons/src/vender/line/general' import { useEventEmitterContextContext } from '@/context/event-emitter' import { useProviderContext } from '@/context/provider-context' +import PromptLogModal from '@/app/components/base/prompt-log-modal' +import { useStore as useAppStore } from '@/app/components/app/store' type IDebug = { hasSetAPIKEY: boolean @@ -365,6 +367,19 @@ const Debug: FC = ({ handleVisionConfigInMultipleModel() }, [multipleModelConfigs, mode]) + const { currentLogItem, setCurrentLogItem, showPromptLogModal, setShowPromptLogModal } = useAppStore() + const [width, setWidth] = useState(0) + const ref = useRef(null) + + const adjustModalWidth = () => { + if (ref.current) + setWidth(document.body.clientWidth - (ref.current?.clientWidth + 16) - 8) + } + + useEffect(() => { + adjustModalWidth() + }, []) + return ( <>
@@ -426,7 +441,7 @@ const Debug: FC = ({ } { !debugWithMultipleModel && ( -
+
{/* Chat */} {mode !== AppType.completion && (
@@ -458,6 +473,16 @@ const Debug: FC = ({ )}
)} + {showPromptLogModal && ( + { + setCurrentLogItem() + setShowPromptLogModal(false) + }} + /> + )} {isShowCannotQueryDataset && ( setShowCannotQueryDataset(false)}