From b1aafde7c94a1423a7cf70a6913adeb4b32cb58c Mon Sep 17 00:00:00 2001 From: Archer <545436317@qq.com> Date: Wed, 22 May 2024 18:49:39 +0800 Subject: [PATCH] 4.8.1 test-fix (#1561) --- .../content/docs/course/chat_input_guide.md | 4 + packages/global/core/workflow/constants.ts | 1 + .../core/workflow/template/system/aiChat.ts | 2 + .../template/system/assignedAnswer.ts | 1 + .../template/system/classifyQuestion.ts | 1 + .../template/system/contextExtract.ts | 25 +- .../core/workflow/template/system/http468.ts | 9 + .../core/workflow/template/system/runApp.ts | 1 + packages/global/core/workflow/template/tip.ts | 2 - packages/global/core/workflow/utils.ts | 2 +- packages/service/common/mongo/init.ts | 4 + packages/service/common/system/tools.ts | 2 + .../common/vectorStore/pg/controller.ts | 10 +- .../core/workflow/dispatch/agent/extract.ts | 7 +- .../service/core/workflow/dispatch/index.ts | 23 +- .../core/workflow/dispatch/tools/http468.ts | 26 +- .../service/support/permission/controller.ts | 5 +- .../common/MyDrawer/MyRightDrawer.tsx | 7 +- .../web/components/common/MySelect/index.tsx | 1 + .../common/MyTooltip/QuestionTip.tsx | 6 +- .../common/Textarea/PromptEditor/type.d.ts | 1 + packages/web/hooks/useRefresh.ts | 9 + .../app/public/imgs/app/inputGuide-icon.svg | 4 + projects/app/public/imgs/app/inputGuide.svg | 80 +++++ .../app/public/imgs/app/nextQuestion-icon.svg | 11 + projects/app/public/imgs/app/nextQuestion.svg | 110 +++++++ projects/app/public/imgs/app/tts-icon.svg | 4 + projects/app/public/imgs/app/tts.svg | 308 ++++++++++++++++++ .../app/public/imgs/app/variable-icon.svg | 6 + projects/app/public/imgs/app/variable.svg | 175 ++++++++++ projects/app/public/imgs/app/welcome-icon.svg | 4 + projects/app/public/imgs/app/welcome.svg | 137 ++++++++ .../ChatBox/Input/InputGuideBox.tsx | 2 +- .../ChatBox/components/VariableInput.tsx | 3 + projects/app/src/components/ChatBox/index.tsx | 1 - .../appConfig => app}/InputGuideConfig.tsx | 3 +- .../app/src/components/core/app/QGSwitch.tsx | 7 +- .../core/app/ScheduledTriggerConfig.tsx | 1 - .../app/src/components/core/app/TTSSelect.tsx | 6 +- projects/app/src/components/core/app/Tip.tsx | 75 +++++ .../src/components/core/app/VariableEdit.tsx | 9 +- .../components/core/app/WelcomeTextConfig.tsx | 29 ++ .../src/components/core/dataset/QuoteItem.tsx | 10 +- .../core/workflow/Flow/hooks/useDebug.tsx | 148 +++++---- .../workflow/Flow/nodes/NodeHttp/index.tsx | 2 +- .../Flow/nodes/NodeIfElse/ListItem.tsx | 19 +- .../workflow/Flow/nodes/NodeSystemConfig.tsx | 27 +- .../Flow/nodes/NodeVariableUpdate.tsx | 4 +- .../workflow/Flow/nodes/NodeWorkflowStart.tsx | 1 + .../Flow/nodes/render/RenderOutput/index.tsx | 5 + .../dataset/collection/create/localFile.ts | 1 + .../app/src/pages/api/v1/chat/completions.ts | 23 +- .../detail/components/SimpleEdit/EditForm.tsx | 24 +- .../Import/components/PreviewChunks.tsx | 42 ++- projects/app/src/pages/dataset/list/index.tsx | 4 +- projects/app/src/pages/plugin/edit/index.tsx | 10 +- projects/app/src/web/common/api/fetch.ts | 4 +- projects/app/src/web/common/api/request.ts | 7 +- projects/app/src/web/common/api/xmlFetch.ts | 31 -- projects/app/src/web/common/system/utils.ts | 8 + projects/app/src/web/common/utils/voice.ts | 4 +- projects/app/src/web/core/app/utils.ts | 3 + .../app/src/web/core/chat/inputGuide/api.ts | 9 +- projects/app/src/web/core/workflow/adapt.ts | 2 +- projects/app/src/web/core/workflow/utils.ts | 28 +- 65 files changed, 1246 insertions(+), 294 deletions(-) create mode 100644 packages/web/hooks/useRefresh.ts create mode 100644 projects/app/public/imgs/app/inputGuide-icon.svg create mode 100644 projects/app/public/imgs/app/inputGuide.svg create mode 100644 projects/app/public/imgs/app/nextQuestion-icon.svg create mode 100644 projects/app/public/imgs/app/nextQuestion.svg create mode 100644 projects/app/public/imgs/app/tts-icon.svg create mode 100644 projects/app/public/imgs/app/tts.svg create mode 100644 projects/app/public/imgs/app/variable-icon.svg create mode 100644 projects/app/public/imgs/app/variable.svg create mode 100644 projects/app/public/imgs/app/welcome-icon.svg create mode 100644 projects/app/public/imgs/app/welcome.svg rename projects/app/src/components/core/{chat/appConfig => app}/InputGuideConfig.tsx (99%) create mode 100644 projects/app/src/components/core/app/Tip.tsx create mode 100644 projects/app/src/components/core/app/WelcomeTextConfig.tsx delete mode 100644 projects/app/src/web/common/api/xmlFetch.ts create mode 100644 projects/app/src/web/common/system/utils.ts diff --git a/docSite/content/docs/course/chat_input_guide.md b/docSite/content/docs/course/chat_input_guide.md index 82456f0d6b9a..0e99b2c3eb68 100644 --- a/docSite/content/docs/course/chat_input_guide.md +++ b/docSite/content/docs/course/chat_input_guide.md @@ -25,6 +25,8 @@ weight: 350 curl --location --request GET 'http://localhost:3000/api/core/chat/inputGuide/query?appId=663c75302caf8315b1c00194&searchKey=你' ``` +其中 `appId` 为应用ID,`searchKey` 为搜索关键字,最多是50个字符。 + **响应** ```json @@ -43,6 +45,8 @@ curl --location --request GET 'http://localhost:3000/api/core/chat/inputGuide/qu } ``` +data是一个数组,包含了搜索到的问题,最多只需要返回5个问题。 + **参数说明:** diff --git a/packages/global/core/workflow/constants.ts b/packages/global/core/workflow/constants.ts index e789d71175ad..9740dfc54234 100644 --- a/packages/global/core/workflow/constants.ts +++ b/packages/global/core/workflow/constants.ts @@ -118,6 +118,7 @@ export enum NodeOutputKeyEnum { answerText = 'answerText', // module answer. the value will be show and save to history success = 'success', failed = 'failed', + error = 'error', text = 'system_text', addOutputParam = 'system_addOutputParam', diff --git a/packages/global/core/workflow/template/system/aiChat.ts b/packages/global/core/workflow/template/system/aiChat.ts index 8f3feeebac53..e88c8c6a11b6 100644 --- a/packages/global/core/workflow/template/system/aiChat.ts +++ b/packages/global/core/workflow/template/system/aiChat.ts @@ -89,6 +89,7 @@ export const AiChatModule: FlowNodeTemplateType = { { id: NodeOutputKeyEnum.history, key: NodeOutputKeyEnum.history, + required: true, label: 'core.module.output.label.New context', description: 'core.module.output.description.New context', valueType: WorkflowIOValueTypeEnum.chatHistory, @@ -97,6 +98,7 @@ export const AiChatModule: FlowNodeTemplateType = { { id: NodeOutputKeyEnum.answerText, key: NodeOutputKeyEnum.answerText, + required: true, label: 'core.module.output.label.Ai response content', description: 'core.module.output.description.Ai response content', valueType: WorkflowIOValueTypeEnum.string, diff --git a/packages/global/core/workflow/template/system/assignedAnswer.ts b/packages/global/core/workflow/template/system/assignedAnswer.ts index 26c6f6baed3f..96d5dae30fa5 100644 --- a/packages/global/core/workflow/template/system/assignedAnswer.ts +++ b/packages/global/core/workflow/template/system/assignedAnswer.ts @@ -24,6 +24,7 @@ export const AssignedAnswerModule: FlowNodeTemplateType = { key: NodeInputKeyEnum.answerText, renderTypeList: [FlowNodeInputTypeEnum.textarea, FlowNodeInputTypeEnum.reference], valueType: WorkflowIOValueTypeEnum.any, + required: true, label: 'core.module.input.label.Response content', description: 'core.module.input.description.Response content', placeholder: 'core.module.input.description.Response content' diff --git a/packages/global/core/workflow/template/system/classifyQuestion.ts b/packages/global/core/workflow/template/system/classifyQuestion.ts index f8325d7337fe..99de2c7eeae7 100644 --- a/packages/global/core/workflow/template/system/classifyQuestion.ts +++ b/packages/global/core/workflow/template/system/classifyQuestion.ts @@ -68,6 +68,7 @@ export const ClassifyQuestionModule: FlowNodeTemplateType = { { id: NodeOutputKeyEnum.cqResult, key: NodeOutputKeyEnum.cqResult, + required: true, label: '分类结果', valueType: WorkflowIOValueTypeEnum.string, type: FlowNodeOutputTypeEnum.static diff --git a/packages/global/core/workflow/template/system/contextExtract.ts b/packages/global/core/workflow/template/system/contextExtract.ts index d34608b1857e..2223d35f97a7 100644 --- a/packages/global/core/workflow/template/system/contextExtract.ts +++ b/packages/global/core/workflow/template/system/contextExtract.ts @@ -60,25 +60,20 @@ export const ContextExtractModule: FlowNodeTemplateType = { } ], outputs: [ - // { - // id: NodeOutputKeyEnum.success, - // key: NodeOutputKeyEnum.success, - // label: '字段完全提取', - // valueType: WorkflowIOValueTypeEnum.boolean, - // type: FlowNodeOutputTypeEnum.source - // }, - // { - // id: NodeOutputKeyEnum.failed, - // key: NodeOutputKeyEnum.failed, - // label: '提取字段缺失', - // description: '存在一个或多个字段未提取成功。尽管使用了默认值也算缺失。', - // valueType: WorkflowIOValueTypeEnum.boolean, - // type: FlowNodeOutputTypeEnum.source - // }, + { + id: NodeOutputKeyEnum.success, + key: NodeOutputKeyEnum.success, + label: '字段完全提取', + required: true, + description: '提取字段全部填充时返回 true (模型提取或使用默认值均属于成功)', + valueType: WorkflowIOValueTypeEnum.boolean, + type: FlowNodeOutputTypeEnum.static + }, { id: NodeOutputKeyEnum.contextExtractFields, key: NodeOutputKeyEnum.contextExtractFields, label: '完整提取结果', + required: true, description: '一个 JSON 字符串,例如:{"name:":"YY","Time":"2023/7/2 18:00"}', valueType: WorkflowIOValueTypeEnum.string, type: FlowNodeOutputTypeEnum.static diff --git a/packages/global/core/workflow/template/system/http468.ts b/packages/global/core/workflow/template/system/http468.ts index 26d49701b137..3b46b779d77d 100644 --- a/packages/global/core/workflow/template/system/http468.ts +++ b/packages/global/core/workflow/template/system/http468.ts @@ -81,10 +81,19 @@ export const HttpModule468: FlowNodeTemplateType = { ], outputs: [ Output_Template_AddOutput, + { + id: NodeOutputKeyEnum.error, + key: NodeOutputKeyEnum.error, + label: '请求错误', + description: 'HTTP请求错误信息,成功时返回空', + valueType: WorkflowIOValueTypeEnum.object, + type: FlowNodeOutputTypeEnum.static + }, { id: NodeOutputKeyEnum.httpRawResponse, key: NodeOutputKeyEnum.httpRawResponse, label: '原始响应', + required: true, description: 'HTTP请求的原始响应。只能接受字符串或JSON类型响应数据。', valueType: WorkflowIOValueTypeEnum.any, type: FlowNodeOutputTypeEnum.static diff --git a/packages/global/core/workflow/template/system/runApp.ts b/packages/global/core/workflow/template/system/runApp.ts index 0d39310a3af0..21ad2ab5bf42 100644 --- a/packages/global/core/workflow/template/system/runApp.ts +++ b/packages/global/core/workflow/template/system/runApp.ts @@ -43,6 +43,7 @@ export const RunAppModule: FlowNodeTemplateType = { label: '新的上下文', description: '将该应用回复内容拼接到历史记录中,作为新的上下文返回', valueType: WorkflowIOValueTypeEnum.chatHistory, + required: true, type: FlowNodeOutputTypeEnum.static }, { diff --git a/packages/global/core/workflow/template/tip.ts b/packages/global/core/workflow/template/tip.ts index add805c721ac..cec778c42c84 100644 --- a/packages/global/core/workflow/template/tip.ts +++ b/packages/global/core/workflow/template/tip.ts @@ -1,3 +1 @@ export const chatNodeSystemPromptTip = 'core.app.tip.chatNodeSystemPromptTip'; -export const welcomeTextTip = 'core.app.tip.welcomeTextTip'; -export const variableTip = 'core.app.tip.variableTip'; diff --git a/packages/global/core/workflow/utils.ts b/packages/global/core/workflow/utils.ts index 004c3b5c65df..2d64bef411be 100644 --- a/packages/global/core/workflow/utils.ts +++ b/packages/global/core/workflow/utils.ts @@ -175,7 +175,7 @@ export const pluginData2FlowNodeIO = ( }; export const formatEditorVariablePickerIcon = ( - variables: { key: string; label: string; type?: `${VariableInputEnum}` }[] + variables: { key: string; label: string; type?: `${VariableInputEnum}`; required?: boolean }[] ): EditorVariablePickerType[] => { return variables.map((item) => ({ ...item, diff --git a/packages/service/common/mongo/init.ts b/packages/service/common/mongo/init.ts index db1de6c1ce59..c93a4b60e6f4 100644 --- a/packages/service/common/mongo/init.ts +++ b/packages/service/common/mongo/init.ts @@ -39,6 +39,10 @@ export async function connectMongo({ global.mongodb?.disconnect(); global.mongodb = undefined; }); + mongoose.connection.on('disconnected', () => { + console.log('mongo disconnected'); + global.mongodb = undefined; + }); console.log('mongo connected'); diff --git a/packages/service/common/system/tools.ts b/packages/service/common/system/tools.ts index 58eb0dd5f0c4..75d29825ed5e 100644 --- a/packages/service/common/system/tools.ts +++ b/packages/service/common/system/tools.ts @@ -32,3 +32,5 @@ export const systemStartCb = () => { // process.exit(1); // 退出进程 }); }; + +export const surrenderProcess = () => new Promise((resolve) => setImmediate(resolve)); diff --git a/packages/service/common/vectorStore/pg/controller.ts b/packages/service/common/vectorStore/pg/controller.ts index 3aad5b411ef0..0ce6203a9694 100644 --- a/packages/service/common/vectorStore/pg/controller.ts +++ b/packages/service/common/vectorStore/pg/controller.ts @@ -132,17 +132,19 @@ export const embeddingRecall = async ( ): Promise<{ results: EmbeddingRecallItemType[]; }> => { - const { datasetIds, vectors, limit, retry = 2 } = props; + const { teamId, datasetIds, vectors, limit, retry = 2 } = props; try { const results: any = await PgClient.query( - `BEGIN; + ` + BEGIN; SET LOCAL hnsw.ef_search = ${global.systemEnv?.pgHNSWEfSearch || 100}; select id, collection_id, vector <#> '[${vectors[0]}]' AS score from ${PgDatasetTableName} - where dataset_id IN (${datasetIds.map((id) => `'${String(id)}'`).join(',')}) + where team_id='${teamId}' + AND dataset_id IN (${datasetIds.map((id) => `'${String(id)}'`).join(',')}) order by score limit ${limit}; - COMMIT;` + COMMIT;` ); const rows = results?.[2]?.rows as PgSearchRawType[]; diff --git a/packages/service/core/workflow/dispatch/agent/extract.ts b/packages/service/core/workflow/dispatch/agent/extract.ts index a663f1374719..45066eb55a18 100644 --- a/packages/service/core/workflow/dispatch/agent/extract.ts +++ b/packages/service/core/workflow/dispatch/agent/extract.ts @@ -35,8 +35,7 @@ type Props = ModuleDispatchProps<{ [NodeInputKeyEnum.aiModel]: string; }>; type Response = DispatchNodeResultType<{ - [NodeOutputKeyEnum.success]?: boolean; - [NodeOutputKeyEnum.failed]?: boolean; + [NodeOutputKeyEnum.success]: boolean; [NodeOutputKeyEnum.contextExtractFields]: string; }>; @@ -119,9 +118,7 @@ export async function dispatchContentExtract(props: Props): Promise { }); return { - // [DispatchNodeResponseKeyEnum.skipHandleId]: success - // ? [getHandleId(nodeId, 'source', NodeOutputKeyEnum.failed)] - // : [getHandleId(nodeId, 'source', NodeOutputKeyEnum.success)], + [NodeOutputKeyEnum.success]: success, [NodeOutputKeyEnum.contextExtractFields]: JSON.stringify(arg), ...arg, [DispatchNodeResponseKeyEnum.nodeResponse]: { diff --git a/packages/service/core/workflow/dispatch/index.ts b/packages/service/core/workflow/dispatch/index.ts index 8d214ffa994d..07436d2148b5 100644 --- a/packages/service/core/workflow/dispatch/index.ts +++ b/packages/service/core/workflow/dispatch/index.ts @@ -1,5 +1,5 @@ import { NextApiResponse } from 'next'; -import { NodeInputKeyEnum, WorkflowIOValueTypeEnum } from '@fastgpt/global/core/workflow/constants'; +import { NodeInputKeyEnum } from '@fastgpt/global/core/workflow/constants'; import { DispatchNodeResponseKeyEnum } from '@fastgpt/global/core/workflow/runtime/constants'; import { NodeOutputKeyEnum } from '@fastgpt/global/core/workflow/constants'; import type { ChatDispatchProps } from '@fastgpt/global/core/workflow/type/index.d'; @@ -45,6 +45,7 @@ import { getReferenceVariableValue } from '@fastgpt/global/core/workflow/runtime import { dispatchSystemConfig } from './init/systemConfig'; import { dispatchUpdateVariable } from './tools/runUpdateVar'; import { addLog } from '../../../common/system/log'; +import { surrenderProcess } from '../../../common/system/tools'; const callbackMap: Record = { [FlowNodeTypeEnum.workflowStart]: dispatchWorkflowStart, @@ -206,25 +207,34 @@ export async function dispatchWorkFlow(data: Props): Promise { return Promise.all( - nodes.map((node) => { + nodes.map(async (node) => { const status = checkNodeRunStatus({ node, runtimeEdges }); + if (res?.closed || props.maxRunTimes <= 0) return; + props.maxRunTimes--; + console.log(props.maxRunTimes, user._id); + + await surrenderProcess(); + if (status === 'run') { addLog.info(`[dispatchWorkFlow] nodeRunWithActive: ${node.name}`); return nodeRunWithActive(node); } if (status === 'skip') { - addLog.info(`[dispatchWorkFlow] nodeRunWithActive: ${node.name}`); + addLog.info(`[dispatchWorkFlow] nodeRunWithSkip: ${node.name}`); return nodeRunWithSkip(node); } - return []; + return; }) ).then((result) => { - const flat = result.flat(); + const flat = result.flat().filter(Boolean) as unknown as { + node: RuntimeNodeItemType; + result: Record; + }[]; if (flat.length === 0) return; // Update the node output at the end of the run and get the next nodes @@ -267,7 +277,6 @@ export async function dispatchWorkFlow(data: Props): Promise; type HttpResponse = DispatchNodeResultType<{ - [NodeOutputKeyEnum.failed]?: boolean; + [NodeOutputKeyEnum.error]?: object; [key: string]: any; }>; @@ -159,20 +159,16 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise 0 ? params : undefined, - body: Object.keys(requestBody).length > 0 ? requestBody : undefined, - headers: Object.keys(headers).length > 0 ? headers : undefined, - httpResult: { error: formatHttpError(error) } - }, - [NodeOutputKeyEnum.httpRawResponse]: getErrText(error) - }; - } - return Promise.reject(error); + return { + [NodeOutputKeyEnum.error]: formatHttpError(error), + [DispatchNodeResponseKeyEnum.nodeResponse]: { + params: Object.keys(params).length > 0 ? params : undefined, + body: Object.keys(requestBody).length > 0 ? requestBody : undefined, + headers: Object.keys(headers).length > 0 ? headers : undefined, + httpResult: { error: formatHttpError(error) } + }, + [NodeOutputKeyEnum.httpRawResponse]: getErrText(error) + }; } }; diff --git a/packages/service/support/permission/controller.ts b/packages/service/support/permission/controller.ts index f7dde6faca8f..82d65aad9a90 100644 --- a/packages/service/support/permission/controller.ts +++ b/packages/service/support/permission/controller.ts @@ -170,10 +170,7 @@ export async function parseHeaderCert({ /* set cookie */ export const setCookie = (res: NextApiResponse, token: string) => { - res.setHeader( - 'Set-Cookie', - `token=${token}; Path=/; HttpOnly; Max-Age=604800; Samesite=Strict; Secure;` - ); + res.setHeader('Set-Cookie', `token=${token}; Path=/; HttpOnly; Max-Age=604800; Samesite=Strict;`); }; /* clear cookie */ export const clearCookie = (res: NextApiResponse) => { diff --git a/packages/web/components/common/MyDrawer/MyRightDrawer.tsx b/packages/web/components/common/MyDrawer/MyRightDrawer.tsx index f1d0d14cc8ab..fe6e22793925 100644 --- a/packages/web/components/common/MyDrawer/MyRightDrawer.tsx +++ b/packages/web/components/common/MyDrawer/MyRightDrawer.tsx @@ -67,7 +67,12 @@ const MyRightDrawer = ({ - + {children} diff --git a/packages/web/components/common/MySelect/index.tsx b/packages/web/components/common/MySelect/index.tsx index d1e7de023fc3..2bafc7319adb 100644 --- a/packages/web/components/common/MySelect/index.tsx +++ b/packages/web/components/common/MySelect/index.tsx @@ -98,6 +98,7 @@ const MySelect = ( { const w = ref.current?.clientWidth; if (w) { diff --git a/packages/web/components/common/MyTooltip/QuestionTip.tsx b/packages/web/components/common/MyTooltip/QuestionTip.tsx index c2a7b81e4525..205245c8ad4c 100644 --- a/packages/web/components/common/MyTooltip/QuestionTip.tsx +++ b/packages/web/components/common/MyTooltip/QuestionTip.tsx @@ -3,12 +3,12 @@ import MyTooltip from '.'; import { IconProps, QuestionOutlineIcon } from '@chakra-ui/icons'; type Props = IconProps & { - label?: string; + label?: string | React.ReactNode; }; -const QuestionTip = ({ label, ...props }: Props) => { +const QuestionTip = ({ label, maxW, ...props }: Props) => { return ( - + ); diff --git a/packages/web/components/common/Textarea/PromptEditor/type.d.ts b/packages/web/components/common/Textarea/PromptEditor/type.d.ts index c1f0b82e322c..cbf35e6d6b30 100644 --- a/packages/web/components/common/Textarea/PromptEditor/type.d.ts +++ b/packages/web/components/common/Textarea/PromptEditor/type.d.ts @@ -3,6 +3,7 @@ import { WorkflowIOValueTypeEnum } from '@fastgpt/global/core/workflow/constants export type EditorVariablePickerType = { key: string; label: string; + required?: boolean; icon?: string; valueType?: WorkflowIOValueTypeEnum; }; diff --git a/packages/web/hooks/useRefresh.ts b/packages/web/hooks/useRefresh.ts new file mode 100644 index 000000000000..a72e45774e59 --- /dev/null +++ b/packages/web/hooks/useRefresh.ts @@ -0,0 +1,9 @@ +import { useBoolean } from 'ahooks'; + +export const useRefresh = () => { + const [_, { toggle }] = useBoolean(); + + return { + refresh: toggle + }; +}; diff --git a/projects/app/public/imgs/app/inputGuide-icon.svg b/projects/app/public/imgs/app/inputGuide-icon.svg new file mode 100644 index 000000000000..beeb37276990 --- /dev/null +++ b/projects/app/public/imgs/app/inputGuide-icon.svg @@ -0,0 +1,4 @@ + + + + diff --git a/projects/app/public/imgs/app/inputGuide.svg b/projects/app/public/imgs/app/inputGuide.svg new file mode 100644 index 000000000000..a3ff98069888 --- /dev/null +++ b/projects/app/public/imgs/app/inputGuide.svg @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/projects/app/public/imgs/app/nextQuestion-icon.svg b/projects/app/public/imgs/app/nextQuestion-icon.svg new file mode 100644 index 000000000000..846196f9fe71 --- /dev/null +++ b/projects/app/public/imgs/app/nextQuestion-icon.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/projects/app/public/imgs/app/nextQuestion.svg b/projects/app/public/imgs/app/nextQuestion.svg new file mode 100644 index 000000000000..105e9ffe696c --- /dev/null +++ b/projects/app/public/imgs/app/nextQuestion.svg @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/projects/app/public/imgs/app/tts-icon.svg b/projects/app/public/imgs/app/tts-icon.svg new file mode 100644 index 000000000000..051eb673cf5d --- /dev/null +++ b/projects/app/public/imgs/app/tts-icon.svg @@ -0,0 +1,4 @@ + + + + diff --git a/projects/app/public/imgs/app/tts.svg b/projects/app/public/imgs/app/tts.svg new file mode 100644 index 000000000000..b7c542f4edbc --- /dev/null +++ b/projects/app/public/imgs/app/tts.svg @@ -0,0 +1,308 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/projects/app/public/imgs/app/variable-icon.svg b/projects/app/public/imgs/app/variable-icon.svg new file mode 100644 index 000000000000..d50a5bdc69a0 --- /dev/null +++ b/projects/app/public/imgs/app/variable-icon.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/projects/app/public/imgs/app/variable.svg b/projects/app/public/imgs/app/variable.svg new file mode 100644 index 000000000000..c8a3551bb304 --- /dev/null +++ b/projects/app/public/imgs/app/variable.svg @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/projects/app/public/imgs/app/welcome-icon.svg b/projects/app/public/imgs/app/welcome-icon.svg new file mode 100644 index 000000000000..b8fbf3f031dd --- /dev/null +++ b/projects/app/public/imgs/app/welcome-icon.svg @@ -0,0 +1,4 @@ + + + + diff --git a/projects/app/public/imgs/app/welcome.svg b/projects/app/public/imgs/app/welcome.svg new file mode 100644 index 000000000000..8a9ddad7c78c --- /dev/null +++ b/projects/app/public/imgs/app/welcome.svg @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/projects/app/src/components/ChatBox/Input/InputGuideBox.tsx b/projects/app/src/components/ChatBox/Input/InputGuideBox.tsx index bdba32d23fd7..e923dc0ff0f7 100644 --- a/projects/app/src/components/ChatBox/Input/InputGuideBox.tsx +++ b/projects/app/src/components/ChatBox/Input/InputGuideBox.tsx @@ -30,7 +30,7 @@ export default function InputGuideBox({ return await queryChatInputGuideList( { appId, - searchKey: text + searchKey: text.slice(0, 50) }, chatInputGuide.customUrl ? chatInputGuide.customUrl : undefined ); diff --git a/projects/app/src/components/ChatBox/components/VariableInput.tsx b/projects/app/src/components/ChatBox/components/VariableInput.tsx index fe93c56268fb..e8477fbfdcc1 100644 --- a/projects/app/src/components/ChatBox/components/VariableInput.tsx +++ b/projects/app/src/components/ChatBox/components/VariableInput.tsx @@ -9,6 +9,7 @@ import { VariableInputEnum } from '@fastgpt/global/core/workflow/constants'; import MySelect from '@fastgpt/web/components/common/MySelect'; import MyIcon from '@fastgpt/web/components/common/Icon'; import { ChatBoxInputFormType } from '../type.d'; +import { useRefresh } from '@fastgpt/web/hooks/useRefresh'; const VariableInput = ({ appAvatar, @@ -25,6 +26,7 @@ const VariableInput = ({ const { register, setValue, handleSubmit: handleSubmitChat, watch } = chatForm; const variables = watch('variables'); const chatStarted = watch('chatStarted'); + const { refresh } = useRefresh(); return ( @@ -86,6 +88,7 @@ const VariableInput = ({ })} value={variables[item.key]} onchange={(e) => { + refresh(); setValue(`variables.${item.key}`, e); }} /> diff --git a/projects/app/src/components/ChatBox/index.tsx b/projects/app/src/components/ChatBox/index.tsx index 521ff6a021b5..8e0e24957726 100644 --- a/projects/app/src/components/ChatBox/index.tsx +++ b/projects/app/src/components/ChatBox/index.tsx @@ -21,7 +21,6 @@ import { getErrText } from '@fastgpt/global/common/error/utils'; import { Box, Flex, Checkbox } from '@chakra-ui/react'; import { EventNameEnum, eventBus } from '@/web/common/utils/eventbus'; import { chats2GPTMessages } from '@fastgpt/global/core/chat/adapt'; -import { StoreNodeItemType } from '@fastgpt/global/core/workflow/type/index.d'; import { VariableInputEnum } from '@fastgpt/global/core/workflow/constants'; import { DispatchNodeResponseKeyEnum } from '@fastgpt/global/core/workflow/runtime/constants'; import { useForm } from 'react-hook-form'; diff --git a/projects/app/src/components/core/chat/appConfig/InputGuideConfig.tsx b/projects/app/src/components/core/app/InputGuideConfig.tsx similarity index 99% rename from projects/app/src/components/core/chat/appConfig/InputGuideConfig.tsx rename to projects/app/src/components/core/app/InputGuideConfig.tsx index bc41831effec..b84ba7e99382 100644 --- a/projects/app/src/components/core/chat/appConfig/InputGuideConfig.tsx +++ b/projects/app/src/components/core/app/InputGuideConfig.tsx @@ -37,6 +37,7 @@ import { useRequest2 } from '@fastgpt/web/hooks/useRequest'; import { useRequest } from 'ahooks'; import HighlightText from '@fastgpt/web/components/common/String/HighlightText'; import { defaultChatInputGuideConfig } from '@fastgpt/global/core/app/constants'; +import ChatFunctionTip from './Tip'; const csvTemplate = `"第一列内容" "只会将第一列内容导入,其余列会被忽略" @@ -86,7 +87,7 @@ const InputGuideConfig = ({ {chatT('Input guide')} - + diff --git a/projects/app/src/components/core/app/QGSwitch.tsx b/projects/app/src/components/core/app/QGSwitch.tsx index cf4d02e8727f..0d2ca8cde3f5 100644 --- a/projects/app/src/components/core/app/QGSwitch.tsx +++ b/projects/app/src/components/core/app/QGSwitch.tsx @@ -1,9 +1,8 @@ import MyIcon from '@fastgpt/web/components/common/Icon'; -import MyTooltip from '@/components/MyTooltip'; -import { QuestionOutlineIcon } from '@chakra-ui/icons'; import { Box, Flex, Switch, type SwitchProps } from '@chakra-ui/react'; import React from 'react'; import { useTranslation } from 'next-i18next'; +import ChatFunctionTip from './Tip'; // question generator switch const QGSwitch = (props: SwitchProps) => { @@ -12,9 +11,7 @@ const QGSwitch = (props: SwitchProps) => { {t('core.app.Question Guide')} - - - + diff --git a/projects/app/src/components/core/app/ScheduledTriggerConfig.tsx b/projects/app/src/components/core/app/ScheduledTriggerConfig.tsx index a7bd47dbe20c..7917dd258a4a 100644 --- a/projects/app/src/components/core/app/ScheduledTriggerConfig.tsx +++ b/projects/app/src/components/core/app/ScheduledTriggerConfig.tsx @@ -8,7 +8,6 @@ import { AppScheduledTriggerConfigType } from '@fastgpt/global/core/app/type'; import MyModal from '@fastgpt/web/components/common/MyModal'; import dynamic from 'next/dynamic'; import type { MultipleSelectProps } from '@fastgpt/web/components/common/MySelect/type.d'; -import { useForm } from 'react-hook-form'; import { cronParser2Fields } from '@fastgpt/global/common/string/time'; import TimezoneSelect from '@fastgpt/web/components/common/MySelect/TimezoneSelect'; diff --git a/projects/app/src/components/core/app/TTSSelect.tsx b/projects/app/src/components/core/app/TTSSelect.tsx index 1089799d5739..e2c09dac40f4 100644 --- a/projects/app/src/components/core/app/TTSSelect.tsx +++ b/projects/app/src/components/core/app/TTSSelect.tsx @@ -1,6 +1,5 @@ import MyIcon from '@fastgpt/web/components/common/Icon'; import MyTooltip from '@/components/MyTooltip'; -import { QuestionOutlineIcon } from '@chakra-ui/icons'; import { Box, Button, Flex, ModalBody, useDisclosure, Image } from '@chakra-ui/react'; import React, { useCallback, useMemo } from 'react'; import { useTranslation } from 'next-i18next'; @@ -12,6 +11,7 @@ import MyModal from '@fastgpt/web/components/common/MyModal'; import MySlider from '@/components/Slider'; import MySelect from '@fastgpt/web/components/common/MySelect'; import { defaultTTSConfig } from '@fastgpt/global/core/app/constants'; +import ChatFunctionTip from './Tip'; const TTSSelect = ({ value = defaultTTSConfig, @@ -82,9 +82,7 @@ const TTSSelect = ({ {t('core.app.TTS')} - - - +