Skip to content

Commit 40f527a

Browse files
authored
4.8.12 test (#2936)
* system config tip * perf: prompt editor code * perf: cookie tip
1 parent 4aaf9bf commit 40f527a

File tree

9 files changed

+162
-174
lines changed

9 files changed

+162
-174
lines changed

docSite/content/zh-cn/docs/development/upgrading/4812.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ weight: 812
1515
4. 新增 - Debug 模式支持输入全局变量
1616
5. 新增 - chat openapi 文档
1717
6. 新增 - wiki 搜索插件
18-
7. 修复 - 文件后缀判断,去除 query 影响。
19-
8. 修复 - AI 响应为空时,会造成 LLM 历史记录合并。
20-
9. 修复 - 用户交互节点未阻塞流程。
18+
7. 新增 - Cookie 隐私协议提示
19+
8. 修复 - 文件后缀判断,去除 query 影响。
20+
9. 修复 - AI 响应为空时,会造成 LLM 历史记录合并。
21+
10. 修复 - 用户交互节点未阻塞流程。

packages/plugins/src/drawing/template.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"author": "",
2+
"author": "silencezhang7",
33
"version": "486",
44
"name": "BI图表功能",
55
"avatar": "core/workflow/template/BI",

packages/service/core/workflow/dispatch/agent/extract.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ const toolChoice = async (props: ActionProps) => {
243243
const arg: Record<string, any> = (() => {
244244
try {
245245
return json5.parse(
246-
response?.choices?.[0]?.message?.tool_calls?.[0]?.function?.arguments || '{}'
246+
response?.choices?.[0]?.message?.tool_calls?.[0]?.function?.arguments || ''
247247
);
248248
} catch (error) {
249249
console.log(agentFunction.parameters);

packages/web/components/common/Textarea/PromptEditor/Editor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
*/
88

9-
import { useState, useRef, useTransition, useCallback } from 'react';
9+
import { useState, useTransition } from 'react';
1010
import { LexicalComposer } from '@lexical/react/LexicalComposer';
1111
import { PlainTextPlugin } from '@lexical/react/LexicalPlainTextPlugin';
1212
import { ContentEditable } from '@lexical/react/LexicalContentEditable';

projects/app/data/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"usedInExtractFields": true, // 是否用于内容提取(务必保证至少有一个为true)
2626
"usedInToolCall": true, // 是否用于工具调用(务必保证至少有一个为true)
2727
"usedInQueryExtension": true, // 是否用于问题优化(务必保证至少有一个为true)
28-
"toolChoice": true, // 是否支持工具选择(分类,内容提取,工具调用会用到。目前只有gpt支持
28+
"toolChoice": true, // 是否支持工具选择(分类,内容提取,工具调用会用到。)
2929
"functionCall": false, // 是否支持函数调用(分类,内容提取,工具调用会用到。会优先使用 toolChoice,如果为false,则使用 functionCall,如果仍为 false,则使用提示词模式)
3030
"customCQPrompt": "", // 自定义文本分类提示词(不支持工具和函数调用的模型
3131
"customExtractPrompt": "", // 自定义内容提取提示词

projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/render/RenderInput/templates/SettingQuotePrompt.tsx

Lines changed: 139 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useCallback, useEffect, useMemo, useState } from 'react';
1+
import React, { useCallback, useMemo, useState } from 'react';
22
import type { RenderInputProps } from '../type';
33
import { Box, BoxProps, Button, Flex, ModalFooter, useDisclosure } from '@chakra-ui/react';
44
import MyModal from '@fastgpt/web/components/common/MyModal';
@@ -43,30 +43,22 @@ const selectTemplateBtn: BoxProps = {
4343
cursor: 'pointer'
4444
};
4545

46-
const SettingQuotePrompt = (props: RenderInputProps) => {
46+
const EditModal = ({ onClose, ...props }: RenderInputProps & { onClose: () => void }) => {
4747
const { inputs = [], nodeId } = props;
4848
const { t } = useTranslation();
49-
const { isOpen, onOpen, onClose } = useDisclosure();
5049
const onChangeNode = useContextSelector(WorkflowContext, (v) => v.onChangeNode);
5150
const nodeList = useContextSelector(WorkflowContext, (v) => v.nodeList);
5251

53-
const defaultValues = useMemo(() => {
54-
return {
52+
const { watch, setValue, handleSubmit } = useForm({
53+
defaultValues: {
5554
quoteTemplate:
5655
inputs.find((input) => input.key === NodeInputKeyEnum.aiChatQuoteTemplate)?.value || '',
5756
quotePrompt:
5857
inputs.find((input) => input.key === NodeInputKeyEnum.aiChatQuotePrompt)?.value || '',
5958
quoteRole: (inputs.find((input) => input.key === NodeInputKeyEnum.aiChatQuoteRole)?.value ||
6059
'system') as AiChatQuoteRoleType
61-
};
62-
}, [inputs]);
63-
64-
const { watch, setValue, handleSubmit, reset } = useForm({ defaultValues });
65-
66-
useEffect(() => {
67-
reset(defaultValues);
68-
}, [defaultValues, reset]);
69-
60+
}
61+
});
7062
const aiChatQuoteTemplate = watch('quoteTemplate');
7163
const aiChatQuotePrompt = watch('quotePrompt');
7264
const aiChatQuoteRole = watch('quoteRole');
@@ -175,6 +167,137 @@ const SettingQuotePrompt = (props: RenderInputProps) => {
175167
const quotePromptTemplates =
176168
aiChatQuoteRole === 'user' ? Prompt_userQuotePromptList : Prompt_systemQuotePromptList;
177169

170+
return (
171+
<>
172+
<MyModal
173+
isOpen
174+
iconSrc={'modal/edit'}
175+
title={t('workflow:Quote_prompt_setting')}
176+
w={'100%'}
177+
h={['90vh', '85vh']}
178+
maxW={['90vw', '700px']}
179+
isCentered
180+
>
181+
<ModalBody flex={'1 0 0'} overflow={'auto'}>
182+
<Flex {...LabelStyles} alignItems={'center'}>
183+
<FormLabel>{t('workflow:dataset_quote_role')}</FormLabel>
184+
<QuestionTip label={t('workflow:dataset_quote_role_tip')} ml={1} mr={5} />
185+
<MySelect<AiChatQuoteRoleType>
186+
value={aiChatQuoteRole}
187+
list={[
188+
{
189+
label: 'System',
190+
value: 'system',
191+
description: t('workflow:dataset_quote_role_system_option_desc')
192+
},
193+
{
194+
label: 'User',
195+
value: 'user',
196+
description: t('workflow:dataset_quote_role_user_option_desc')
197+
}
198+
]}
199+
onchange={(e) => {
200+
setValue('quoteRole', e);
201+
}}
202+
/>
203+
<Box ml={5}>
204+
{aiChatQuoteRole === 'user' ? (
205+
<LightTip text={t('workflow:quote_role_user_tip')} />
206+
) : (
207+
<LightTip text={t('workflow:quote_role_system_tip')} />
208+
)}
209+
</Box>
210+
</Flex>
211+
<Box mt={4}>
212+
<Flex {...LabelStyles} mb={1}>
213+
<FormLabel>{t('common:core.app.Quote templates')}</FormLabel>
214+
<QuestionTip
215+
ml={1}
216+
label={t('workflow:quote_content_tip', {
217+
default: Prompt_QuoteTemplateList[0].value
218+
})}
219+
></QuestionTip>
220+
<Box flex={1} />
221+
<Box
222+
{...selectTemplateBtn}
223+
fontSize={'sm'}
224+
onClick={() =>
225+
setSelectTemplateData({
226+
title: t('common:core.app.Select quote template'),
227+
templates: Prompt_QuoteTemplateList
228+
})
229+
}
230+
>
231+
{t('common:common.Select template')}
232+
</Box>
233+
</Flex>
234+
235+
<PromptEditor
236+
variables={quoteTemplateVariables}
237+
minH={160}
238+
title={t('common:core.app.Quote templates')}
239+
placeholder={t('workflow:quote_content_placeholder')}
240+
value={aiChatQuoteTemplate}
241+
onChange={(e) => {
242+
setValue('quoteTemplate', e);
243+
}}
244+
/>
245+
</Box>
246+
<Box mt={4}>
247+
<Flex {...LabelStyles} mb={1}>
248+
<FormLabel>{t('common:core.app.Quote prompt')}</FormLabel>
249+
<QuestionTip
250+
ml={1}
251+
label={t('workflow:quote_prompt_tip', {
252+
default: quotePromptTemplates[0].value
253+
})}
254+
></QuestionTip>
255+
</Flex>
256+
<PromptEditor
257+
variables={quotePromptVariables}
258+
title={t('common:core.app.Quote prompt')}
259+
minH={300}
260+
placeholder={t('workflow:quote_prompt_tip', {
261+
default: quotePromptTemplates[0].value
262+
})}
263+
value={aiChatQuotePrompt}
264+
onChange={(e) => {
265+
setValue('quotePrompt', e);
266+
}}
267+
/>
268+
</Box>
269+
</ModalBody>
270+
<ModalFooter>
271+
<Button variant={'whiteBase'} mr={2} onClick={onClose}>
272+
{t('common:common.Close')}
273+
</Button>
274+
<Button onClick={handleSubmit(onSubmit)}>{t('common:common.Confirm')}</Button>
275+
</ModalFooter>
276+
</MyModal>
277+
{/* Prompt template */}
278+
{!!selectTemplateData && (
279+
<PromptTemplate
280+
title={selectTemplateData.title}
281+
templates={selectTemplateData.templates}
282+
onClose={() => setSelectTemplateData(undefined)}
283+
onSuccess={(e) => {
284+
const quoteVal = e.value;
285+
286+
const promptVal = quotePromptTemplates.find((item) => item.title === e.title)?.value;
287+
288+
setValue('quoteTemplate', quoteVal);
289+
setValue('quotePrompt', promptVal);
290+
}}
291+
/>
292+
)}
293+
</>
294+
);
295+
};
296+
297+
const SettingQuotePrompt = (props: RenderInputProps) => {
298+
const { t } = useTranslation();
299+
const { isOpen, onOpen, onClose } = useDisclosure();
300+
178301
const Render = useMemo(() => {
179302
return (
180303
<>
@@ -201,146 +324,10 @@ const SettingQuotePrompt = (props: RenderInputProps) => {
201324
<Reference {...props} />
202325
</Box>
203326

204-
<MyModal
205-
isOpen={isOpen}
206-
iconSrc={'modal/edit'}
207-
title={t('workflow:Quote_prompt_setting')}
208-
w={'100%'}
209-
h={['90vh', '85vh']}
210-
maxW={['90vw', '700px']}
211-
isCentered
212-
>
213-
<ModalBody flex={'1 0 0'} overflow={'auto'}>
214-
<Flex {...LabelStyles} alignItems={'center'}>
215-
<FormLabel>{t('workflow:dataset_quote_role')}</FormLabel>
216-
<QuestionTip label={t('workflow:dataset_quote_role_tip')} ml={1} mr={5} />
217-
<MySelect<AiChatQuoteRoleType>
218-
value={aiChatQuoteRole}
219-
list={[
220-
{
221-
label: 'System',
222-
value: 'system',
223-
description: t('workflow:dataset_quote_role_system_option_desc')
224-
},
225-
{
226-
label: 'User',
227-
value: 'user',
228-
description: t('workflow:dataset_quote_role_user_option_desc')
229-
}
230-
]}
231-
onchange={(e) => {
232-
setValue('quoteRole', e);
233-
}}
234-
/>
235-
<Box ml={5}>
236-
{aiChatQuoteRole === 'user' ? (
237-
<LightTip text={t('workflow:quote_role_user_tip')} />
238-
) : (
239-
<LightTip text={t('workflow:quote_role_system_tip')} />
240-
)}
241-
</Box>
242-
</Flex>
243-
<Box mt={4}>
244-
<Flex {...LabelStyles} mb={1}>
245-
<FormLabel>{t('common:core.app.Quote templates')}</FormLabel>
246-
<QuestionTip
247-
ml={1}
248-
label={t('workflow:quote_content_tip', {
249-
default: Prompt_QuoteTemplateList[0].value
250-
})}
251-
></QuestionTip>
252-
<Box flex={1} />
253-
<Box
254-
{...selectTemplateBtn}
255-
fontSize={'sm'}
256-
onClick={() =>
257-
setSelectTemplateData({
258-
title: t('common:core.app.Select quote template'),
259-
templates: Prompt_QuoteTemplateList
260-
})
261-
}
262-
>
263-
{t('common:common.Select template')}
264-
</Box>
265-
</Flex>
266-
267-
<PromptEditor
268-
variables={quoteTemplateVariables}
269-
minH={160}
270-
title={t('common:core.app.Quote templates')}
271-
placeholder={t('workflow:quote_content_placeholder')}
272-
value={aiChatQuoteTemplate}
273-
onChange={(e) => {
274-
setValue('quoteTemplate', e);
275-
}}
276-
/>
277-
</Box>
278-
<Box mt={4}>
279-
<Flex {...LabelStyles} mb={1}>
280-
<FormLabel>{t('common:core.app.Quote prompt')}</FormLabel>
281-
<QuestionTip
282-
ml={1}
283-
label={t('workflow:quote_prompt_tip', {
284-
default: quotePromptTemplates[0].value
285-
})}
286-
></QuestionTip>
287-
</Flex>
288-
<PromptEditor
289-
variables={quotePromptVariables}
290-
title={t('common:core.app.Quote prompt')}
291-
minH={300}
292-
placeholder={t('workflow:quote_prompt_tip', {
293-
default: quotePromptTemplates[0].value
294-
})}
295-
value={aiChatQuotePrompt}
296-
onChange={(e) => {
297-
setValue('quotePrompt', e);
298-
}}
299-
/>
300-
</Box>
301-
</ModalBody>
302-
<ModalFooter>
303-
<Button variant={'whiteBase'} mr={2} onClick={onClose}>
304-
{t('common:common.Close')}
305-
</Button>
306-
<Button onClick={handleSubmit(onSubmit)}>{t('common:common.Confirm')}</Button>
307-
</ModalFooter>
308-
</MyModal>
309-
{/* Prompt template */}
310-
{!!selectTemplateData && (
311-
<PromptTemplate
312-
title={selectTemplateData.title}
313-
templates={selectTemplateData.templates}
314-
onClose={() => setSelectTemplateData(undefined)}
315-
onSuccess={(e) => {
316-
const quoteVal = e.value;
317-
318-
const promptVal = quotePromptTemplates.find((item) => item.title === e.title)?.value;
319-
320-
setValue('quoteTemplate', quoteVal);
321-
setValue('quotePrompt', promptVal);
322-
}}
323-
/>
324-
)}
327+
{isOpen && <EditModal {...props} onClose={onClose} />}
325328
</>
326329
);
327-
}, [
328-
aiChatQuotePrompt,
329-
aiChatQuoteRole,
330-
aiChatQuoteTemplate,
331-
handleSubmit,
332-
isOpen,
333-
onClose,
334-
onOpen,
335-
onSubmit,
336-
props,
337-
quotePromptTemplates,
338-
quotePromptVariables,
339-
quoteTemplateVariables,
340-
selectTemplateData,
341-
setValue,
342-
t
343-
]);
330+
}, [isOpen, onClose, onOpen, t]);
344331

345332
return Render;
346333
};

projects/app/src/pages/app/detail/components/WorkflowComponents/utils.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ export const getEditorVariables = ({
123123
const sourceNodeVariables = !sourceNodes
124124
? []
125125
: sourceNodes
126-
.reverse()
127126
.map((node) => {
128127
return node.outputs
129128
.filter((output) => !!output.label)

0 commit comments

Comments
 (0)