From cf7d64020bcf2fc94f3673f5bbbe184d5986f34a Mon Sep 17 00:00:00 2001 From: Anusha Yella Date: Thu, 25 Apr 2024 17:11:11 +0530 Subject: [PATCH 1/4] fix: disabled autogenerate field icon when empty system role --- .../AgentMeta/AutoGenerateInput.tsx | 57 ++++++++++--------- .../AgentMeta/AutoGenerateSelect.tsx | 4 +- src/features/AgentSetting/AgentMeta/index.tsx | 2 + src/features/AgentSetting/store/action.ts | 13 +---- 4 files changed, 37 insertions(+), 39 deletions(-) diff --git a/src/features/AgentSetting/AgentMeta/AutoGenerateInput.tsx b/src/features/AgentSetting/AgentMeta/AutoGenerateInput.tsx index cebdde8c6c6f..581f43e3edeb 100644 --- a/src/features/AgentSetting/AgentMeta/AutoGenerateInput.tsx +++ b/src/features/AgentSetting/AgentMeta/AutoGenerateInput.tsx @@ -5,37 +5,42 @@ import { Wand2 } from 'lucide-react'; import { memo } from 'react'; import { useTranslation } from 'react-i18next'; + export interface AutoGenerateInputProps extends InputProps { + canAutoGenerate?: boolean; loading?: boolean; onGenerate?: () => void; } -const AutoGenerateInput = memo(({ loading, onGenerate, ...props }) => { - const { t } = useTranslation('common'); - const theme = useTheme(); +const AutoGenerateInput = memo( + ({ loading, onGenerate, canAutoGenerate, ...props }) => { + const { t } = useTranslation('common'); + const theme = useTheme(); - return ( - - ) - } - type={'block'} - {...props} - /> - ); -}); + return ( + + ) + } + type="block" + {...props} + /> + ); + }, +); export default AutoGenerateInput; diff --git a/src/features/AgentSetting/AgentMeta/AutoGenerateSelect.tsx b/src/features/AgentSetting/AgentMeta/AutoGenerateSelect.tsx index 980ffe9baffa..a31ed4960660 100644 --- a/src/features/AgentSetting/AgentMeta/AutoGenerateSelect.tsx +++ b/src/features/AgentSetting/AgentMeta/AutoGenerateSelect.tsx @@ -7,12 +7,13 @@ import { memo } from 'react'; import { useTranslation } from 'react-i18next'; export interface AutoGenerateInputProps extends SelectProps { + canAutoGenerate?: boolean; loading?: boolean; onGenerate?: () => void; } const AutoGenerateSelect = memo( - ({ loading, onGenerate, value, ...props }) => { + ({ loading, onGenerate, value, canAutoGenerate, ...props }) => { const { t } = useTranslation('common'); const theme = useTheme(); @@ -25,6 +26,7 @@ const AutoGenerateSelect = memo( onGenerate && ( { return { children: ( { diff --git a/src/features/AgentSetting/store/action.ts b/src/features/AgentSetting/store/action.ts index 5176fe661253..bff9d1846fb7 100644 --- a/src/features/AgentSetting/store/action.ts +++ b/src/features/AgentSetting/store/action.ts @@ -9,9 +9,7 @@ import { chatService } from '@/services/chat'; import { LobeAgentConfig } from '@/types/agent'; import { MetaData } from '@/types/meta'; import { setNamespace } from '@/utils/storeDebug'; - -import { SessionLoadingState } from '../store/initialState'; -import { State, initialState } from './initialState'; +import { State, initialState, SessionLoadingState } from './initialState'; import { ConfigDispatch, configReducer } from './reducers/config'; import { MetaDataDispatch, metaDataReducer } from './reducers/meta'; @@ -91,9 +89,6 @@ export const store: StateCreator = (set, g const { dispatchMeta, config, meta, updateLoadingState, streamUpdateMetaString } = get(); const systemRole = config.systemRole; - - if (!systemRole) return; - const preValue = meta.description; // 替换为 ... @@ -115,9 +110,6 @@ export const store: StateCreator = (set, g const { dispatchMeta, config, meta, updateLoadingState, streamUpdateMetaArray } = get(); const systemRole = config.systemRole; - - if (!systemRole) return; - const preValue = meta.tags; // 替换为 ... @@ -141,9 +133,6 @@ export const store: StateCreator = (set, g const { dispatchMeta, config, meta, updateLoadingState, streamUpdateMetaString } = get(); const systemRole = config.systemRole; - - if (!systemRole) return; - const previousTitle = meta.title; // 替换为 ... From 9f85b6dce95f5ef9079af59c39d22db3c68eee86 Mon Sep 17 00:00:00 2001 From: Anusha Yella Date: Fri, 3 May 2024 12:12:22 +0530 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=90=9B=20fix:=20update=20systemrole?= =?UTF-8?q?=20guard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/features/AgentSetting/store/action.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/features/AgentSetting/store/action.ts b/src/features/AgentSetting/store/action.ts index bff9d1846fb7..8e7df1ed42e3 100644 --- a/src/features/AgentSetting/store/action.ts +++ b/src/features/AgentSetting/store/action.ts @@ -91,6 +91,8 @@ export const store: StateCreator = (set, g const systemRole = config.systemRole; const preValue = meta.description; + if (!systemRole) return; + // 替换为 ... dispatchMeta({ type: 'update', value: { description: '...' } }); @@ -112,6 +114,8 @@ export const store: StateCreator = (set, g const systemRole = config.systemRole; const preValue = meta.tags; + if (!systemRole) return; + // 替换为 ... dispatchMeta({ type: 'update', value: { tags: ['...'] } }); @@ -135,6 +139,8 @@ export const store: StateCreator = (set, g const systemRole = config.systemRole; const previousTitle = meta.title; + if (!systemRole) return; + // 替换为 ... dispatchMeta({ type: 'update', value: { title: '...' } }); From 76f8112427eb3ee713911b58f97311d2ad5696f6 Mon Sep 17 00:00:00 2001 From: Anusha Yella Date: Fri, 3 May 2024 16:10:24 +0530 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=90=9B=20fix:=20revert=20action.ts=20?= =?UTF-8?q?file=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/features/AgentSetting/store/action.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/features/AgentSetting/store/action.ts b/src/features/AgentSetting/store/action.ts index 8e7df1ed42e3..13a88bc212bc 100644 --- a/src/features/AgentSetting/store/action.ts +++ b/src/features/AgentSetting/store/action.ts @@ -9,7 +9,9 @@ import { chatService } from '@/services/chat'; import { LobeAgentConfig } from '@/types/agent'; import { MetaData } from '@/types/meta'; import { setNamespace } from '@/utils/storeDebug'; -import { State, initialState, SessionLoadingState } from './initialState'; + +import { SessionLoadingState } from '../store/initialState'; +import { State, initialState } from './initialState'; import { ConfigDispatch, configReducer } from './reducers/config'; import { MetaDataDispatch, metaDataReducer } from './reducers/meta'; @@ -89,10 +91,11 @@ export const store: StateCreator = (set, g const { dispatchMeta, config, meta, updateLoadingState, streamUpdateMetaString } = get(); const systemRole = config.systemRole; - const preValue = meta.description; if (!systemRole) return; + const preValue = meta.description; + // 替换为 ... dispatchMeta({ type: 'update', value: { description: '...' } }); @@ -112,10 +115,11 @@ export const store: StateCreator = (set, g const { dispatchMeta, config, meta, updateLoadingState, streamUpdateMetaArray } = get(); const systemRole = config.systemRole; - const preValue = meta.tags; if (!systemRole) return; + const preValue = meta.tags; + // 替换为 ... dispatchMeta({ type: 'update', value: { tags: ['...'] } }); @@ -137,10 +141,11 @@ export const store: StateCreator = (set, g const { dispatchMeta, config, meta, updateLoadingState, streamUpdateMetaString } = get(); const systemRole = config.systemRole; - const previousTitle = meta.title; if (!systemRole) return; - + + const previousTitle = meta.title; + // 替换为 ... dispatchMeta({ type: 'update', value: { title: '...' } }); @@ -266,4 +271,4 @@ export const store: StateCreator = (set, g t('updateLoadingState', { key, value }), ); }, -}); +}); \ No newline at end of file From 56cbc3b16da4c2a25520b84bab9d95996757e12c Mon Sep 17 00:00:00 2001 From: Anusha Yella Date: Fri, 3 May 2024 16:12:01 +0530 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=90=9B=20fix:=20added=20space?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/features/AgentSetting/store/action.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/features/AgentSetting/store/action.ts b/src/features/AgentSetting/store/action.ts index 13a88bc212bc..5176fe661253 100644 --- a/src/features/AgentSetting/store/action.ts +++ b/src/features/AgentSetting/store/action.ts @@ -271,4 +271,4 @@ export const store: StateCreator = (set, g t('updateLoadingState', { key, value }), ); }, -}); \ No newline at end of file +});