Skip to content

Commit c8bbd8a

Browse files
authored
version (#6726)
* version * fix: default model
1 parent 57a505f commit c8bbd8a

5 files changed

Lines changed: 41 additions & 56 deletions

File tree

projects/app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "app",
3-
"version": "4.14.10",
3+
"version": "4.14.10.1",
44
"private": false,
55
"scripts": {
66
"dev": "NODE_OPTIONS='--max-old-space-size=8192' npm run build:workers && next dev",

projects/app/src/components/core/ai/SettingLLMModel/index.tsx

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,14 @@ import MyIcon from '@fastgpt/web/components/common/Icon';
99
import AIModelSelector from '@/components/Select/AIModelSelector';
1010
import { getWebDefaultLLMModel } from '@/web/common/system/utils';
1111
import { useMemoEnhance } from '@fastgpt/web/hooks/useMemoEnhance';
12-
import { useLatest } from 'ahooks';
1312

1413
type Props = {
15-
defaultModel?: string;
1614
defaultData: SettingAIDataType;
1715
onChange: (e: SettingAIDataType) => void;
1816
bg?: string;
1917
};
2018

21-
const SettingLLMModel = ({
22-
defaultModel,
23-
defaultData,
24-
onChange,
25-
...props
26-
}: AIChatSettingsModalProps & Props) => {
19+
const SettingLLMModel = ({ defaultData, onChange, ...props }: AIChatSettingsModalProps & Props) => {
2720
const { t } = useTranslation();
2821
const { llmModelList } = useSystemStore();
2922

@@ -38,18 +31,20 @@ const SettingLLMModel = ({
3831
};
3932
}, [llmModelList]);
4033

41-
// Set default model
42-
const lastDefaultModel = useLatest(defaultModel);
34+
// Reset undefined model
4335
useEffect(() => {
44-
if (modelSet.size === 0) return;
45-
if (!modelSet.has(model)) {
46-
const defaultLLM = lastDefaultModel.current || defaultLLMModel;
47-
if (defaultLLM && modelSet.has(defaultLLM)) {
36+
if (model) {
37+
if (modelSet.size > 0 && !modelSet.has(model) && defaultLLMModel) {
4838
onChange({
4939
...defaultData,
50-
model: defaultLLM
40+
model: defaultLLMModel
5141
});
5242
}
43+
} else if (defaultLLMModel) {
44+
onChange({
45+
...defaultData,
46+
model: defaultLLMModel
47+
});
5348
}
5449
}, [model, defaultData, modelSet, defaultLLMModel]);
5550

projects/app/src/pageComponents/app/detail/Edit/ChatAgent/index.tsx

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState } from 'react';
2-
import { getDefaultAppForm } from '@fastgpt/global/core/app/utils';
2+
import type { AppFormEditFormType } from '@fastgpt/global/core/app/formEdit/type';
33
import { agentForm2AppWorkflow, appWorkflow2AgentForm } from './utils';
44

55
import Header from '../FormComponent/Header';
@@ -24,14 +24,9 @@ const AgentEdit = () => {
2424
appDetail._id
2525
);
2626

27-
const [appForm, setAppForm] = useState(getDefaultAppForm());
28-
29-
// Init app form
30-
useMount(async () => {
31-
let initialAppForm;
32-
27+
const [appForm, setAppForm] = useState<AppFormEditFormType>(() => {
3328
if (past.length === 0) {
34-
initialAppForm = appWorkflow2AgentForm({
29+
return appWorkflow2AgentForm({
3530
nodes: appDetail.modules,
3631
chatConfig: {
3732
...appDetail.chatConfig,
@@ -41,17 +36,20 @@ const AgentEdit = () => {
4136
}
4237
}
4338
});
39+
}
40+
41+
return past[0].appForm;
42+
});
43+
44+
// Init snapshot
45+
useMount(() => {
46+
if (past.length === 0) {
4447
saveSnapshot({
45-
appForm: initialAppForm,
48+
appForm,
4649
title: t('app:initial_form'),
4750
isSaved: true
4851
});
49-
} else {
50-
initialAppForm = past[0].appForm;
5152
}
52-
53-
// Set initial app form
54-
setAppForm(initialAppForm);
5553
});
5654

5755
// Save snapshot to local

projects/app/src/pageComponents/app/detail/Edit/SimpleApp/index.tsx

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import React, { useState } from 'react';
2-
import { getDefaultAppForm } from '@fastgpt/global/core/app/utils';
3-
42
import Header from '../FormComponent/Header';
53
import { useContextSelector } from 'use-context-selector';
64
import { AppContext, TabEnum } from '../../context';
@@ -25,22 +23,16 @@ const SimpleEdit = () => {
2523
appDetail._id
2624
);
2725

28-
const [appForm, setAppForm] = useState(getDefaultAppForm());
29-
30-
// Init app form
31-
useMount(() => {
26+
const [appForm, setAppForm] = useState(() => {
3227
if (appDetail.version !== 'v2') {
33-
return setAppForm(
34-
appWorkflow2Form({
35-
nodes: v1Workflow2V2((appDetail.modules || []) as any)?.nodes,
36-
chatConfig: appDetail.chatConfig
37-
})
38-
);
28+
return appWorkflow2Form({
29+
nodes: v1Workflow2V2((appDetail.modules || []) as any)?.nodes,
30+
chatConfig: appDetail.chatConfig
31+
});
3932
}
4033

41-
// 初始化snapshot
4234
if (past.length === 0) {
43-
const appForm = appWorkflow2Form({
35+
return appWorkflow2Form({
4436
nodes: appDetail.modules,
4537
chatConfig: {
4638
...appDetail.chatConfig,
@@ -50,14 +42,20 @@ const SimpleEdit = () => {
5042
}
5143
}
5244
});
45+
}
46+
return past[0].appForm;
47+
});
48+
49+
// Init app form
50+
useMount(() => {
51+
// 初始化snapshot
52+
if (past.length === 0) {
5353
saveSnapshot({
5454
appForm,
5555
title: t('app:initial_form'),
5656
isSaved: true
5757
});
5858
setAppForm(appForm);
59-
} else {
60-
setAppForm(past[0].appForm);
6159
}
6260
});
6361

projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderInput/templates/SettingLLMModel.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { useMemoEnhance } from '@fastgpt/web/hooks/useMemoEnhance';
99
import { useLocalStorageState } from 'ahooks';
1010
import { getWebDefaultLLMModel } from '@/web/common/system/utils';
1111

12-
const SelectAiModelRender = ({ item, inputs = [], nodeId }: RenderInputProps) => {
12+
const SelectAiModelRender = ({ inputs = [], nodeId }: RenderInputProps) => {
1313
const onChangeNode = useContextSelector(WorkflowActionsContext, (v) => v.onChangeNode);
1414

1515
const [defaultModel, setDefaultModel] = useLocalStorageState<string>(
@@ -46,7 +46,7 @@ const SelectAiModelRender = ({ item, inputs = [], nodeId }: RenderInputProps) =>
4646

4747
const llmModelData: SettingAIDataType = useMemoEnhance(
4848
() => ({
49-
model: inputs.find((input) => input.key === NodeInputKeyEnum.aiModel)?.value ?? '',
49+
model: inputs.find((input) => input.key === NodeInputKeyEnum.aiModel)?.value ?? defaultModel,
5050
maxToken: inputs.find((input) => input.key === NodeInputKeyEnum.aiChatMaxToken)?.value,
5151
temperature: inputs.find((input) => input.key === NodeInputKeyEnum.aiChatTemperature)?.value,
5252
isResponseAnswerText: inputs.find(
@@ -64,16 +64,10 @@ const SelectAiModelRender = ({ item, inputs = [], nodeId }: RenderInputProps) =>
6464
aiChatJsonSchema: inputs.find((input) => input.key === NodeInputKeyEnum.aiChatJsonSchema)
6565
?.value
6666
}),
67-
[inputs]
67+
[inputs, defaultModel]
6868
);
6969

70-
return (
71-
<SettingLLMModel
72-
defaultModel={defaultModel}
73-
defaultData={llmModelData}
74-
onChange={onChangeModel}
75-
/>
76-
);
70+
return <SettingLLMModel defaultData={llmModelData} onChange={onChangeModel} />;
7771
};
7872

7973
export default React.memo(SelectAiModelRender);

0 commit comments

Comments
 (0)