1
- import type { AppSimpleEditFormType } from '../app/type' ;
1
+ import type { AppChatConfigType , AppSimpleEditFormType } from '../app/type' ;
2
2
import { FlowNodeTypeEnum } from '../workflow/node/constant' ;
3
3
import { NodeInputKeyEnum , FlowNodeTemplateTypeEnum } from '../workflow/constants' ;
4
4
import type { FlowNodeInputItemType } from '../workflow/type/io.d' ;
5
- import { getGuideModule , splitGuideModule } from '../workflow/utils' ;
5
+ import { getAppChatConfig } from '../workflow/utils' ;
6
6
import { StoreNodeItemType } from '../workflow/type' ;
7
7
import { DatasetSearchModeEnum } from '../dataset/constants' ;
8
- import { defaultQuestionGuideTextConfig , defaultWhisperConfig } from './constants' ;
9
8
10
- export const getDefaultAppForm = ( ) : AppSimpleEditFormType => {
11
- return {
12
- aiSettings : {
13
- model : 'gpt-3.5-turbo' ,
14
- systemPrompt : '' ,
15
- temperature : 0 ,
16
- isResponseAnswerText : true ,
17
- maxHistories : 6 ,
18
- maxToken : 4000
19
- } ,
20
- dataset : {
21
- datasets : [ ] ,
22
- similarity : 0.4 ,
23
- limit : 1500 ,
24
- searchMode : DatasetSearchModeEnum . embedding ,
25
- usingReRank : false ,
26
- datasetSearchUsingExtensionQuery : true ,
27
- datasetSearchExtensionBg : ''
28
- } ,
29
- selectedTools : [ ] ,
30
- userGuide : {
31
- welcomeText : '' ,
32
- variables : [ ] ,
33
- questionGuide : false ,
34
- tts : {
35
- type : 'web'
36
- } ,
37
- whisper : defaultWhisperConfig ,
38
- scheduleTrigger : null ,
39
- questionGuideText : defaultQuestionGuideTextConfig
40
- }
41
- } ;
42
- } ;
9
+ export const getDefaultAppForm = ( ) : AppSimpleEditFormType => ( {
10
+ aiSettings : {
11
+ model : 'gpt-3.5-turbo' ,
12
+ systemPrompt : '' ,
13
+ temperature : 0 ,
14
+ isResponseAnswerText : true ,
15
+ maxHistories : 6 ,
16
+ maxToken : 4000
17
+ } ,
18
+ dataset : {
19
+ datasets : [ ] ,
20
+ similarity : 0.4 ,
21
+ limit : 1500 ,
22
+ searchMode : DatasetSearchModeEnum . embedding ,
23
+ usingReRank : false ,
24
+ datasetSearchUsingExtensionQuery : true ,
25
+ datasetSearchExtensionBg : ''
26
+ } ,
27
+ selectedTools : [ ] ,
28
+ chatConfig : { }
29
+ } ) ;
43
30
44
31
/* format app nodes to edit form */
45
- export const appWorkflow2Form = ( { nodes } : { nodes : StoreNodeItemType [ ] } ) => {
32
+ export const appWorkflow2Form = ( {
33
+ nodes,
34
+ chatConfig
35
+ } : {
36
+ nodes : StoreNodeItemType [ ] ;
37
+ chatConfig : AppChatConfigType ;
38
+ } ) => {
46
39
const defaultAppForm = getDefaultAppForm ( ) ;
47
-
48
40
const findInputValueByKey = ( inputs : FlowNodeInputItemType [ ] , key : string ) => {
49
41
return inputs . find ( ( item ) => item . key === key ) ?. value ;
50
42
} ;
@@ -103,26 +95,6 @@ export const appWorkflow2Form = ({ nodes }: { nodes: StoreNodeItemType[] }) => {
103
95
node . inputs ,
104
96
NodeInputKeyEnum . datasetSearchExtensionBg
105
97
) ;
106
- } else if ( node . flowNodeType === FlowNodeTypeEnum . systemConfig ) {
107
- const {
108
- welcomeText,
109
- variableNodes,
110
- questionGuide,
111
- ttsConfig,
112
- whisperConfig,
113
- scheduledTriggerConfig,
114
- questionGuideText
115
- } = splitGuideModule ( getGuideModule ( nodes ) ) ;
116
-
117
- defaultAppForm . userGuide = {
118
- welcomeText : welcomeText ,
119
- variables : variableNodes ,
120
- questionGuide : questionGuide ,
121
- tts : ttsConfig ,
122
- whisper : whisperConfig ,
123
- scheduleTrigger : scheduledTriggerConfig ,
124
- questionGuideText : questionGuideText
125
- } ;
126
98
} else if ( node . flowNodeType === FlowNodeTypeEnum . pluginModule ) {
127
99
if ( ! node . pluginId ) return ;
128
100
@@ -139,6 +111,12 @@ export const appWorkflow2Form = ({ nodes }: { nodes: StoreNodeItemType[] }) => {
139
111
outputs : node . outputs ,
140
112
templateType : FlowNodeTemplateTypeEnum . other
141
113
} ) ;
114
+ } else if ( node . flowNodeType === FlowNodeTypeEnum . systemConfig ) {
115
+ defaultAppForm . chatConfig = getAppChatConfig ( {
116
+ chatConfig,
117
+ systemConfigNode : node ,
118
+ isPublicFetch : true
119
+ } ) ;
142
120
}
143
121
} ) ;
144
122
0 commit comments