From 34c48e8c0b46f0dd381dd4b4a228fbf59813fdff Mon Sep 17 00:00:00 2001 From: archer <545436317@qq.com> Date: Fri, 12 Dec 2025 00:06:48 +0800 Subject: [PATCH] perf: rewrite type with zod --- .../core/app/workflow/inteactive/SKILL.md | 4 +- packages/global/common/parentFolder/type.ts | 2 +- packages/global/common/secret/type.d.ts | 6 - packages/global/common/secret/type.ts | 10 + .../global/common/system/types/index.d.ts | 2 +- packages/global/core/ai/constants.ts | 61 ++++ packages/global/core/ai/model.d.ts | 87 ------ packages/global/core/ai/model.ts | 164 +++++++---- packages/global/core/ai/prompt/AIChat.ts | 2 +- .../global/core/ai/{type.d.ts => type.ts} | 10 +- packages/global/core/app/agent/type.ts | 6 - packages/global/core/app/controller.d.ts | 10 +- packages/global/core/app/formEdit/type.ts | 61 ++++ packages/global/core/app/jsonschema.ts | 55 ++-- .../global/core/app/tool/httpTool/type.d.ts | 14 - .../global/core/app/tool/httpTool/type.ts | 43 +++ .../global/core/app/tool/httpTool/utils.ts | 3 +- .../global/core/app/tool/mcpTool/type.d.ts | 19 -- packages/global/core/app/tool/mcpTool/type.ts | 25 ++ packages/global/core/app/type.d.ts | 274 ------------------ packages/global/core/app/type.ts | 228 +++++++++++++++ packages/global/core/app/utils.ts | 12 +- packages/global/core/app/version.d.ts | 8 +- packages/global/core/chat/adapt.ts | 2 +- packages/global/core/chat/type.ts | 6 +- .../global/core/dataset/training/utils.ts | 2 +- packages/global/core/dataset/type.d.ts | 2 +- .../global/core/plugin/admin/tool/type.ts | 44 +-- packages/global/core/plugin/tool/type.ts | 60 ++-- packages/global/core/workflow/constants.ts | 7 - .../workflow/runtime/{type.d.ts => type.ts} | 26 +- .../global/core/workflow/runtime/utils.ts | 6 +- .../global/core/workflow/template/output.ts | 2 +- .../template/system/assignedAnswer.ts | 2 +- .../core/workflow/template/system/comment.ts | 2 +- .../template/system/customFeedback.ts | 2 +- .../workflow/template/system/datasetConcat.ts | 2 +- .../core/workflow/template/system/http468.ts | 2 +- .../template/system/interactive/type.ts | 219 ++++++++------ .../template/system/interactive/userSelect.ts | 2 +- .../core/workflow/template/system/laf.ts | 2 +- .../template/system/loop/loopStart.ts | 2 +- .../workflow/template/system/pluginConfig.ts | 2 +- .../template/system/queryExtension.ts | 2 +- .../workflow/template/system/systemConfig.ts | 2 +- .../workflow/template/system/textEditor.ts | 2 +- .../template/system/variableUpdate/index.tsx | 2 +- .../workflow/template/system/workflowStart.ts | 2 +- packages/global/core/workflow/type/edge.d.ts | 12 - packages/global/core/workflow/type/edge.ts | 16 + packages/global/core/workflow/type/index.d.ts | 64 ---- packages/global/core/workflow/type/index.ts | 54 ++++ packages/global/core/workflow/type/io.d.ts | 141 --------- packages/global/core/workflow/type/io.ts | 165 +++++++++++ packages/global/core/workflow/type/node.d.ts | 194 ------------- packages/global/core/workflow/type/node.ts | 212 ++++++++++++++ packages/global/core/workflow/utils.ts | 6 +- .../openapi/core/plugin/marketplace/api.ts | 18 +- .../support/wallet/discountCoupon/api.ts | 26 +- packages/global/support/outLink/type.d.ts | 2 +- packages/global/support/user/type.ts | 2 +- .../common/s3/sources/helperbot/index.ts | 2 +- .../service/common/vectorDB/controller.ts | 2 +- .../service/core/ai/audio/transcriptions.ts | 2 +- packages/service/core/ai/config/utils.ts | 4 +- packages/service/core/ai/embedding/index.ts | 2 +- .../core/ai/functions/createQuestionGuide.ts | 2 +- .../service/core/ai/llm/compress/index.ts | 2 +- .../service/core/ai/llm/compress/prompt.ts | 2 +- packages/service/core/ai/llm/request.ts | 2 +- packages/service/core/ai/llm/utils.ts | 2 +- packages/service/core/ai/model.ts | 2 +- packages/service/core/ai/rerank/index.ts | 2 +- .../service/core/ai/{type.d.ts => type.ts} | 5 +- packages/service/core/ai/utils.ts | 2 +- packages/service/core/app/controller.ts | 6 +- packages/service/core/app/http.ts | 2 +- packages/service/core/app/mcp.ts | 4 +- packages/service/core/app/schema.ts | 2 +- packages/service/core/app/tool/controller.ts | 2 +- .../service/core/app/version/controller.ts | 6 +- .../service/core/dataset/search/controller.ts | 2 +- .../dispatch/ai/agent/sub/model/index.ts | 2 +- .../dispatch/ai/agent/sub/plan/index.ts | 5 +- .../service/core/workflow/dispatch/ai/chat.ts | 4 +- .../workflow/dispatch/ai/classifyQuestion.ts | 3 +- .../core/workflow/dispatch/ai/extract.ts | 2 +- .../core/workflow/dispatch/ai/tool/type.ts | 2 +- .../core/workflow/dispatch/child/runApp.ts | 4 +- .../core/workflow/dispatch/child/runTool.ts | 2 +- .../core/workflow/dispatch/dataset/search.ts | 2 +- .../service/core/workflow/dispatch/index.ts | 2 +- .../workflow/dispatch/plugin/runOutput.ts | 2 +- .../service/core/workflow/dispatch/type.ts | 2 +- .../service/core/workflow/dispatch/utils.ts | 4 +- .../service/support/permission/app/auth.ts | 2 +- packages/service/type.d.ts | 2 +- pnpm-lock.yaml | 2 +- .../src/components/PromptTemplate/index.tsx | 2 +- .../app/src/components/common/folder/Path.tsx | 7 +- .../core/ai/AISettingModal/index.tsx | 4 +- .../components/core/ai/ModelTable/index.tsx | 2 +- .../core/ai/SettingLLMModel/index.tsx | 2 +- .../core/app/DatasetParamsModal.tsx | 2 +- .../src/components/core/app/FileSelect.tsx | 2 +- .../components/core/app/InputGuideConfig.tsx | 2 +- .../app/src/components/core/app/QGConfig.tsx | 2 +- .../app/src/components/core/app/TTSSelect.tsx | 2 +- .../src/components/core/app/VariableEdit.tsx | 2 +- .../core/app/VariableEditModal/index.tsx | 2 +- .../src/components/core/app/WhisperConfig.tsx | 2 +- .../components/core/dataset/SelectModal.tsx | 10 +- .../app/src/global/core/api/datasetReq.d.ts | 5 +- projects/app/src/global/core/app/api.d.ts | 22 +- projects/app/src/global/core/chat/api.d.ts | 2 +- .../app/src/global/core/workflow/api.d.ts | 4 +- .../account/model/AddModelBox.tsx | 2 +- .../model/Channel/EditChannelModal.tsx | 2 +- .../account/model/ModelConfigTable.tsx | 2 +- .../app/detail/Edit/ChatAgent/ChatTest.tsx | 2 +- .../app/detail/Edit/ChatAgent/Edit.tsx | 4 +- .../app/detail/Edit/ChatAgent/EditForm.tsx | 7 +- .../Edit/ChatAgent/SkillEdit/ChatTest.tsx | 3 +- .../Edit/ChatAgent/SkillEdit/EditForm.tsx | 16 +- .../detail/Edit/ChatAgent/SkillEdit/Row.tsx | 2 +- .../Edit/ChatAgent/hooks/useSkillManager.tsx | 2 +- .../app/detail/Edit/ChatAgent/utils.ts | 10 +- .../app/detail/Edit/FormComponent/AppCard.tsx | 5 +- .../detail/Edit/FormComponent/ChatTest.tsx | 2 +- .../app/detail/Edit/FormComponent/Header.tsx | 7 +- .../FormComponent/ToolSelector/ToolSelect.tsx | 10 +- .../ToolSelector/ToolSelectModal.tsx | 7 +- .../app/detail/Edit/FormComponent/type.d.ts | 3 +- .../Edit/FormComponent/useSnapshots.tsx | 2 +- .../app/detail/Edit/HTTPTools/AppCard.tsx | 4 +- .../app/detail/Edit/HTTPTools/ChatTest.tsx | 2 +- .../app/detail/Edit/HTTPTools/Edit.tsx | 2 +- .../app/detail/Edit/HTTPTools/EditForm.tsx | 2 +- .../app/detail/Edit/HTTPTools/Header.tsx | 5 +- .../detail/Edit/HTTPTools/ManualToolModal.tsx | 2 +- .../app/detail/Edit/MCPTools/AppCard.tsx | 4 +- .../app/detail/Edit/MCPTools/Header.tsx | 5 +- .../app/detail/Edit/SimpleApp/Edit.tsx | 2 +- .../app/detail/Edit/SimpleApp/EditForm.tsx | 6 +- .../app/detail/Edit/SimpleApp/utils.ts | 8 +- .../detail/Edit/component/ConfigToolModal.tsx | 1 - .../app/detail/ExportConfigPopover.tsx | 3 +- .../pageComponents/app/detail/InfoModal.tsx | 4 +- .../WorkflowComponents/Flow/ChatTest.tsx | 2 +- .../Flow/NodeTemplatesModal.tsx | 2 +- .../Flow/components/ButtonEdge.tsx | 8 +- .../Flow/components/NodeTemplates/header.tsx | 2 +- .../detail/WorkflowComponents/Flow/index.tsx | 2 +- .../Flow/nodes/NodeAnswer.tsx | 2 +- .../Flow/nodes/NodeCQNode.tsx | 4 +- .../Flow/nodes/NodeCode/index.tsx | 4 +- .../Flow/nodes/NodeDatasetConcat.tsx | 4 +- .../Flow/nodes/NodeEmpty.tsx | 2 +- .../Flow/nodes/NodeExtract/index.tsx | 4 +- .../Flow/nodes/NodeHttp/CurlImportModal.tsx | 2 +- .../Flow/nodes/NodeHttp/index.tsx | 4 +- .../WorkflowComponents/Flow/nodes/NodeLaf.tsx | 2 +- .../nodes/NodePluginIO/InputTypeConfig.tsx | 5 +- .../nodes/NodePluginIO/NodePluginConfig.tsx | 2 +- .../Flow/nodes/NodePluginIO/PluginInput.tsx | 4 +- .../Flow/nodes/NodePluginIO/PluginOutput.tsx | 2 +- .../Flow/nodes/NodeSimple.tsx | 2 +- .../Flow/nodes/NodeSystemConfig.tsx | 2 +- .../Flow/nodes/NodeToolCall.tsx | 2 +- .../Flow/nodes/NodeUserSelect.tsx | 4 +- .../Flow/nodes/NodeWorkflowStart.tsx | 2 +- .../Flow/nodes/render/NodeCard.tsx | 5 +- .../render/RenderDebug/NodeDebugResponse.tsx | 10 +- .../Flow/nodes/render/RenderInput/Label.tsx | 2 +- .../Flow/nodes/render/RenderInput/index.tsx | 2 +- .../RenderInput/templates/SelectDataset.tsx | 4 +- .../RenderInput/templates/SettingLLMModel.tsx | 2 +- .../Flow/nodes/render/RenderInput/type.d.ts | 2 +- .../nodes/render/RenderOutput/CatchError.tsx | 2 +- .../render/RenderOutput/DynamicOutputs.tsx | 2 +- .../Flow/nodes/render/RenderOutput/Label.tsx | 2 +- .../Flow/nodes/render/RenderOutput/index.tsx | 2 +- .../Flow/nodes/render/RenderOutput/type.d.ts | 2 +- .../render/RenderToolInput/EditFieldModal.tsx | 2 +- .../nodes/render/RenderToolInput/index.tsx | 2 +- .../context/workflowDebugContext.tsx | 3 +- .../app/detail/WorkflowComponents/utils.ts | 2 +- .../components/QuickCreateDatasetModal.tsx | 3 +- .../AddFavouriteAppModal.tsx | 3 +- .../HomepageSetting/AddQuickAppModal.tsx | 3 +- .../ChatSetting/HomepageSetting/index.tsx | 2 +- .../chat/ChatSetting/ToolSelectModal.tsx | 4 +- .../dashboard/agent/TemplateCreatePanel.tsx | 8 +- .../dataset/detail/Info/index.tsx | 2 +- .../pageComponents/dataset/detail/Test.tsx | 2 +- projects/app/src/pages/api/admin/initv4141.ts | 4 +- projects/app/src/pages/api/admin/initv4820.ts | 2 +- .../app/src/pages/api/core/ai/model/list.ts | 2 +- .../app/src/pages/api/core/ai/model/test.ts | 2 +- .../pages/api/core/ai/model/updateDefault.ts | 2 +- .../src/pages/api/core/ai/optimizePrompt.ts | 2 +- projects/app/src/pages/api/core/app/create.ts | 16 +- .../pages/api/core/app/httpTools/runTool.ts | 2 +- .../pages/api/core/app/httpTools/update.ts | 2 +- .../src/pages/api/core/app/template/list.ts | 4 +- .../pages/api/core/app/tool/getPreviewNode.ts | 2 +- .../core/app/tool/getSystemToolTemplates.ts | 2 +- .../api/core/dataset/collection/update.ts | 4 +- .../pages/api/core/dataset/createWithFiles.ts | 5 +- .../app/src/pages/api/v1/chat/completions.ts | 6 +- .../app/src/pages/api/v2/chat/completions.ts | 6 +- projects/app/src/pages/chat/share.tsx | 4 +- .../pages/dashboard/templateMarket/index.tsx | 16 +- projects/app/src/service/core/app/workflow.ts | 2 +- .../service/core/dataset/queues/generateQA.ts | 4 +- projects/app/src/service/support/mcp/utils.ts | 4 +- projects/app/src/types/app.d.ts | 8 +- projects/app/src/types/index.d.ts | 2 +- .../src/web/common/system/useSystemStore.ts | 4 +- projects/app/src/web/common/system/utils.ts | 5 +- projects/app/src/web/common/utils/voice.ts | 2 +- projects/app/src/web/core/app/api.ts | 2 +- projects/app/src/web/core/app/constants.ts | 2 +- projects/app/src/web/core/app/templates.ts | 8 +- projects/app/src/web/core/app/utils.ts | 9 +- projects/app/src/web/core/chat/utils.ts | 2 +- projects/app/src/web/core/dataset/api.ts | 4 +- .../dataset/components/SelectCollections.tsx | 7 +- .../app/src/web/core/dataset/constants.ts | 2 +- projects/app/src/web/core/workflow/adapt.ts | 2 +- projects/app/src/web/core/workflow/utils.ts | 5 +- .../support/user/team/org/hooks/useOrg.tsx | 8 +- .../detail/WorkflowComponents/utils.test.ts | 2 +- projects/app/test/web/core/app/utils.test.ts | 2 +- test/setupModels.ts | 2 +- 235 files changed, 1605 insertions(+), 1443 deletions(-) delete mode 100644 packages/global/common/secret/type.d.ts create mode 100644 packages/global/common/secret/type.ts delete mode 100644 packages/global/core/ai/model.d.ts rename packages/global/core/ai/{type.d.ts => type.ts} (88%) delete mode 100644 packages/global/core/app/agent/type.ts create mode 100644 packages/global/core/app/formEdit/type.ts delete mode 100644 packages/global/core/app/tool/httpTool/type.d.ts create mode 100644 packages/global/core/app/tool/httpTool/type.ts delete mode 100644 packages/global/core/app/tool/mcpTool/type.d.ts create mode 100644 packages/global/core/app/tool/mcpTool/type.ts delete mode 100644 packages/global/core/app/type.d.ts create mode 100644 packages/global/core/app/type.ts rename packages/global/core/workflow/runtime/{type.d.ts => type.ts} (91%) delete mode 100644 packages/global/core/workflow/type/edge.d.ts create mode 100644 packages/global/core/workflow/type/edge.ts delete mode 100644 packages/global/core/workflow/type/index.d.ts create mode 100644 packages/global/core/workflow/type/index.ts delete mode 100644 packages/global/core/workflow/type/io.d.ts create mode 100644 packages/global/core/workflow/type/io.ts delete mode 100644 packages/global/core/workflow/type/node.d.ts create mode 100644 packages/global/core/workflow/type/node.ts rename packages/service/core/ai/{type.d.ts => type.ts} (90%) diff --git a/.claude/skills/core/app/workflow/inteactive/SKILL.md b/.claude/skills/core/app/workflow/inteactive/SKILL.md index 6652163ba..f3b25cd93 100644 --- a/.claude/skills/core/app/workflow/inteactive/SKILL.md +++ b/.claude/skills/core/app/workflow/inteactive/SKILL.md @@ -313,12 +313,12 @@ import React, { useMemo } from 'react'; import { type NodeProps } from 'reactflow'; import { Box, Button } from '@chakra-ui/react'; import NodeCard from './render/NodeCard'; -import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node.d'; +import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node'; import Container from '../components/Container'; import RenderInput from './render/RenderInput'; import { NodeInputKeyEnum } from '@fastgpt/global/core/workflow/constants'; import { useTranslation } from 'next-i18next'; -import { type FlowNodeInputItemType } from '@fastgpt/global/core/workflow/type/io.d'; +import { type FlowNodeInputItemType } from '@fastgpt/global/core/workflow/type/io'; import { useContextSelector } from 'use-context-selector'; import IOTitle from '../components/IOTitle'; import RenderOutput from './render/RenderOutput'; diff --git a/packages/global/common/parentFolder/type.ts b/packages/global/common/parentFolder/type.ts index 801d2b966..3b29cc462 100644 --- a/packages/global/common/parentFolder/type.ts +++ b/packages/global/common/parentFolder/type.ts @@ -9,7 +9,7 @@ export type GetPathProps = { }; export type ParentTreePathItemType = { - parentId: string; + parentId: ParentIdType; parentName: string; }; diff --git a/packages/global/common/secret/type.d.ts b/packages/global/common/secret/type.d.ts deleted file mode 100644 index 2a3d1ff02..000000000 --- a/packages/global/common/secret/type.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export type SecretValueType = { - value: string; - secret: string; -}; - -export type StoreSecretValueType = Record; diff --git a/packages/global/common/secret/type.ts b/packages/global/common/secret/type.ts new file mode 100644 index 000000000..b274201b0 --- /dev/null +++ b/packages/global/common/secret/type.ts @@ -0,0 +1,10 @@ +import z from 'zod'; + +export const SecretValueTypeSchema = z.object({ + value: z.string(), + secret: z.string() +}); +export type SecretValueType = z.infer; + +export const StoreSecretValueTypeSchema = z.record(z.string(), SecretValueTypeSchema); +export type StoreSecretValueType = z.infer; diff --git a/packages/global/common/system/types/index.d.ts b/packages/global/common/system/types/index.d.ts index 0ec10272f..b53e440f0 100644 --- a/packages/global/common/system/types/index.d.ts +++ b/packages/global/common/system/types/index.d.ts @@ -8,7 +8,7 @@ import type { AudioSpeechModels, STTModelType, RerankModelItemType -} from '../../../core/ai/model.d'; +} from '../../../core/ai/model'; import { SubTypeEnum } from '../../../support/wallet/sub/constants'; export type NavbarItemType = { diff --git a/packages/global/core/ai/constants.ts b/packages/global/core/ai/constants.ts index 358a66118..a5fb54896 100644 --- a/packages/global/core/ai/constants.ts +++ b/packages/global/core/ai/constants.ts @@ -1,5 +1,6 @@ import { i18nT } from '../../../web/i18n/utils'; import type { CompletionUsage } from './type'; +import type { LLMModelItemType, EmbeddingModelItemType, STTModelType } from './model'; export const getLLMDefaultUsage = (): CompletionUsage => { return { @@ -9,6 +10,66 @@ export const getLLMDefaultUsage = (): CompletionUsage => { }; }; +export enum ModelTypeEnum { + llm = 'llm', + embedding = 'embedding', + tts = 'tts', + stt = 'stt', + rerank = 'rerank' +} + +export const defaultQAModels: LLMModelItemType[] = [ + { + type: ModelTypeEnum.llm, + provider: 'OpenAI', + model: 'gpt-5', + name: 'gpt-5', + maxContext: 16000, + maxResponse: 16000, + quoteMaxToken: 13000, + maxTemperature: 1.2, + charsPointsPrice: 0, + censor: false, + vision: true, + datasetProcess: true, + toolChoice: true, + functionCall: false, + defaultSystemChatPrompt: '', + defaultConfig: {} + } +]; + +export const defaultVectorModels: EmbeddingModelItemType[] = [ + { + type: ModelTypeEnum.embedding, + provider: 'OpenAI', + model: 'text-embedding-3-small', + name: 'Embedding-2', + charsPointsPrice: 0, + defaultToken: 500, + maxToken: 3000, + weight: 100 + } +]; + +export const defaultSTTModels: STTModelType[] = [ + { + type: ModelTypeEnum.stt, + provider: 'OpenAI', + model: 'whisper-1', + name: 'whisper-1', + charsPointsPrice: 0 + } +]; + +export const modelTypeList = [ + { label: i18nT('common:model.type.chat'), value: ModelTypeEnum.llm }, + { label: i18nT('common:model.type.embedding'), value: ModelTypeEnum.embedding }, + { label: i18nT('common:model.type.tts'), value: ModelTypeEnum.tts }, + { label: i18nT('common:model.type.stt'), value: ModelTypeEnum.stt }, + { label: i18nT('common:model.type.reRank'), value: ModelTypeEnum.rerank } +]; + export enum ChatCompletionRequestMessageRoleEnum { 'System' = 'system', 'User' = 'user', diff --git a/packages/global/core/ai/model.d.ts b/packages/global/core/ai/model.d.ts deleted file mode 100644 index fe9a81f6b..000000000 --- a/packages/global/core/ai/model.d.ts +++ /dev/null @@ -1,87 +0,0 @@ -import type { ModelTypeEnum } from './model'; - -type PriceType = { - charsPointsPrice?: number; // 1k chars=n points; 60s=n points; - - // If inputPrice is set, the input-output charging scheme is adopted - inputPrice?: number; // 1k tokens=n points - outputPrice?: number; // 1k tokens=n points -}; -type BaseModelItemType = { - provider: string; - model: string; - name: string; - avatar?: string; // model icon, from provider - - isActive?: boolean; - isCustom?: boolean; - isDefault?: boolean; - isDefaultDatasetTextModel?: boolean; - isDefaultDatasetImageModel?: boolean; - - // If has requestUrl, it will request the model directly - requestUrl?: string; - requestAuth?: string; -}; - -export type LLMModelItemType = PriceType & - BaseModelItemType & { - type: ModelTypeEnum.llm; - // Model params - maxContext: number; - maxResponse: number; - quoteMaxToken: number; - maxTemperature?: number; - - showTopP?: boolean; - responseFormatList?: string[]; - showStopSign?: boolean; - - censor?: boolean; - vision?: boolean; - reasoning?: boolean; - - // diff function model - datasetProcess?: boolean; // dataset - usedInClassify?: boolean; // classify - usedInExtractFields?: boolean; // extract fields - usedInToolCall?: boolean; // tool call - useInEvaluation?: boolean; // evaluation - - functionCall: boolean; - toolChoice: boolean; - - defaultSystemChatPrompt?: string; - defaultConfig?: Record; - fieldMap?: Record; - }; - -export type EmbeddingModelItemType = PriceType & - BaseModelItemType & { - type: ModelTypeEnum.embedding; - defaultToken: number; // split text default token - maxToken: number; // model max token - weight: number; // training weight - hidden?: boolean; // Disallow creation - normalization?: boolean; // normalization processing - batchSize?: number; - defaultConfig?: Record; // post request config - dbConfig?: Record; // Custom parameters for storage - queryConfig?: Record; // Custom parameters for query - }; - -export type RerankModelItemType = PriceType & - BaseModelItemType & { - type: ModelTypeEnum.rerank; - }; - -export type TTSModelType = PriceType & - BaseModelItemType & { - type: ModelTypeEnum.tts; - voices: { label: string; value: string }[]; - }; - -export type STTModelType = PriceType & - BaseModelItemType & { - type: ModelTypeEnum.stt; - }; diff --git a/packages/global/core/ai/model.ts b/packages/global/core/ai/model.ts index 766026cf2..c64f3398e 100644 --- a/packages/global/core/ai/model.ts +++ b/packages/global/core/ai/model.ts @@ -1,62 +1,112 @@ -import { i18nT } from '../../../web/i18n/utils'; -import type { LLMModelItemType, STTModelType, EmbeddingModelItemType } from './model.d'; +import { ModelTypeEnum } from './constants'; +import z from 'zod'; -export enum ModelTypeEnum { - llm = 'llm', - embedding = 'embedding', - tts = 'tts', - stt = 'stt', - rerank = 'rerank' -} +const PriceTypeSchema = z.object({ + charsPointsPrice: z.number().optional(), // 1k chars=n points; 60s=n points; + // If inputPrice is set, the input-output charging scheme is adopted + inputPrice: z.number().optional(), // 1k tokens=n points + outputPrice: z.number().optional() // 1k tokens=n points +}); +type PriceType = z.infer; -export const defaultQAModels: LLMModelItemType[] = [ - { - type: ModelTypeEnum.llm, - provider: 'OpenAI', - model: 'gpt-5', - name: 'gpt-5', - maxContext: 16000, - maxResponse: 16000, - quoteMaxToken: 13000, - maxTemperature: 1.2, - charsPointsPrice: 0, - censor: false, - vision: true, - datasetProcess: true, - toolChoice: true, - functionCall: false, - defaultSystemChatPrompt: '', - defaultConfig: {} - } -]; +const BaseModelItemSchema = z.object({ + provider: z.string(), + model: z.string(), + name: z.string(), + avatar: z.string().optional(), // model icon, from provider -export const defaultVectorModels: EmbeddingModelItemType[] = [ - { - type: ModelTypeEnum.embedding, - provider: 'OpenAI', - model: 'text-embedding-3-small', - name: 'Embedding-2', - charsPointsPrice: 0, - defaultToken: 500, - maxToken: 3000, - weight: 100 - } -]; + isActive: z.boolean().optional(), + isCustom: z.boolean().optional(), + isDefault: z.boolean().optional(), + isDefaultDatasetTextModel: z.boolean().optional(), + isDefaultDatasetImageModel: z.boolean().optional(), -export const defaultSTTModels: STTModelType[] = [ - { - type: ModelTypeEnum.stt, - provider: 'OpenAI', - model: 'whisper-1', - name: 'whisper-1', - charsPointsPrice: 0 - } -]; + // If has requestUrl, it will request the model directly + requestUrl: z.string().optional(), + requestAuth: z.string().optional() +}); +type BaseModelItemType = z.infer; -export const modelTypeList = [ - { label: i18nT('common:model.type.chat'), value: ModelTypeEnum.llm }, - { label: i18nT('common:model.type.embedding'), value: ModelTypeEnum.embedding }, - { label: i18nT('common:model.type.tts'), value: ModelTypeEnum.tts }, - { label: i18nT('common:model.type.stt'), value: ModelTypeEnum.stt }, - { label: i18nT('common:model.type.reRank'), value: ModelTypeEnum.rerank } -]; +export const LLMModelItemSchema = PriceTypeSchema.and(BaseModelItemSchema).and( + z.object({ + type: z.literal(ModelTypeEnum.llm), + // Model params + maxContext: z.number(), + maxResponse: z.number(), + quoteMaxToken: z.number(), + maxTemperature: z.number().optional(), + + showTopP: z.boolean().optional(), + responseFormatList: z.array(z.string()).optional(), + showStopSign: z.boolean().optional(), + + censor: z.boolean().optional(), + vision: z.boolean().optional(), + reasoning: z.boolean().optional(), + + // diff function model + datasetProcess: z.boolean().optional(), // dataset + usedInClassify: z.boolean().optional(), // classify + usedInExtractFields: z.boolean().optional(), // extract fields + usedInToolCall: z.boolean().optional(), // tool call + useInEvaluation: z.boolean().optional(), // evaluation + + functionCall: z.boolean(), + toolChoice: z.boolean(), + + defaultSystemChatPrompt: z.string().optional(), + defaultConfig: z.record(z.string(), z.any()).optional(), + fieldMap: z.record(z.string(), z.string()).optional() + }) +); +export type LLMModelItemType = z.infer; + +export const EmbeddingModelItemSchema = PriceTypeSchema.and(BaseModelItemSchema).and( + z.object({ + type: z.literal(ModelTypeEnum.embedding), + defaultToken: z.number(), // split text default token + maxToken: z.number(), // model max token + weight: z.number(), // training weight + hidden: z.boolean().optional(), // Disallow creation + normalization: z.boolean().optional(), // normalization processing + batchSize: z.number().optional(), // batch request size + defaultConfig: z.record(z.string(), z.any()).optional(), // post request config + dbConfig: z.record(z.string(), z.any()).optional(), // Custom parameters for storage + queryConfig: z.record(z.string(), z.any()).optional() // Custom parameters for query + }) +); +export type EmbeddingModelItemType = PriceType & + BaseModelItemType & { + type: ModelTypeEnum.embedding; + defaultToken: number; // split text default token + maxToken: number; // model max token + weight: number; // training weight + hidden?: boolean; // Disallow creation + normalization?: boolean; // normalization processing + batchSize?: number; + defaultConfig?: Record; // post request config + dbConfig?: Record; // Custom parameters for storage + queryConfig?: Record; // Custom parameters for query + }; + +export const RerankModelItemSchema = PriceTypeSchema.and(BaseModelItemSchema).and( + z.object({ + type: z.literal(ModelTypeEnum.rerank) + }) +); +export type RerankModelItemType = z.infer; + +export const TTSModelItemSchema = PriceTypeSchema.and(BaseModelItemSchema).and( + z.object({ + type: z.literal(ModelTypeEnum.tts), + voices: z.array(z.object({ label: z.string(), value: z.string() })) + }) +); +export type TTSModelType = z.infer; + +export const STTModelItemSchema = PriceTypeSchema.and(BaseModelItemSchema).and( + z.object({ + type: z.literal(ModelTypeEnum.stt) + }) +); +export type STTModelType = z.infer; diff --git a/packages/global/core/ai/prompt/AIChat.ts b/packages/global/core/ai/prompt/AIChat.ts index 6bec26cf6..9bdd0aec1 100644 --- a/packages/global/core/ai/prompt/AIChat.ts +++ b/packages/global/core/ai/prompt/AIChat.ts @@ -1,4 +1,4 @@ -import { type PromptTemplateItem } from '../type.d'; +import { type PromptTemplateItem } from '../type'; import { i18nT } from '../../../../web/i18n/utils'; import { getPromptByVersion } from './utils'; diff --git a/packages/global/core/ai/type.d.ts b/packages/global/core/ai/type.ts similarity index 88% rename from packages/global/core/ai/type.d.ts rename to packages/global/core/ai/type.ts index cd83ad5d9..9fee60ba2 100644 --- a/packages/global/core/ai/type.d.ts +++ b/packages/global/core/ai/type.ts @@ -1,14 +1,12 @@ import openai from 'openai'; import type { ChatCompletionMessageToolCall, - ChatCompletionMessageParam as SdkChatCompletionMessageParam, + ChatCompletionMessageParam as OpenaiChatCompletionMessageParam, ChatCompletionContentPart as SdkChatCompletionContentPart, ChatCompletionUserMessageParam as SdkChatCompletionUserMessageParam, ChatCompletionToolMessageParam as SdkChatCompletionToolMessageParam, - ChatCompletionAssistantMessageParam as SdkChatCompletionAssistantMessageParam, - ChatCompletionTool + ChatCompletionAssistantMessageParam as SdkChatCompletionAssistantMessageParam } from 'openai/resources'; -import { ChatMessageTypeEnum } from './constants'; import type { WorkflowInteractiveResponseType } from '../workflow/template/system/interactive/type'; import type { Stream } from 'openai/streaming'; export * from 'openai/resources'; @@ -24,7 +22,7 @@ export type ChatCompletionContentPartFile = { export type ChatCompletionContentPart = | (SdkChatCompletionContentPart & { key?: string }) | ChatCompletionContentPartFile; -type CustomChatCompletionUserMessageParam = Omit & { +type CustomChatCompletionUserMessageParam = Omit & { role: 'user'; content: string | Array; }; @@ -52,7 +50,7 @@ export type ChatCompletionMessageParam = ( dataId?: string; hideInUI?: boolean; }; -export type SdkChatCompletionMessageParam = SdkChatCompletionMessageParam; +export type SdkChatCompletionMessageParam = OpenaiChatCompletionMessageParam; /* ToolChoice and functionCall extension */ export type ChatCompletionAssistantToolParam = { diff --git a/packages/global/core/app/agent/type.ts b/packages/global/core/app/agent/type.ts deleted file mode 100644 index 2e2324937..000000000 --- a/packages/global/core/app/agent/type.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { ObjectIdSchema } from '../../../../global/common/type/mongo'; -import { z } from 'zod'; - -export type AgentSubAppItemType = {}; - -/* ===== Dataset ==== */ diff --git a/packages/global/core/app/controller.d.ts b/packages/global/core/app/controller.d.ts index c7051b221..0bcd169fb 100644 --- a/packages/global/core/app/controller.d.ts +++ b/packages/global/core/app/controller.d.ts @@ -1,5 +1,5 @@ import type { ParentIdType } from 'common/parentFolder/type'; -import type { AppSchema } from './type'; +import type { AppSchemaType } from './type'; import type { AppTypeEnum } from './constants'; export type CreateAppProps = { @@ -8,16 +8,16 @@ export type CreateAppProps = { avatar?: string; intro?: string; type?: AppTypeEnum; - modules: AppSchema['modules']; - edges?: AppSchema['edges']; + modules: AppSchemaType['modules']; + edges?: AppSchemaType['edges']; }; export type CreateHttpPluginChildrenPros = Omit & { parentId: ParentIdType; name: string; intro: string; avatar: string; - modules: AppSchema['modules']; - edges: AppSchema['edges']; + modules: AppSchemaType['modules']; + edges: AppSchemaType['edges']; pluginData: { pluginUniId: string; }; diff --git a/packages/global/core/app/formEdit/type.ts b/packages/global/core/app/formEdit/type.ts new file mode 100644 index 000000000..524f6dfb0 --- /dev/null +++ b/packages/global/core/app/formEdit/type.ts @@ -0,0 +1,61 @@ +import { SelectedDatasetSchema } from '../../workflow/type/io'; +import { z } from 'zod'; +import { + AppChatConfigTypeSchema, + AppDatasetSearchParamsTypeSchema, + AppFileSelectConfigTypeSchema +} from '../type'; +import { FlowNodeTemplateTypeSchema } from '../../workflow/type/node'; +import { NodeInputKeyEnum } from '../../workflow/constants'; + +export type AgentSubAppItemType = {}; + +/* ===== Tool ===== */ +export const SelectedToolItemTypeSchema = FlowNodeTemplateTypeSchema.and( + z.object({ + configStatus: z.enum(['active', 'waitingForConfig', 'invalid']).optional() + }) +); +export type SelectedToolItemType = z.infer; + +/* ===== skill ===== */ +export const SkillEditTypeSchema = z.object({ + id: z.string(), + name: z.string(), + description: z.string(), + prompt: z.string(), + dataset: z.object({ + list: z.array(SelectedDatasetSchema) + }), + selectedTools: z.array(SelectedToolItemTypeSchema), + fileSelectConfig: AppFileSelectConfigTypeSchema +}); +export type SkillEditType = z.infer; + +export const AppFormEditFormV1TypeSchema = z.object({ + aiSettings: z.object({ + [NodeInputKeyEnum.aiModel]: z.string(), + [NodeInputKeyEnum.aiSystemPrompt]: z.string().optional(), + [NodeInputKeyEnum.aiRole]: z.string().optional(), + [NodeInputKeyEnum.aiTaskObject]: z.string().optional(), + + [NodeInputKeyEnum.aiChatTemperature]: z.number().optional(), + [NodeInputKeyEnum.aiChatMaxToken]: z.number().optional(), + [NodeInputKeyEnum.aiChatIsResponseText]: z.boolean(), + maxHistories: z.int().min(0).max(100), + [NodeInputKeyEnum.aiChatReasoning]: z.boolean().optional(), + [NodeInputKeyEnum.aiChatTopP]: z.number().optional(), + [NodeInputKeyEnum.aiChatStopSign]: z.string().optional(), + [NodeInputKeyEnum.aiChatResponseFormat]: z.string().optional(), + [NodeInputKeyEnum.aiChatJsonSchema]: z.string().optional() + }), + dataset: AppDatasetSearchParamsTypeSchema.and( + z.object({ + datasets: z.array(SelectedDatasetSchema) + }) + ), + selectedTools: z.array(SelectedToolItemTypeSchema), + skills: z.array(SkillEditTypeSchema), + chatConfig: AppChatConfigTypeSchema +}); +export type AppFormEditFormType = z.infer; diff --git a/packages/global/core/app/jsonschema.ts b/packages/global/core/app/jsonschema.ts index 53426efed..2ff23c65c 100644 --- a/packages/global/core/app/jsonschema.ts +++ b/packages/global/core/app/jsonschema.ts @@ -6,27 +6,42 @@ import yaml from 'js-yaml'; import type { OpenAPIV3 } from 'openapi-types'; import type { OpenApiJsonSchema } from './tool/httpTool/type'; import { i18nT } from '../../../web/i18n/utils'; +import z from 'zod'; -type SchemaInputValueType = 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object'; -export type JsonSchemaPropertiesItemType = { - description?: string; - 'x-tool-description'?: string; - type: SchemaInputValueType; - enum?: string[]; - minimum?: number; - maximum?: number; - items?: { type: SchemaInputValueType }; -}; -export type JSONSchemaInputType = { - type: SchemaInputValueType; - properties?: Record; - required?: string[]; -}; -export type JSONSchemaOutputType = { - type: SchemaInputValueType; - properties?: Record; - required?: string[]; -}; +const SchemaInputValueTypeSchema = z.enum([ + 'string', + 'number', + 'integer', + 'boolean', + 'array', + 'object' +]); +type SchemaInputValueType = z.infer; + +export const JsonSchemaPropertiesItemSchema = z.object({ + description: z.string().optional(), + 'x-tool-description': z.string().optional(), + type: SchemaInputValueTypeSchema, + enum: z.array(z.string()).optional(), + minimum: z.number().optional(), + maximum: z.number().optional(), + items: z.object({ type: SchemaInputValueTypeSchema }).optional() +}); +export type JsonSchemaPropertiesItemType = z.infer; + +export const JSONSchemaInputTypeSchema = z.object({ + type: SchemaInputValueTypeSchema, + properties: z.record(z.string(), JsonSchemaPropertiesItemSchema).optional(), + required: z.array(z.string()).optional() +}); +export type JSONSchemaInputType = z.infer; + +export const JSONSchemaOutputTypeSchema = z.object({ + type: SchemaInputValueTypeSchema, + properties: z.record(z.string(), JsonSchemaPropertiesItemSchema).optional(), + required: z.array(z.string()).optional() +}); +export type JSONSchemaOutputType = z.infer; export const getNodeInputTypeFromSchemaInputType = ({ type, diff --git a/packages/global/core/app/tool/httpTool/type.d.ts b/packages/global/core/app/tool/httpTool/type.d.ts deleted file mode 100644 index be3dd4eb9..000000000 --- a/packages/global/core/app/tool/httpTool/type.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -type PathDataType = { - name: string; - description: string; - method: string; - path: string; - params: any[]; - request: any; - response: any; -}; - -export type OpenApiJsonSchema = { - pathData: PathDataType[]; - serverPath: string; -}; diff --git a/packages/global/core/app/tool/httpTool/type.ts b/packages/global/core/app/tool/httpTool/type.ts new file mode 100644 index 000000000..47c8ece64 --- /dev/null +++ b/packages/global/core/app/tool/httpTool/type.ts @@ -0,0 +1,43 @@ +import { StoreSecretValueTypeSchema } from '../../../../common/secret/type'; +import { JSONSchemaInputTypeSchema, JSONSchemaOutputTypeSchema } from '../../jsonschema'; +import { ContentTypes } from '../../../workflow/constants'; +import z from 'zod'; + +const PathDataTypeSchema = z.object({ + name: z.string(), + description: z.string(), + method: z.string(), + path: z.string(), + params: z.array(z.any()), + request: z.any(), + response: z.any() +}); +export type PathDataType = z.infer; + +export const OpenApiJsonSchemaSchema = z.object({ + pathData: z.array(PathDataTypeSchema), + serverPath: z.string() +}); +export type OpenApiJsonSchema = z.infer; + +export const HttpToolConfigTypeSchema = z.object({ + name: z.string(), + description: z.string(), + inputSchema: JSONSchemaInputTypeSchema, + outputSchema: JSONSchemaOutputTypeSchema, + path: z.string(), + method: z.string(), + + // manual + staticParams: z.array(z.object({ key: z.string(), value: z.string() })).optional(), + staticHeaders: z.array(z.object({ key: z.string(), value: z.string() })).optional(), + staticBody: z + .object({ + type: z.enum(ContentTypes), + content: z.string().optional(), + formData: z.array(z.object({ key: z.string(), value: z.string() })).optional() + }) + .optional(), + headerSecret: StoreSecretValueTypeSchema.optional() +}); +export type HttpToolConfigType = z.infer; diff --git a/packages/global/core/app/tool/httpTool/utils.ts b/packages/global/core/app/tool/httpTool/utils.ts index 49a9770c1..8be9e4c6c 100644 --- a/packages/global/core/app/tool/httpTool/utils.ts +++ b/packages/global/core/app/tool/httpTool/utils.ts @@ -1,8 +1,7 @@ import { getNanoid } from '../../../../common/string/tools'; -import type { PathDataType } from './type'; +import type { PathDataType, HttpToolConfigType } from './type'; import { type RuntimeNodeItemType } from '../../../workflow/runtime/type'; import { FlowNodeOutputTypeEnum, FlowNodeTypeEnum } from '../../../workflow/node/constant'; -import { type HttpToolConfigType } from '../../type'; import { AppToolSourceEnum } from '../constants'; import { jsonSchema2NodeInput, jsonSchema2NodeOutput } from '../../jsonschema'; import { type StoreSecretValueType } from '../../../../common/secret/type'; diff --git a/packages/global/core/app/tool/mcpTool/type.d.ts b/packages/global/core/app/tool/mcpTool/type.d.ts deleted file mode 100644 index cdea9b0f3..000000000 --- a/packages/global/core/app/tool/mcpTool/type.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -import type { StoreSecretValueType } from '../../../../common/secret/type'; -import type { JSONSchemaInputType } from '../../jsonschema'; - -export type McpToolConfigType = { - name: string; - description: string; - inputSchema: JSONSchemaInputType; -}; - -export type McpToolSetDataType = { - url: string; - headerSecret?: StoreSecretValueType; - toolList: McpToolConfigType[]; -}; - -export type McpToolDataType = McpToolConfigType & { - url: string; - headerSecret?: StoreSecretValueType; -}; diff --git a/packages/global/core/app/tool/mcpTool/type.ts b/packages/global/core/app/tool/mcpTool/type.ts new file mode 100644 index 000000000..9bfde3828 --- /dev/null +++ b/packages/global/core/app/tool/mcpTool/type.ts @@ -0,0 +1,25 @@ +import { SecretValueTypeSchema } from '../../../../common/secret/type'; +import { JSONSchemaInputTypeSchema } from '../../jsonschema'; +import z from 'zod'; + +export const McpToolConfigSchema = z.object({ + name: z.string(), + description: z.string(), + inputSchema: JSONSchemaInputTypeSchema +}); +export type McpToolConfigType = z.infer; + +export const McpToolSetDataTypeSchema = z.object({ + url: z.string(), + headerSecret: SecretValueTypeSchema.optional(), + toolList: z.array(McpToolConfigSchema) +}); +export type McpToolSetDataType = z.infer; + +export const McpToolDataTypeSchema = McpToolConfigSchema.and( + z.object({ + url: z.string(), + headerSecret: SecretValueTypeSchema.optional() + }) +); +export type McpToolDataType = z.infer; diff --git a/packages/global/core/app/type.d.ts b/packages/global/core/app/type.d.ts deleted file mode 100644 index 63113fc9c..000000000 --- a/packages/global/core/app/type.d.ts +++ /dev/null @@ -1,274 +0,0 @@ -import type { FlowNodeTemplateType, StoreNodeItemType } from '../workflow/type/node'; -import type { AppTypeEnum } from './constants'; -import { PermissionTypeEnum } from '../../support/permission/constant'; -import type { - ContentTypes, - NodeInputKeyEnum, - VariableInputEnum, - WorkflowIOValueTypeEnum -} from '../workflow/constants'; -import type { InputComponentPropsType, SelectedDatasetType } from '../workflow/type/io'; -import type { DatasetSearchModeEnum } from '../dataset/constants'; -import { TeamTagSchema as TeamTagsSchemaType } from '@fastgpt/global/support/user/team/type.d'; -import type { StoreEdgeItemType } from '../workflow/type/edge'; -import type { AppPermission } from '../../support/permission/app/controller'; -import type { ParentIdType } from '../../common/parentFolder/type'; -import { FlowNodeInputTypeEnum } from '../../core/workflow/node/constant'; -import type { WorkflowTemplateBasicType } from '@fastgpt/global/core/workflow/type'; -import type { SourceMemberType } from '../../support/user/type'; -import type { JSONSchemaInputType, JSONSchemaOutputType } from './jsonschema'; - -export type AppSchema = { - _id: string; - parentId?: ParentIdType; - teamId: string; - tmbId: string; - type: AppTypeEnum; - version?: 'v1' | 'v2'; - - name: string; - avatar: string; - intro: string; - templateId?: string; // Create by template - - updateTime: Date; - - modules: StoreNodeItemType[]; - edges: StoreEdgeItemType[]; - pluginData?: { - nodeVersion?: string; - pluginUniId?: string; // plugin unique id(plugin name) - apiSchemaStr?: string; // api schema string - customHeaders?: string; - }; - - // App system config - chatConfig: AppChatConfigType; - scheduledTriggerConfig?: AppScheduledTriggerConfigType | null; - scheduledTriggerNextTime?: Date; - - inheritPermission?: boolean; - - // if access the app by favourite or quick - favourite?: boolean; - quick?: boolean; - - /** @deprecated */ - defaultPermission?: number; - /** @deprecated */ - inited?: boolean; - /** @deprecated */ - teamTags: string[]; - - // 软删除字段 - deleteTime?: Date | null; -}; - -export type AppListItemType = { - _id: string; - parentId: ParentIdType; - tmbId: string; - name: string; - avatar: string; - intro: string; - type: AppTypeEnum; - updateTime: Date; - pluginData?: AppSchema['pluginData']; - permission: AppPermission; - inheritPermission?: boolean; - private?: boolean; - sourceMember: SourceMemberType; - hasInteractiveNode?: boolean; -}; - -export type AppDetailType = AppSchema & { - permission: AppPermission; -}; - -export type AppDatasetSearchParamsType = { - searchMode: `${DatasetSearchModeEnum}`; - limit?: number; // limit max tokens - similarity?: number; - embeddingWeight?: number; // embedding weight, fullText weight = 1 - embeddingWeight - - usingReRank?: boolean; - rerankModel?: string; - rerankWeight?: number; - - datasetSearchUsingExtensionQuery?: boolean; - datasetSearchExtensionModel?: string; - datasetSearchExtensionBg?: string; -}; - -/* ===== skill ===== */ -export type SkillEditType = { - id: string; - name: string; - description: string; - prompt: string; - dataset: { - list: SelectedDatasetType[]; - }; - selectedTools: SelectedToolItemType[]; - fileSelectConfig: AppFileSelectConfigType; -}; - -export type SelectedToolItemType = FlowNodeTemplateType & { - configStatus?: 'active' | 'waitingForConfig' | 'invalid'; -}; -export type AppFormEditFormType = { - // templateId: string; - aiSettings: { - [NodeInputKeyEnum.aiModel]: string; - [NodeInputKeyEnum.aiSystemPrompt]?: string | undefined; - [NodeInputKeyEnum.aiRole]?: string | undefined; - [NodeInputKeyEnum.aiTaskObject]?: string | undefined; - - [NodeInputKeyEnum.aiChatTemperature]?: number; - [NodeInputKeyEnum.aiChatMaxToken]?: number; - [NodeInputKeyEnum.aiChatIsResponseText]: boolean; - maxHistories: number; - [NodeInputKeyEnum.aiChatReasoning]?: boolean; // Is open reasoning mode - [NodeInputKeyEnum.aiChatTopP]?: number; - [NodeInputKeyEnum.aiChatStopSign]?: string; - [NodeInputKeyEnum.aiChatResponseFormat]?: string; - [NodeInputKeyEnum.aiChatJsonSchema]?: string; - }; - dataset: { - datasets: SelectedDatasetType[]; - } & AppDatasetSearchParamsType; - selectedTools: SelectedToolItemType[]; - chatConfig: AppChatConfigType; - skills: SkillEditType[]; -}; - -export type HttpToolConfigType = { - name: string; - description: string; - inputSchema: JSONSchemaInputType; - outputSchema: JSONSchemaOutputType; - path: string; - method: string; - - // manual - staticParams?: Array<{ key: string; value: string }>; - staticHeaders?: Array<{ key: string; value: string }>; - staticBody?: { - type: ContentTypes; - content?: string; - formData?: Array<{ key: string; value: string }>; - }; - headerSecret?: StoreSecretValueType; -}; - -/* app chat config type */ -export type AppChatConfigType = { - welcomeText?: string; - variables?: VariableItemType[]; - autoExecute?: AppAutoExecuteConfigType; - questionGuide?: AppQGConfigType; - ttsConfig?: AppTTSConfigType; - whisperConfig?: AppWhisperConfigType; - scheduledTriggerConfig?: AppScheduledTriggerConfigType; - chatInputGuide?: ChatInputGuideConfigType; - fileSelectConfig?: AppFileSelectConfigType; - - // plugin - instruction?: string; -}; -export type SettingAIDataType = { - model: string; - temperature?: number; - maxToken?: number; - isResponseAnswerText?: boolean; - maxHistories?: number; - [NodeInputKeyEnum.aiChatVision]?: boolean; // Is open vision mode - [NodeInputKeyEnum.aiChatReasoning]?: boolean; // Is open reasoning mode - [NodeInputKeyEnum.aiChatTopP]?: number; - [NodeInputKeyEnum.aiChatStopSign]?: string; - [NodeInputKeyEnum.aiChatResponseFormat]?: string; - [NodeInputKeyEnum.aiChatJsonSchema]?: string; -}; - -// variable -export type VariableItemType = AppFileSelectConfigType & - InputComponentPropsType & { - type: VariableInputEnum; - description: string; - }; -// tts -export type AppTTSConfigType = { - type: 'none' | 'web' | 'model'; - model?: string; - voice?: string; - speed?: number; -}; -// whisper -export type AppWhisperConfigType = { - open: boolean; - autoSend: boolean; - autoTTSResponse: boolean; -}; - -// question guide -export type AppQGConfigType = { - open: boolean; - model?: string; - customPrompt?: string; -}; - -// question guide text -export type ChatInputGuideConfigType = { - open: boolean; - customUrl: string; -}; -// interval timer -export type AppScheduledTriggerConfigType = { - cronString: string; - timezone: string; - defaultPrompt: string; -}; -// auto execute -export type AppAutoExecuteConfigType = { - open: boolean; - defaultPrompt: string; -}; -// File -export type AppFileSelectConfigType = { - maxFiles?: number; - canSelectFile?: boolean; - customPdfParse?: boolean; - canSelectImg?: boolean; - canSelectVideo?: boolean; - canSelectAudio?: boolean; - canSelectCustomFileExtension?: boolean; - customFileExtensionList?: string[]; -}; - -export type AppTemplateSchemaType = { - templateId: string; - name: string; - intro: string; - avatar: string; - tags: string[]; - type: string; - author?: string; - isActive?: boolean; - isPromoted?: boolean; - recommendText?: string; - userGuide?: { - type: 'markdown' | 'link'; - content?: string; - link?: string; - }; - isQuickTemplate?: boolean; - order?: number; - // TODO: 对于建议应用,是另一个格式 - workflow: WorkflowTemplateBasicType; -}; - -export type TemplateTypeSchemaType = { - typeName: string; - typeId: string; - typeOrder: number; -}; diff --git a/packages/global/core/app/type.ts b/packages/global/core/app/type.ts new file mode 100644 index 000000000..ca2e839f2 --- /dev/null +++ b/packages/global/core/app/type.ts @@ -0,0 +1,228 @@ +import { StoreNodeItemTypeSchema } from '../workflow/type/node'; +import { AppTypeEnum } from './constants'; +import type { NodeInputKeyEnum } from '../workflow/constants'; +import { VariableInputEnum } from '../workflow/constants'; +import { InputComponentPropsTypeSchema } from '../workflow/type/io'; +import { DatasetSearchModeEnum } from '../dataset/constants'; +import { StoreEdgeItemTypeSchema } from '../workflow/type/edge'; +import type { AppPermission } from '../../support/permission/app/controller'; +import { ParentIdSchema, type ParentIdType } from '../../common/parentFolder/type'; +import type { WorkflowTemplateBasicType } from '../workflow/type'; +import type { SourceMemberType } from '../../support/user/type'; +import z from 'zod'; +import { ObjectIdSchema } from '../../common/type/mongo'; + +/* app chat config type */ +// File +export const AppFileSelectConfigTypeSchema = z.object({ + maxFiles: z.number().optional(), + canSelectFile: z.boolean().optional(), + customPdfParse: z.boolean().optional(), + canSelectImg: z.boolean().optional(), + canSelectVideo: z.boolean().optional(), + canSelectAudio: z.boolean().optional(), + canSelectCustomFileExtension: z.boolean().optional(), + customFileExtensionList: z.array(z.string()).optional() +}); +export type AppFileSelectConfigType = z.infer; + +// variable +export const VariableItemTypeSchema = AppFileSelectConfigTypeSchema.and( + InputComponentPropsTypeSchema +).and( + z.object({ + type: z.enum(VariableInputEnum), + description: z.string() + }) +); +export type VariableItemType = z.infer; + +// tts +export const AppTTSConfigTypeSchema = z.object({ + type: z.enum(['none', 'web', 'model']), + model: z.string().optional(), + voice: z.string().optional(), + speed: z.number().optional() +}); +export type AppTTSConfigType = z.infer; + +// whisper +export const AppWhisperConfigTypeSchema = z.object({ + open: z.boolean(), + autoSend: z.boolean(), + autoTTSResponse: z.boolean() +}); +export type AppWhisperConfigType = z.infer; + +// question guide +export const AppQGConfigTypeSchema = z.object({ + open: z.boolean(), + model: z.string().optional(), + customPrompt: z.string().optional() +}); +export type AppQGConfigType = z.infer; + +// question guide text +export const ChatInputGuideConfigTypeSchema = z.object({ + open: z.boolean(), + customUrl: z.string() +}); +export type ChatInputGuideConfigType = z.infer; + +// interval timer +export const AppScheduledTriggerConfigTypeSchema = z.object({ + cronString: z.string(), + timezone: z.string(), + defaultPrompt: z.string() +}); +export type AppScheduledTriggerConfigType = z.infer; + +// auto execute +export const AppAutoExecuteConfigTypeSchema = z.object({ + open: z.boolean(), + defaultPrompt: z.string() +}); +export type AppAutoExecuteConfigType = z.infer; + +export const AppChatConfigTypeSchema = z.object({ + welcomeText: z.string().optional(), + variables: z.array(VariableItemTypeSchema).optional(), + autoExecute: AppAutoExecuteConfigTypeSchema.optional(), + questionGuide: AppQGConfigTypeSchema.optional(), + ttsConfig: AppTTSConfigTypeSchema.optional(), + whisperConfig: AppWhisperConfigTypeSchema.optional(), + scheduledTriggerConfig: AppScheduledTriggerConfigTypeSchema.optional(), + chatInputGuide: ChatInputGuideConfigTypeSchema.optional(), + fileSelectConfig: AppFileSelectConfigTypeSchema.optional(), + instruction: z.string().optional() +}); +export type AppChatConfigType = z.infer; + +// Mongo Collection +export const AppSchemaTypeSchema = z.object({ + _id: ObjectIdSchema, + parentId: ParentIdSchema.optional(), + teamId: z.string(), + tmbId: z.string(), + type: z.enum(AppTypeEnum), + version: z.enum(['v1', 'v2']).optional(), + + name: z.string(), + avatar: z.string(), + intro: z.string(), + templateId: z.string().optional(), + + updateTime: z.date(), + + modules: z.array(StoreNodeItemTypeSchema), + edges: z.array(StoreEdgeItemTypeSchema), + pluginData: z + .object({ + nodeVersion: z.string().optional(), + pluginUniId: z.string().optional(), // plugin unique id(plugin name) + apiSchemaStr: z.string().optional(), // api schema string + customHeaders: z.string().optional() + }) + .optional(), + + // App system config + chatConfig: AppChatConfigTypeSchema, + scheduledTriggerConfig: AppScheduledTriggerConfigTypeSchema.optional(), + scheduledTriggerNextTime: z.date().optional(), + + inheritPermission: z.boolean().optional(), + + // if access the app by favourite or quick + favourite: z.boolean().optional(), + quick: z.boolean().optional(), + + // 软删除字段 + deleteTime: z.date().nullish(), + + /** @deprecated */ + defaultPermission: z.number().optional(), + /** @deprecated */ + inited: z.boolean().optional(), + /** @deprecated */ + teamTags: z.array(z.string()).optional() +}); +export type AppSchemaType = z.infer; + +export type AppListItemType = { + _id: string; + parentId: ParentIdType; + tmbId: string; + name: string; + avatar: string; + intro: string; + type: AppTypeEnum; + updateTime: Date; + pluginData?: AppSchemaType['pluginData']; + permission: AppPermission; + inheritPermission?: boolean; + private?: boolean; + sourceMember: SourceMemberType; + hasInteractiveNode?: boolean; +}; + +export type AppDetailType = AppSchemaType & { + permission: AppPermission; +}; + +export const AppDatasetSearchParamsTypeSchema = z.object({ + searchMode: z.enum(DatasetSearchModeEnum), + limit: z.number().optional(), // limit max tokens + similarity: z.number().optional(), + embeddingWeight: z.number().optional(), // embedding weight, fullText weight = 1 - embeddingWeight + + usingReRank: z.boolean().optional(), + rerankModel: z.string().optional(), + rerankWeight: z.number().optional(), + + datasetSearchUsingExtensionQuery: z.boolean().optional(), + datasetSearchExtensionModel: z.string().optional(), + datasetSearchExtensionBg: z.string().optional() +}); +export type AppDatasetSearchParamsType = z.infer; + +export type SettingAIDataType = { + model: string; + temperature?: number; + maxToken?: number; + isResponseAnswerText?: boolean; + maxHistories?: number; + [NodeInputKeyEnum.aiChatVision]?: boolean; // Is open vision mode + [NodeInputKeyEnum.aiChatReasoning]?: boolean; // Is open reasoning mode + [NodeInputKeyEnum.aiChatTopP]?: number; + [NodeInputKeyEnum.aiChatStopSign]?: string; + [NodeInputKeyEnum.aiChatResponseFormat]?: string; + [NodeInputKeyEnum.aiChatJsonSchema]?: string; +}; + +export type AppTemplateSchemaType = { + templateId: string; + name: string; + intro: string; + avatar: string; + tags: string[]; + type: string; + author?: string; + isActive?: boolean; + isPromoted?: boolean; + recommendText?: string; + userGuide?: { + type: 'markdown' | 'link'; + content?: string; + link?: string; + }; + isQuickTemplate?: boolean; + order?: number; + // TODO: 对于建议应用,是另一个格式 + workflow: WorkflowTemplateBasicType; +}; + +export type TemplateTypeSchemaType = { + typeName: string; + typeId: string; + typeOrder: number; +}; diff --git a/packages/global/core/app/utils.ts b/packages/global/core/app/utils.ts index a51f9d163..6b0033bde 100644 --- a/packages/global/core/app/utils.ts +++ b/packages/global/core/app/utils.ts @@ -1,4 +1,4 @@ -import type { AppFormEditFormType } from '../app/type'; +import type { AppFormEditFormType } from './formEdit/type'; import { DatasetSearchModeEnum } from '../dataset/constants'; import { type WorkflowTemplateBasicType } from '../workflow/type'; import { AppTypeEnum } from './constants'; @@ -9,12 +9,8 @@ export const getDefaultAppForm = (): AppFormEditFormType => { return { aiSettings: { model: '', - systemPrompt: '', - temperature: 0, isResponseAnswerText: true, - maxHistories: 6, - maxToken: 4000, - aiChatReasoning: true + maxHistories: 6 }, dataset: { datasets: [], @@ -28,8 +24,8 @@ export const getDefaultAppForm = (): AppFormEditFormType => { datasetSearchExtensionBg: '' }, selectedTools: [], - chatConfig: {}, - skills: [] + skills: [], + chatConfig: {} }; }; diff --git a/packages/global/core/app/version.d.ts b/packages/global/core/app/version.d.ts index 669ed98eb..bdb864854 100644 --- a/packages/global/core/app/version.d.ts +++ b/packages/global/core/app/version.d.ts @@ -1,6 +1,6 @@ import { TeamMemberStatusEnum } from 'support/user/team/constant'; import { StoreEdgeItemType } from '../workflow/type/edge'; -import type { AppSchema } from './type'; +import type { AppSchemaType } from './type'; import { AppChatConfigType } from './type'; import type { SourceMemberType } from 'support/user/type'; @@ -8,9 +8,9 @@ export type AppVersionSchemaType = { _id: string; appId: string; time: Date; - nodes: AppSchema['modules']; - edges: AppSchema['edges']; - chatConfig: AppSchema['chatConfig']; + nodes: AppSchemaType['modules']; + edges: AppSchemaType['edges']; + chatConfig: AppSchemaType['chatConfig']; isPublish?: boolean; isAutoSave?: boolean; versionName: string; diff --git a/packages/global/core/chat/adapt.ts b/packages/global/core/chat/adapt.ts index 686ac2362..d5b6370b9 100644 --- a/packages/global/core/chat/adapt.ts +++ b/packages/global/core/chat/adapt.ts @@ -16,7 +16,7 @@ import type { ChatCompletionMessageParam, ChatCompletionMessageToolCall, ChatCompletionToolMessageParam -} from '../../core/ai/type.d'; +} from '../../core/ai/type'; import { ChatCompletionRequestMessageRoleEnum } from '../../core/ai/constants'; export const GPT2Chat = { diff --git a/packages/global/core/chat/type.ts b/packages/global/core/chat/type.ts index 33f02880a..c57598b8d 100644 --- a/packages/global/core/chat/type.ts +++ b/packages/global/core/chat/type.ts @@ -4,7 +4,7 @@ import { ChatFileTypeEnum, ChatRoleEnum } from './constants'; import type { FlowNodeTypeEnum } from '../workflow/node/constant'; import { NodeOutputKeyEnum } from '../workflow/constants'; import type { DispatchNodeResponseKeyEnum } from '../workflow/runtime/constants'; -import type { AppSchema, VariableItemType } from '../app/type'; +import type { AppSchemaType, VariableItemType } from '../app/type'; import type { DispatchNodeResponseType } from '../workflow/runtime/type'; import type { ChatBoxInputType } from '../../../../projects/app/src/components/core/chat/ChatContainer/ChatBox/type'; import type { WorkflowInteractiveResponseType } from '../workflow/template/system/interactive/type'; @@ -61,7 +61,7 @@ export type ChatSchemaType = { }; export type ChatWithAppSchema = Omit & { - appId: AppSchema; + appId: AppSchemaType; }; /* --------- chat item ---------- */ @@ -216,7 +216,7 @@ export type ChatItemResponseSchemaType = { /* --------- team chat --------- */ export type ChatAppListSchema = { - apps: AppSchema[]; + apps: AppSchemaType[]; teamInfo: any; uid?: string; }; diff --git a/packages/global/core/dataset/training/utils.ts b/packages/global/core/dataset/training/utils.ts index 670ee0dec..96d0ce4cf 100644 --- a/packages/global/core/dataset/training/utils.ts +++ b/packages/global/core/dataset/training/utils.ts @@ -1,5 +1,5 @@ import { getEmbeddingModel } from '../../../../service/core/ai/model'; -import { type EmbeddingModelItemType, type LLMModelItemType } from '../../../core/ai/model.d'; +import { type EmbeddingModelItemType, type LLMModelItemType } from '../../../core/ai/model'; import { ChunkSettingModeEnum, DataChunkSplitModeEnum, diff --git a/packages/global/core/dataset/type.d.ts b/packages/global/core/dataset/type.d.ts index de9b0adbd..d7921fccc 100644 --- a/packages/global/core/dataset/type.d.ts +++ b/packages/global/core/dataset/type.d.ts @@ -1,4 +1,4 @@ -import type { LLMModelItemType, EmbeddingModelItemType } from '../../core/ai/model.d'; +import type { LLMModelItemType, EmbeddingModelItemType } from '../../core/ai/model'; import { PermissionTypeEnum } from '../../support/permission/constant'; import { PushDatasetDataChunkProps } from './api'; import type { diff --git a/packages/global/core/plugin/admin/tool/type.ts b/packages/global/core/plugin/admin/tool/type.ts index 724299f03..468839f47 100644 --- a/packages/global/core/plugin/admin/tool/type.ts +++ b/packages/global/core/plugin/admin/tool/type.ts @@ -2,23 +2,25 @@ import { ParentIdSchema } from '../../../../common/parentFolder/type'; import { SystemToolBasicConfigSchema, ToolSecretInputItemSchema } from '../../tool/type'; import z from 'zod'; -export const AdminSystemToolListItemSchema = SystemToolBasicConfigSchema.extend({ - id: z.string(), - parentId: ParentIdSchema, - name: z.string(), - intro: z.string().optional(), - author: z.string().optional(), - avatar: z.string().optional(), - tags: z.array(z.string()).nullish(), +export const AdminSystemToolListItemSchema = SystemToolBasicConfigSchema.merge( + z.object({ + id: z.string(), + parentId: ParentIdSchema, + name: z.string(), + intro: z.string().optional(), + author: z.string().optional(), + avatar: z.string().optional(), + tags: z.array(z.string()).nullish(), - hasSystemSecret: z.boolean().optional(), + hasSystemSecret: z.boolean().optional(), - // App tool - associatedPluginId: z.string().optional(), + // App tool + associatedPluginId: z.string().optional(), - isFolder: z.boolean().optional(), - hasSecretInput: z.boolean() -}); + isFolder: z.boolean().optional(), + hasSecretInput: z.boolean() + }) +); export type AdminSystemToolListItemType = z.infer; // Child config schema for update @@ -29,10 +31,12 @@ export const ToolsetChildSchema = z.object({ }); export const AdminSystemToolDetailSchema = AdminSystemToolListItemSchema.omit({ hasSecretInput: true -}).extend({ - userGuide: z.string().nullish(), - inputList: z.array(ToolSecretInputItemSchema).optional(), - inputListVal: z.record(z.string(), z.any()).nullish(), - childTools: z.array(ToolsetChildSchema).optional() -}); +}).and( + z.object({ + userGuide: z.string().nullish(), + inputList: z.array(ToolSecretInputItemSchema).optional(), + inputListVal: z.record(z.string(), z.any()).nullish(), + childTools: z.array(ToolsetChildSchema).optional() + }) +); export type AdminSystemToolDetailType = z.infer; diff --git a/packages/global/core/plugin/tool/type.ts b/packages/global/core/plugin/tool/type.ts index 1ea135a79..56476dfd8 100644 --- a/packages/global/core/plugin/tool/type.ts +++ b/packages/global/core/plugin/tool/type.ts @@ -12,36 +12,38 @@ export const SystemToolBasicConfigSchema = z.object({ pluginOrder: z.number().optional() }); -export const SystemPluginToolCollectionSchema = SystemToolBasicConfigSchema.extend({ - pluginId: z.string(), - customConfig: z - .object({ - name: z.string(), - avatar: z.string().optional(), - intro: z.string().optional(), - toolDescription: z.string().optional(), - version: z.string(), - tags: z.array(z.string()).nullish(), - associatedPluginId: z.string().optional(), - userGuide: z.string().optional(), - author: z.string().optional() - }) - .optional(), - inputListVal: z.record(z.string(), z.any()).optional(), - - // @deprecated - isActive: z.boolean().optional(), - inputConfig: z - .array( - z.object({ - key: z.string(), - label: z.string(), - description: z.string().optional(), - value: z.any().optional() +export const SystemPluginToolCollectionSchema = SystemToolBasicConfigSchema.and( + z.object({ + pluginId: z.string(), + customConfig: z + .object({ + name: z.string(), + avatar: z.string().optional(), + intro: z.string().optional(), + toolDescription: z.string().optional(), + version: z.string(), + tags: z.array(z.string()).nullish(), + associatedPluginId: z.string().optional(), + userGuide: z.string().optional(), + author: z.string().optional() }) - ) - .optional() -}); + .optional(), + inputListVal: z.record(z.string(), z.any()).optional(), + + // @deprecated + isActive: z.boolean().optional(), + inputConfig: z + .array( + z.object({ + key: z.string(), + label: z.string(), + description: z.string().optional(), + value: z.any().optional() + }) + ) + .optional() + }) +); export type SystemPluginToolCollectionType = z.infer; // TODO: 移动到 plugin sdk 里 diff --git a/packages/global/core/workflow/constants.ts b/packages/global/core/workflow/constants.ts index bffa95f6d..cfa0ca4a3 100644 --- a/packages/global/core/workflow/constants.ts +++ b/packages/global/core/workflow/constants.ts @@ -453,13 +453,6 @@ export const variableMap: Record = { // Keep backward compatibility export const variableMapGroups = variableConfigs; -/* run time */ -export enum RuntimeEdgeStatusEnum { - 'waiting' = 'waiting', - 'active' = 'active', - 'skipped' = 'skipped' -} - export const VARIABLE_NODE_ID = 'VARIABLE_NODE_ID'; export const DYNAMIC_INPUT_REFERENCE_KEY = 'DYNAMIC_INPUT_REFERENCE_KEY'; diff --git a/packages/global/core/workflow/runtime/type.d.ts b/packages/global/core/workflow/runtime/type.ts similarity index 91% rename from packages/global/core/workflow/runtime/type.d.ts rename to packages/global/core/workflow/runtime/type.ts index 1132153c2..e53382f4f 100644 --- a/packages/global/core/workflow/runtime/type.d.ts +++ b/packages/global/core/workflow/runtime/type.ts @@ -5,25 +5,19 @@ import type { AIChatItemValueItemType, ChatHistoryItemResType } from '../../chat/type'; -import type { FlowNodeInputItemType, FlowNodeOutputItemType } from '../type/io.d'; -import type { NodeToolConfigType, StoreNodeItemType } from '../type/node'; +import type { FlowNodeInputItemType, FlowNodeOutputItemType } from '../type/io'; +import type { StoreNodeItemType } from '../type/node'; import type { DispatchNodeResponseKeyEnum } from './constants'; -import type { StoreEdgeItemType } from '../type/edge'; import type { NodeInputKeyEnum, NodeOutputKeyEnum } from '../constants'; import type { ClassifyQuestionAgentItemType } from '../template/system/classifyQuestion/type'; import type { NextApiResponse } from 'next'; -import { UserModelSchema } from '../../../support/user/type'; -import type { AppSchema } from '../../app/type'; -import { AppDetailType } from '../../app/type'; -import type { RuntimeNodeItemType } from '../runtime/type'; -import type { RuntimeEdgeItemType } from './edge'; +import type { AppSchemaType } from '../../app/type'; +import type { RuntimeEdgeItemType } from '../type/edge'; import type { ReadFileNodeResponse } from '../template/system/readFiles/type'; -import { UserSelectOptionType } from '../template/system/userSelect/type'; import type { WorkflowResponseType } from '../../../../service/core/workflow/dispatch/type'; import type { AiChatQuoteRoleType } from '../template/system/aiChat/type'; import type { OpenaiAccountType } from '../../../support/user/team/type'; -import { LafAccountType } from '../../../support/user/team/type'; -import type { ChatCompletionMessageParam, CompletionFinishReason } from '../../ai/type'; +import type { CompletionFinishReason } from '../../ai/type'; import type { InteractiveNodeResponseType, WorkflowInteractiveResponseType @@ -31,6 +25,10 @@ import type { import type { SearchDataResponseItemType } from '../../dataset/type'; import type { localeType } from '../../../common/i18n/type'; import { type UserChatItemValueItemType } from '../../chat/type'; +import { z } from 'zod'; +import type { DatasetSearchModeEnum } from '../../dataset/constants'; +import type { ChatRoleEnum } from '../../chat/constants'; +import type { MCPClient } from '../../../../service/core/app/mcp'; export type ExternalProviderType = { openaiAccount?: OpenaiAccountType; @@ -70,7 +68,7 @@ export type ChatDispatchProps = { variables: Record; // global variable cloneVariables: Record; query: UserChatItemValueItemType[]; // trigger query - chatConfig: AppSchema['chatConfig']; + chatConfig: AppSchemaType['chatConfig']; lastInteractive?: WorkflowInteractiveResponseType; // last interactive response stream: boolean; retainDatasetCite?: boolean; @@ -131,10 +129,6 @@ export type RuntimeNodeItemType = { catchError?: boolean; }; -export type RuntimeEdgeItemType = StoreEdgeItemType & { - status: 'waiting' | 'active' | 'skipped'; -}; - export type DispatchNodeResponseType = { // common moduleLogo?: string; diff --git a/packages/global/core/workflow/runtime/utils.ts b/packages/global/core/workflow/runtime/utils.ts index 8a8f6d08b..7776fc4db 100644 --- a/packages/global/core/workflow/runtime/utils.ts +++ b/packages/global/core/workflow/runtime/utils.ts @@ -14,11 +14,11 @@ import { type InteractiveNodeResponseType, type WorkflowInteractiveResponseType } from '../template/system/interactive/type'; -import type { StoreEdgeItemType } from '../type/edge'; +import type { RuntimeEdgeItemType, StoreEdgeItemType } from '../type/edge'; import type { FlowNodeOutputItemType, ReferenceValueType } from '../type/io'; import type { StoreNodeItemType } from '../type/node'; import { isValidReferenceValueFormat } from '../utils'; -import type { RuntimeEdgeItemType, RuntimeNodeItemType } from './type'; +import type { RuntimeNodeItemType } from './type'; import { isSecretValue } from '../../../common/secret/utils'; import { isChildInteractive } from '../template/system/interactive/constants'; @@ -633,7 +633,7 @@ export const textAdaptGptResponse = ({ /* Update runtimeNode's outputs with interactive data from history */ export function rewriteNodeOutputByHistories( runtimeNodes: RuntimeNodeItemType[], - lastInteractive?: InteractiveNodeResponseType + lastInteractive?: WorkflowInteractiveResponseType ) { const interactive = lastInteractive; if (!interactive?.nodeOutputs) { diff --git a/packages/global/core/workflow/template/output.ts b/packages/global/core/workflow/template/output.ts index c86963ad1..0aebb128b 100644 --- a/packages/global/core/workflow/template/output.ts +++ b/packages/global/core/workflow/template/output.ts @@ -1,4 +1,4 @@ -import type { FlowNodeOutputItemType } from '../type/io.d'; +import type { FlowNodeOutputItemType } from '../type/io'; import { NodeOutputKeyEnum } from '../constants'; import { FlowNodeOutputTypeEnum } from '../node/constant'; import { WorkflowIOValueTypeEnum } from '../constants'; diff --git a/packages/global/core/workflow/template/system/assignedAnswer.ts b/packages/global/core/workflow/template/system/assignedAnswer.ts index 48c3f2f1a..d78cf48d3 100644 --- a/packages/global/core/workflow/template/system/assignedAnswer.ts +++ b/packages/global/core/workflow/template/system/assignedAnswer.ts @@ -1,5 +1,5 @@ import { FlowNodeInputTypeEnum, FlowNodeTypeEnum } from '../../node/constant'; -import { type FlowNodeTemplateType } from '../../type/node.d'; +import { type FlowNodeTemplateType } from '../../type/node'; import { WorkflowIOValueTypeEnum, NodeInputKeyEnum, diff --git a/packages/global/core/workflow/template/system/comment.ts b/packages/global/core/workflow/template/system/comment.ts index d3e1a191c..a76a2616b 100644 --- a/packages/global/core/workflow/template/system/comment.ts +++ b/packages/global/core/workflow/template/system/comment.ts @@ -1,5 +1,5 @@ import { FlowNodeTypeEnum } from '../../node/constant'; -import { type FlowNodeTemplateType } from '../../type/node.d'; +import { type FlowNodeTemplateType } from '../../type/node'; import { FlowNodeTemplateTypeEnum, NodeInputKeyEnum, diff --git a/packages/global/core/workflow/template/system/customFeedback.ts b/packages/global/core/workflow/template/system/customFeedback.ts index 88926a6e2..76cf8eba1 100644 --- a/packages/global/core/workflow/template/system/customFeedback.ts +++ b/packages/global/core/workflow/template/system/customFeedback.ts @@ -1,5 +1,5 @@ import { FlowNodeInputTypeEnum, FlowNodeTypeEnum } from '../../node/constant'; -import { type FlowNodeTemplateType } from '../../type/node.d'; +import { type FlowNodeTemplateType } from '../../type/node'; import { WorkflowIOValueTypeEnum, NodeInputKeyEnum, diff --git a/packages/global/core/workflow/template/system/datasetConcat.ts b/packages/global/core/workflow/template/system/datasetConcat.ts index b3b337c5d..5cc4022d0 100644 --- a/packages/global/core/workflow/template/system/datasetConcat.ts +++ b/packages/global/core/workflow/template/system/datasetConcat.ts @@ -12,7 +12,7 @@ import { FlowNodeTemplateTypeEnum } from '../../constants'; import { getNanoid } from '../../../../common/string/tools'; -import { type FlowNodeInputItemType } from '../../type/io.d'; +import { type FlowNodeInputItemType } from '../../type/io'; import { i18nT } from '../../../../../web/i18n/utils'; export const getOneQuoteInputTemplate = ({ diff --git a/packages/global/core/workflow/template/system/http468.ts b/packages/global/core/workflow/template/system/http468.ts index 4728ebf35..d18c8f46f 100644 --- a/packages/global/core/workflow/template/system/http468.ts +++ b/packages/global/core/workflow/template/system/http468.ts @@ -3,7 +3,7 @@ import { FlowNodeOutputTypeEnum, FlowNodeTypeEnum } from '../../node/constant'; -import { type FlowNodeTemplateType } from '../../type/node.d'; +import { type FlowNodeTemplateType } from '../../type/node'; import { WorkflowIOValueTypeEnum, NodeInputKeyEnum, diff --git a/packages/global/core/workflow/template/system/interactive/type.ts b/packages/global/core/workflow/template/system/interactive/type.ts index 4a69a6846..52bda13ed 100644 --- a/packages/global/core/workflow/template/system/interactive/type.ts +++ b/packages/global/core/workflow/template/system/interactive/type.ts @@ -1,31 +1,52 @@ -import type { NodeOutputItemType } from '../../../../chat/type'; -import type { FlowNodeInputTypeEnum } from '../../../../../core/workflow/node/constant'; -import type { WorkflowIOValueTypeEnum } from '../../../../../core/workflow/constants'; +import { NodeOutputItemSchema } from '../../../../chat/type'; +import { FlowNodeInputTypeEnum } from '../../../../../core/workflow/node/constant'; +import { WorkflowIOValueTypeEnum } from '../../../../../core/workflow/constants'; import type { ChatCompletionMessageParam } from '../../../../ai/type'; -import type { AppFileSelectConfigType } from '../../../../app/type'; -import type { RuntimeEdgeItemType } from '../../../type/edge'; +import { AppFileSelectConfigTypeSchema } from '../../../../app/type'; +import { RuntimeEdgeItemTypeSchema } from '../../../type/edge'; +import z from 'zod'; -export type InteractiveBasicType = { - entryNodeIds: string[]; - memoryEdges: RuntimeEdgeItemType[]; - nodeOutputs: NodeOutputItemType[]; - skipNodeQueue?: { id: string; skippedNodeIdList: string[] }[]; // 需要记录目前在 queue 里的节点 +export const InteractiveBasicTypeSchema = z.object({ + entryNodeIds: z.array(z.string()), + memoryEdges: z.array(RuntimeEdgeItemTypeSchema), + nodeOutputs: z.array(NodeOutputItemSchema), + skipNodeQueue: z + .array(z.object({ id: z.string(), skippedNodeIdList: z.array(z.string()) })) + .optional(), // 需要记录目前在 queue 里的节点 + usageId: z.string().optional() +}); +export type InteractiveBasicType = z.infer; - usageId?: string; -}; - -type InteractiveNodeType = { - entryNodeIds?: string[]; - memoryEdges?: RuntimeEdgeItemType[]; - nodeOutputs?: NodeOutputItemType[]; -}; +const InteractiveNodeTypeSchema = z.object({ + entryNodeIds: z.array(z.string()).optional(), + memoryEdges: z.array(RuntimeEdgeItemTypeSchema).optional(), + nodeOutputs: z.array(NodeOutputItemSchema).optional() +}); +export type InteractiveNodeType = z.infer; +export const ChildrenInteractiveSchema = z.object({ + type: z.literal('childrenInteractive'), + params: z.object({ + childrenResponse: z.any() + }) +}); export type ChildrenInteractive = InteractiveNodeType & { type: 'childrenInteractive'; params: { childrenResponse: WorkflowInteractiveResponseType; }; }; + +export const ToolCallChildrenInteractiveSchema = z.object({ + type: z.literal('toolChildrenInteractive'), + params: z.object({ + childrenResponse: z.any(), + toolParams: z.object({ + memoryRequestMessages: z.array(z.any()), // 这轮工具中,产生的新的 messages + toolCallId: z.string() // 记录对应 tool 的id,用于后续交互节点可以替换掉 tool 的 response + }) + }) +}); export type ToolCallChildrenInteractive = InteractiveNodeType & { type: 'toolChildrenInteractive'; params: { @@ -38,6 +59,14 @@ export type ToolCallChildrenInteractive = InteractiveNodeType & { }; // Loop bode +export const LoopInteractiveSchema = z.object({ + type: z.literal('loopInteractive'), + params: z.object({ + loopResult: z.array(z.any()), + childrenResponse: z.any(), + currentIndex: z.number() + }) +}); export type LoopInteractive = InteractiveNodeType & { type: 'loopInteractive'; params: { @@ -48,85 +77,91 @@ export type LoopInteractive = InteractiveNodeType & { }; // Agent Interactive -export type AgentPlanCheckInteractive = InteractiveNodeType & { - type: 'agentPlanCheck'; - params: { - confirmed?: boolean; - }; -}; -export type AgentPlanAskQueryInteractive = InteractiveNodeType & { - type: 'agentPlanAskQuery'; - params: { - content: string; - }; -}; +export const AgentPlanCheckInteractiveSchema = z.object({ + type: z.literal('agentPlanCheck'), + params: z.object({ + confirmed: z.boolean().optional() + }) +}); +export type AgentPlanCheckInteractive = z.infer; -export type UserSelectOptionItemType = { - key: string; - value: string; -}; -export type UserSelectInteractive = InteractiveNodeType & { - type: 'userSelect' | 'agentPlanAskUserSelect'; - params: { - description: string; - userSelectOptions: UserSelectOptionItemType[]; - userSelectedVal?: string; - }; -}; +export const AgentPlanAskQueryInteractiveSchema = z.object({ + type: z.literal('agentPlanAskQuery'), + params: z.object({ + content: z.string() + }) +}); +export type AgentPlanAskQueryInteractive = z.infer; -export type UserInputFormItemType = { - type: FlowNodeInputTypeEnum; - key: string; - label: string; - value: any; - valueType: WorkflowIOValueTypeEnum; - description?: string; - defaultValue?: any; - required: boolean; +// User selector +export const UserSelectOptionItemSchema = z.object({ + key: z.string(), + value: z.string() +}); +export type UserSelectOptionItemType = z.infer; +export const UserSelectInteractiveSchema = z.object({ + type: z.literal('userSelect').or(z.literal('agentPlanAskUserSelect')), + params: z.object({ + description: z.string(), + userSelectOptions: z.array(UserSelectOptionItemSchema), + userSelectedVal: z.string().optional() + }) +}); +export type UserSelectInteractive = z.infer; - // input & textarea - maxLength?: number; +// User input +export const UserInputFormItemSchema = AppFileSelectConfigTypeSchema.extend( + z.object({ + type: z.enum(FlowNodeInputTypeEnum), + key: z.string(), + label: z.string(), + value: z.any(), + valueType: z.enum(WorkflowIOValueTypeEnum), + description: z.string().optional(), + defaultValue: z.any().optional(), + required: z.boolean(), - // password - minLength?: number; - - // numberInput - max?: number; - min?: number; - // select - list?: { label: string; value: string }[]; - - // File - canLocalUpload?: boolean; - canUrlUpload?: boolean; -} & AppFileSelectConfigType; - -export type UserInputInteractive = InteractiveNodeType & { - type: 'userInput' | 'agentPlanAskUserForm'; - params: { - description: string; - inputForm: UserInputFormItemType[]; - submitted?: boolean; - }; -}; + maxLength: z.number().optional(), // input & textarea + minLength: z.number().optional(), // password + max: z.number().optional(), // numberInput + min: z.number().optional(), // numberInput + list: z.array(z.object({ label: z.string(), value: z.string() })).optional() // select + }) +); +export type UserInputFormItemType = z.infer; +export const UserInputInteractiveSchema = z.object({ + type: z.literal('userInput').or(z.literal('agentPlanAskUserForm')), + params: z.object({ + description: z.string(), + inputForm: z.array(UserInputFormItemSchema), + submitted: z.boolean().optional() + }) +}); +export type UserInputInteractive = z.infer; // 欠费暂停交互 -export type PaymentPauseInteractive = InteractiveNodeType & { - type: 'paymentPause'; - params: { - description?: string; - continue?: boolean; - }; -}; +export const PaymentPauseInteractiveSchema = z.object({ + type: z.literal('paymentPause'), + params: z.object({ + description: z.string().optional(), + continue: z.boolean().optional() + }) +}); +export type PaymentPauseInteractive = z.infer; -export type InteractiveNodeResponseType = - | UserSelectInteractive - | UserInputInteractive - | ChildrenInteractive - | ToolCallChildrenInteractive - | LoopInteractive - | PaymentPauseInteractive - | AgentPlanCheckInteractive - | AgentPlanAskQueryInteractive; +export const InteractiveNodeResponseTypeSchema = z.union([ + UserSelectInteractiveSchema, + UserInputInteractiveSchema, + ChildrenInteractiveSchema, + ToolCallChildrenInteractiveSchema, + LoopInteractiveSchema, + PaymentPauseInteractiveSchema, + AgentPlanCheckInteractiveSchema, + AgentPlanAskQueryInteractiveSchema +]); +export type InteractiveNodeResponseType = z.infer; -export type WorkflowInteractiveResponseType = InteractiveBasicType & InteractiveNodeResponseType; +export const WorkflowInteractiveResponseTypeSchema = InteractiveBasicTypeSchema.and( + InteractiveNodeResponseTypeSchema +); +export type WorkflowInteractiveResponseType = z.infer; diff --git a/packages/global/core/workflow/template/system/interactive/userSelect.ts b/packages/global/core/workflow/template/system/interactive/userSelect.ts index f04e1af41..53035273a 100644 --- a/packages/global/core/workflow/template/system/interactive/userSelect.ts +++ b/packages/global/core/workflow/template/system/interactive/userSelect.ts @@ -10,7 +10,7 @@ import { FlowNodeOutputTypeEnum, FlowNodeTypeEnum } from '../../../node/constant'; -import { type FlowNodeTemplateType } from '../../../type/node.d'; +import { type FlowNodeTemplateType } from '../../../type/node'; export const UserSelectNode: FlowNodeTemplateType = { id: FlowNodeTypeEnum.userSelect, diff --git a/packages/global/core/workflow/template/system/laf.ts b/packages/global/core/workflow/template/system/laf.ts index 3b306ab2d..7e4ccfbf6 100644 --- a/packages/global/core/workflow/template/system/laf.ts +++ b/packages/global/core/workflow/template/system/laf.ts @@ -3,7 +3,7 @@ import { FlowNodeOutputTypeEnum, FlowNodeTypeEnum } from '../../node/constant'; -import { type FlowNodeTemplateType } from '../../type/node.d'; +import { type FlowNodeTemplateType } from '../../type/node'; import { WorkflowIOValueTypeEnum, NodeInputKeyEnum, diff --git a/packages/global/core/workflow/template/system/loop/loopStart.ts b/packages/global/core/workflow/template/system/loop/loopStart.ts index 59a4cc0ec..8db2d6dc5 100644 --- a/packages/global/core/workflow/template/system/loop/loopStart.ts +++ b/packages/global/core/workflow/template/system/loop/loopStart.ts @@ -3,7 +3,7 @@ import { FlowNodeOutputTypeEnum, FlowNodeTypeEnum } from '../../../node/constant'; -import { type FlowNodeTemplateType } from '../../../type/node.d'; +import { type FlowNodeTemplateType } from '../../../type/node'; import { FlowNodeTemplateTypeEnum, NodeInputKeyEnum, diff --git a/packages/global/core/workflow/template/system/pluginConfig.ts b/packages/global/core/workflow/template/system/pluginConfig.ts index dceec8926..65464741f 100644 --- a/packages/global/core/workflow/template/system/pluginConfig.ts +++ b/packages/global/core/workflow/template/system/pluginConfig.ts @@ -1,5 +1,5 @@ import { FlowNodeTypeEnum } from '../../node/constant'; -import { type FlowNodeTemplateType } from '../../type/node.d'; +import { type FlowNodeTemplateType } from '../../type/node'; import { FlowNodeTemplateTypeEnum } from '../../constants'; import { i18nT } from '../../../../../web/i18n/utils'; diff --git a/packages/global/core/workflow/template/system/queryExtension.ts b/packages/global/core/workflow/template/system/queryExtension.ts index 01ee258b1..3b19cf3ac 100644 --- a/packages/global/core/workflow/template/system/queryExtension.ts +++ b/packages/global/core/workflow/template/system/queryExtension.ts @@ -3,7 +3,7 @@ import { FlowNodeOutputTypeEnum, FlowNodeTypeEnum } from '../../node/constant'; -import { type FlowNodeTemplateType } from '../../type/node.d'; +import { type FlowNodeTemplateType } from '../../type/node'; import { WorkflowIOValueTypeEnum, NodeInputKeyEnum, diff --git a/packages/global/core/workflow/template/system/systemConfig.ts b/packages/global/core/workflow/template/system/systemConfig.ts index c44a2a130..8dbd2295c 100644 --- a/packages/global/core/workflow/template/system/systemConfig.ts +++ b/packages/global/core/workflow/template/system/systemConfig.ts @@ -1,5 +1,5 @@ import { FlowNodeTypeEnum } from '../../node/constant'; -import { type FlowNodeTemplateType } from '../../type/node.d'; +import { type FlowNodeTemplateType } from '../../type/node'; import { FlowNodeTemplateTypeEnum } from '../../constants'; import { i18nT } from '../../../../../web/i18n/utils'; diff --git a/packages/global/core/workflow/template/system/textEditor.ts b/packages/global/core/workflow/template/system/textEditor.ts index bbc0451f0..46a6d54e3 100644 --- a/packages/global/core/workflow/template/system/textEditor.ts +++ b/packages/global/core/workflow/template/system/textEditor.ts @@ -3,7 +3,7 @@ import { FlowNodeOutputTypeEnum, FlowNodeTypeEnum } from '../../node/constant'; -import { type FlowNodeTemplateType } from '../../type/node.d'; +import { type FlowNodeTemplateType } from '../../type/node'; import { WorkflowIOValueTypeEnum, NodeOutputKeyEnum, diff --git a/packages/global/core/workflow/template/system/variableUpdate/index.tsx b/packages/global/core/workflow/template/system/variableUpdate/index.tsx index 3e46bc33e..c9b82da9a 100644 --- a/packages/global/core/workflow/template/system/variableUpdate/index.tsx +++ b/packages/global/core/workflow/template/system/variableUpdate/index.tsx @@ -1,5 +1,5 @@ import { FlowNodeInputTypeEnum, FlowNodeTypeEnum } from '../../../node/constant'; -import { type FlowNodeTemplateType } from '../../../type/node.d'; +import { type FlowNodeTemplateType } from '../../../type/node'; import { FlowNodeTemplateTypeEnum, NodeInputKeyEnum, diff --git a/packages/global/core/workflow/template/system/workflowStart.ts b/packages/global/core/workflow/template/system/workflowStart.ts index 4a2c9bc7d..f1d9d463e 100644 --- a/packages/global/core/workflow/template/system/workflowStart.ts +++ b/packages/global/core/workflow/template/system/workflowStart.ts @@ -1,5 +1,5 @@ import { FlowNodeOutputTypeEnum, FlowNodeTypeEnum } from '../../node/constant'; -import { type FlowNodeTemplateType } from '../../type/node.d'; +import { type FlowNodeTemplateType } from '../../type/node'; import { WorkflowIOValueTypeEnum, NodeOutputKeyEnum, diff --git a/packages/global/core/workflow/type/edge.d.ts b/packages/global/core/workflow/type/edge.d.ts deleted file mode 100644 index 885759b59..000000000 --- a/packages/global/core/workflow/type/edge.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import type { RuntimeEdgeStatusEnum } from '../constants'; - -export type StoreEdgeItemType = { - source: string; - sourceHandle: string; - target: string; - targetHandle: string; -}; - -export type RuntimeEdgeItemType = StoreEdgeItemType & { - status: `${RuntimeEdgeStatusEnum}`; -}; diff --git a/packages/global/core/workflow/type/edge.ts b/packages/global/core/workflow/type/edge.ts new file mode 100644 index 000000000..08cd09982 --- /dev/null +++ b/packages/global/core/workflow/type/edge.ts @@ -0,0 +1,16 @@ +import { z } from 'zod'; + +export const StoreEdgeItemTypeSchema = z.object({ + source: z.string(), + sourceHandle: z.string(), + target: z.string(), + targetHandle: z.string() +}); +export type StoreEdgeItemType = z.infer; + +export const RuntimeEdgeItemTypeSchema = StoreEdgeItemTypeSchema.and( + z.object({ + status: z.enum(['waiting', 'active', 'skipped']) + }) +); +export type RuntimeEdgeItemType = z.infer; diff --git a/packages/global/core/workflow/type/index.d.ts b/packages/global/core/workflow/type/index.d.ts deleted file mode 100644 index ff8fb0793..000000000 --- a/packages/global/core/workflow/type/index.d.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { FlowNodeTypeEnum } from '../node/constant'; -import { - WorkflowIOValueTypeEnum, - NodeOutputKeyEnum, - FlowNodeTemplateTypeEnum, - VariableInputEnum -} from '../constants'; -import { DispatchNodeResponseKeyEnum } from '../runtime/constants'; -import type { FlowNodeInputItemType, FlowNodeOutputItemType } from './io.d'; -import { CustomInputItemType } from './io.d'; -import { - ChatHistoryItemResType, - ChatItemType, - ChatItemValueItemType, - ToolRunResponseItemType -} from '../../chat/type'; -import { ChatNodeUsageType } from '../../../support/wallet/bill/type'; -import type { StoreEdgeItemType } from './edge'; -import type { AppChatConfigType } from '../../app/type'; -import type { ParentIdType } from 'common/parentFolder/type'; -import type { AppTypeEnum } from 'core/app/constants'; -import type { StoreNodeItemType } from './node'; -import { FlowNodeTemplateType } from './node'; -import type { SecretValueType } from './../../../common/secret/type'; -import type { I18nStringType } from '../../../common/i18n/type'; - -export type WorkflowTemplateBasicType = { - nodes: StoreNodeItemType[]; - edges: StoreEdgeItemType[]; - chatConfig?: AppChatConfigType; -}; -export type WorkflowTemplateType = { - id: string; - parentId?: ParentIdType; - isFolder?: boolean; - - avatar?: string; - name: I18nStringType | string; - intro?: I18nStringType | string; - toolDescription?: string; - - author?: string; - courseUrl?: string; - weight?: number; - - version?: string; - workflow: WorkflowTemplateBasicType; -}; - -// template market -export type TemplateMarketItemType = WorkflowTemplateType & { - tags: string[]; - type: AppTypeEnum.simple | AppTypeEnum.workflow | AppTypeEnum.workflowTool; -}; -// template market list -export type TemplateMarketListItemType = { - id: string; - name: string; - intro?: string; - author?: string; - tags: string[]; - type: AppTypeEnum.simple | AppTypeEnum.workflow | AppTypeEnum.workflowTool; - avatar: string; -}; diff --git a/packages/global/core/workflow/type/index.ts b/packages/global/core/workflow/type/index.ts new file mode 100644 index 000000000..98e20154a --- /dev/null +++ b/packages/global/core/workflow/type/index.ts @@ -0,0 +1,54 @@ +import { StoreEdgeItemTypeSchema } from './edge'; +import { AppChatConfigTypeSchema } from '../../app/type'; +import { ParentIdSchema } from '../../../common/parentFolder/type'; +import { AppTypeEnum } from '../../app/constants'; +import { StoreNodeItemTypeSchema } from './node'; +import { I18nStringSchema } from '../../../common/i18n/type'; +import z from 'zod'; + +export const WorkflowTemplateBasicTypeSchema = z.object({ + nodes: z.array(StoreNodeItemTypeSchema), + edges: z.array(StoreEdgeItemTypeSchema), + chatConfig: AppChatConfigTypeSchema.optional() +}); +export type WorkflowTemplateBasicType = z.infer; + +export const WorkflowTemplateTypeSchema = z.object({ + id: z.string(), + parentId: ParentIdSchema.optional(), + isFolder: z.boolean().optional(), + + avatar: z.string().optional(), + name: z.union([I18nStringSchema, z.string()]), + intro: z.union([I18nStringSchema, z.string()]).optional(), + toolDescription: z.string().optional(), + + author: z.string().optional(), + courseUrl: z.string().optional(), + weight: z.number().optional(), + + version: z.string().optional(), + workflow: WorkflowTemplateBasicTypeSchema +}); +export type WorkflowTemplateType = z.infer; + +// template market +export const TemplateMarketItemTypeSchema = WorkflowTemplateTypeSchema.and( + z.object({ + tags: z.array(z.string()), + type: z.enum([AppTypeEnum.simple, AppTypeEnum.workflow, AppTypeEnum.workflowTool]) + }) +); +export type TemplateMarketItemType = z.infer; + +// template market list +export const TemplateMarketListItemTypeSchema = z.object({ + id: z.string(), + name: z.string(), + intro: z.string().optional(), + author: z.string().optional(), + tags: z.array(z.string()), + type: z.enum([AppTypeEnum.simple, AppTypeEnum.workflow, AppTypeEnum.workflowTool]), + avatar: z.string() +}); +export type TemplateMarketListItemType = z.infer; diff --git a/packages/global/core/workflow/type/io.d.ts b/packages/global/core/workflow/type/io.d.ts deleted file mode 100644 index c1e46fd6b..000000000 --- a/packages/global/core/workflow/type/io.d.ts +++ /dev/null @@ -1,141 +0,0 @@ -import type { EmbeddingModelItemType, LLMModelItemType } from '../../ai/model.d'; -import type { LLMModelTypeEnum } from '../../ai/constants'; -import type { WorkflowIOValueTypeEnum, NodeInputKeyEnum, NodeOutputKeyEnum } from '../constants'; -import type { FlowNodeInputTypeEnum, FlowNodeOutputTypeEnum } from '../node/constant'; -import type { SecretValueType } from '../../../common/secret/type'; - -// Dynamic input field configuration -export type CustomFieldConfigType = { - // selectInputTypeList: FlowNodeInputTypeEnum[]; // 可以选哪些输入类型, 只有1个话,则默认选择 - - // reference - selectValueTypeList?: WorkflowIOValueTypeEnum[]; // 可以选哪个数据类型, 只有1个的话,则默认选择 - - showDefaultValue?: boolean; - showDescription?: boolean; -}; -export type InputComponentPropsType = { - key: `${NodeInputKeyEnum}` | string; - label: string; - - valueType?: WorkflowIOValueTypeEnum; // data type - required?: boolean; - defaultValue?: any; - - referencePlaceholder?: string; - isRichText?: boolean; - placeholder?: string; // input,textarea - maxLength?: number; // input,textarea - minLength?: number; // password - - list?: { label: string; value: string }[]; // select - - markList?: { label: string; value: number }[]; // slider - step?: number; // slider - max?: number; // slider, number input - min?: number; // slider, number input - precision?: number; // number input - - llmModelType?: `${LLMModelTypeEnum}`; - - // file - canSelectFile?: boolean; - canSelectImg?: boolean; - canSelectVideo?: boolean; - canSelectAudio?: boolean; - canSelectCustomFileExtension?: boolean; - customFileExtensionList?: string[]; - canLocalUpload?: boolean; - canUrlUpload?: boolean; - maxFiles?: number; - - // Time - timeGranularity?: 'day' | 'hour' | 'minute' | 'second'; - timeRangeStart?: string; - timeRangeEnd?: string; - - // dataset select - datasetOptions?: SelectedDatasetType[]; - - // dynamic input - customInputConfig?: CustomFieldConfigType; - - // @deprecated - enums?: { value: string; label: string }[]; -}; -export type InputConfigType = { - key: string; - label: string; - description?: string; - required?: boolean; - inputType: 'input' | 'numberInput' | 'secret' | 'switch' | 'select'; - value?: SecretValueType; - - // Selector - list?: { label: string; value: string }[]; -}; - -export type FlowNodeInputItemType = InputComponentPropsType & { - selectedTypeIndex?: number; - renderTypeList: FlowNodeInputTypeEnum[]; // Node Type. Decide on a render style - - valueDesc?: string; // data desc - value?: any; - debugLabel?: string; - description?: string; // field desc - toolDescription?: string; // If this field is not empty, it is entered as a tool - - enum?: string; - inputList?: InputConfigType[]; // when key === 'system_input_config', this field is used - - // render components params - canEdit?: boolean; // dynamic inputs - isPro?: boolean; // Pro version field - isToolOutput?: boolean; - - deprecated?: boolean; -}; - -export type FlowNodeOutputItemType = { - id: string; // output unique id(Does not follow the key change) - type: FlowNodeOutputTypeEnum; - key: `${NodeOutputKeyEnum}` | string; - valueType?: WorkflowIOValueTypeEnum; - valueDesc?: string; - value?: any; - - label?: string; - description?: string; - defaultValue?: any; - required?: boolean; - - invalid?: boolean; - invalidCondition?: (e: { - inputs: FlowNodeInputItemType[]; - llmModelList: LLMModelItemType[]; - }) => boolean; - - // component params - customFieldConfig?: CustomFieldConfigType; - - deprecated?: boolean; -}; - -// Field value type -export type ReferenceItemValueType = [string, string | undefined]; -export type ReferenceArrayValueType = ReferenceItemValueType[]; -export type ReferenceValueType = ReferenceItemValueType | ReferenceArrayValueType; - -export type SelectedDatasetType = { - datasetId: string; - avatar: string; - name: string; - vectorModel: EmbeddingModelItemType; -}; - -/* http node */ -export type HttpParamAndHeaderItemType = { - key: string; - type: string; - value: string; -}; diff --git a/packages/global/core/workflow/type/io.ts b/packages/global/core/workflow/type/io.ts new file mode 100644 index 000000000..4d8e851f4 --- /dev/null +++ b/packages/global/core/workflow/type/io.ts @@ -0,0 +1,165 @@ +import { LLMModelItemSchema } from '../../ai/model'; +import { LLMModelTypeEnum } from '../../ai/constants'; +import { WorkflowIOValueTypeEnum, NodeInputKeyEnum, NodeOutputKeyEnum } from '../constants'; +import { FlowNodeInputTypeEnum, FlowNodeOutputTypeEnum } from '../node/constant'; +import { SecretValueTypeSchema } from '../../../common/secret/type'; +import z from 'zod'; + +/* Dataset node */ +export const SelectedDatasetSchema = z.object({ + datasetId: z.string(), + avatar: z.string(), + name: z.string(), + vectorModel: z.object({ + model: z.string() + }) +}); +export type SelectedDatasetType = z.infer; + +// Dynamic input field configuration +export const CustomFieldConfigTypeSchema = z.object({ + // reference + selectValueTypeList: z.array(z.enum(WorkflowIOValueTypeEnum)).optional(), // 可以选哪个数据类型, 只有1个的话,则默认选择 + showDefaultValue: z.boolean().optional(), + showDescription: z.boolean().optional() +}); +export type CustomFieldConfigType = z.infer; + +export const InputComponentPropsTypeSchema = z.object({ + key: z.enum(NodeInputKeyEnum).or(z.string()), + label: z.string(), + + valueType: z.enum(WorkflowIOValueTypeEnum).optional(), + required: z.boolean().optional(), + defaultValue: z.any().optional(), + + // 不同组件的配置嘻嘻 + referencePlaceholder: z.string().optional(), + isRichText: z.boolean().optional(), // Prompt editor + placeholder: z.string().optional(), // input,textarea + maxLength: z.number().optional(), // input,textarea + minLength: z.number().optional(), // password + list: z.array(z.object({ label: z.string(), value: z.string() })).optional(), // select + markList: z.array(z.object({ label: z.string(), value: z.number() })).optional(), // slider + step: z.number().optional(), // slider + max: z.number().optional(), // slider, number input + min: z.number().optional(), // slider, number input + precision: z.number().optional(), // number input + llmModelType: z.enum(LLMModelTypeEnum).optional(), // ai model select + + canSelectFile: z.boolean().optional(), // file select + canSelectImg: z.boolean().optional(), // file select + canSelectVideo: z.boolean().optional(), // file select + canSelectAudio: z.boolean().optional(), // file select + canSelectCustomFileExtension: z.boolean().optional(), // file select + customFileExtensionList: z.array(z.string()).optional(), // file select + canLocalUpload: z.boolean().optional(), // file select + canUrlUpload: z.boolean().optional(), // file select + maxFiles: z.number().optional(), // file select + + // Time + timeGranularity: z.enum(['day', 'hour', 'minute', 'second']).optional(), // time point select, time range select + timeRangeStart: z.string().optional(), // time range select + timeRangeEnd: z.string().optional(), // time range select + + // dataset select + datasetOptions: z.array(SelectedDatasetSchema).optional(), + + // dynamic input + customInputConfig: CustomFieldConfigTypeSchema.optional(), + + // @deprecated + enums: z.array(z.object({ value: z.string(), label: z.string() })).optional() +}); +export type InputComponentPropsType = z.infer; + +// 输入配置 +export const InputConfigTypeSchema = z.object({ + key: z.string(), + label: z.string(), + description: z.string().optional(), + required: z.boolean().optional(), + inputType: z.enum(['input', 'numberInput', 'secret', 'switch', 'select']), + value: SecretValueTypeSchema.optional(), + + // Selector + list: z.array(z.object({ label: z.string(), value: z.string() })).optional() +}); +export type InputConfigType = z.infer; + +// Workflow node input +export const FlowNodeInputItemTypeSchema = InputComponentPropsTypeSchema.and( + z.object({ + selectedTypeIndex: z.number().optional(), + renderTypeList: z.array(z.enum(FlowNodeInputTypeEnum)), // Node Type. Decide on a render style + valueDesc: z.string().optional(), // data desc + value: z.any().optional(), + + debugLabel: z.string().optional(), + + description: z.string().optional(), // field desc + toolDescription: z.string().optional(), // If this field is not empty, it is entered as a tool + + enum: z.string().optional(), + inputList: z.array(InputConfigTypeSchema).optional(), // when key === 'system_input_config', this field is used + + // render components params + canEdit: z.boolean().optional(), // dynamic inputs + isPro: z.boolean().optional(), // Pro version field + isToolOutput: z.boolean().optional(), + + deprecated: z.boolean().optional() // node deprecated + }) +); +export type FlowNodeInputItemType = z.infer; + +// Workflow node output +export const FlowNodeOutputItemTypeSchema = z.object({ + id: z.string(), + key: z.enum(NodeOutputKeyEnum).or(z.string()), + type: z.enum(FlowNodeOutputTypeEnum), + valueType: z.enum(WorkflowIOValueTypeEnum).optional(), + valueDesc: z.string().optional(), + value: z.any().optional(), + + label: z.string().optional(), + description: z.string().optional(), + defaultValue: z.any().optional(), + required: z.boolean().optional(), + + invalid: z.boolean().optional(), + invalidCondition: z.optional( + z.function({ + input: z.tuple([ + z.object({ + inputs: FlowNodeInputItemTypeSchema.array(), + llmModelList: LLMModelItemSchema.array() + }) + ]), + output: z.boolean() + }) + ), + + customFieldConfig: CustomFieldConfigTypeSchema.optional(), + deprecated: z.boolean().optional() +}); +export type FlowNodeOutputItemType = z.infer; + +/* Reference */ +export const ReferenceItemValueTypeSchema = z.tuple([z.string(), z.string().optional()]); +export type ReferenceItemValueType = z.infer; +export const ReferenceArrayValueTypeSchema = z.array(ReferenceItemValueTypeSchema); +export type ReferenceArrayValueType = z.infer; +export const ReferenceValueTypeSchema = z.union([ + ReferenceItemValueTypeSchema, + ReferenceArrayValueTypeSchema +]); +export type ReferenceValueType = z.infer; + +/* http node */ +export const HttpParamAndHeaderItemTypeSchema = z.object({ + key: z.string(), + type: z.string(), + value: z.string() +}); +export type HttpParamAndHeaderItemType = z.infer; diff --git a/packages/global/core/workflow/type/node.d.ts b/packages/global/core/workflow/type/node.d.ts deleted file mode 100644 index e586b671b..000000000 --- a/packages/global/core/workflow/type/node.d.ts +++ /dev/null @@ -1,194 +0,0 @@ -import type { FlowNodeTypeEnum } from '../node/constant'; -import { - WorkflowIOValueTypeEnum, - NodeOutputKeyEnum, - FlowNodeTemplateTypeEnum, - VariableInputEnum -} from '../constants'; -import { DispatchNodeResponseKeyEnum } from '../runtime/constants'; -import type { FlowNodeInputItemType, FlowNodeOutputItemType } from './io.d'; -import { UserModelSchema } from '../../../support/user/type'; -import type { ChatHistoryItemResType } from '../../chat/type'; -import { - ChatItemType, - ChatItemValueItemType, - ToolRunResponseItemType, - UserChatItemValueItemType -} from '../../chat/type'; -import { ChatNodeUsageType } from '../../../support/wallet/bill/type'; -import { RuntimeNodeItemType } from '../runtime/type'; -import { RuntimeEdgeItemType, StoreEdgeItemType } from './edge'; -import { NextApiResponse } from 'next'; -import type { AppDetailType, AppSchema, HttpToolConfigType } from '../../app/type'; -import type { McpToolConfigType } from '../../app/tool/mcpTool/type'; -import type { ParentIdType } from '../../../common/parentFolder/type'; -import { AppTypeEnum } from '../../app/constants'; -import type { WorkflowInteractiveResponseType } from '../template/system/interactive/type'; -import type { StoreSecretValueType } from '../../../common/secret/type'; -import type { PluginStatusType } from '../../plugin/type'; - -export type NodeToolConfigType = { - mcpToolSet?: { - toolId: string; // ObjectId of the MCP App - url: string; - headerSecret?: StoreSecretValueType; - toolList: McpToolConfigType[]; - }; - mcpTool?: { - toolId: string; - }; - systemTool?: { - toolId: string; - }; - systemToolSet?: { - toolId: string; - toolList: { - toolId: string; - name: string; - description: string; - }[]; - }; - httpToolSet?: { - toolList: HttpToolConfigType[]; - baseUrl?: string; - apiSchemaStr?: string; - customHeaders?: string; - headerSecret?: StoreSecretValueType; - }; - httpTool?: { - toolId: string; - }; -}; - -export type FlowNodeCommonType = { - parentNodeId?: string; - flowNodeType: FlowNodeTypeEnum; // render node card - abandon?: boolean; // abandon node - - avatar?: string; - name: string; - intro?: string; // template list intro - toolDescription?: string; - showStatus?: boolean; // chatting response step status - - version?: string; - versionLabel?: string; // Just ui show - isLatestVersion?: boolean; // Just ui show - - // data - catchError?: boolean; - inputs: FlowNodeInputItemType[]; - outputs: FlowNodeOutputItemType[]; - - // plugin data - pluginId?: string; - isFolder?: boolean; - pluginData?: PluginDataType; - - // tool data - toolConfig?: NodeToolConfigType; - - // Not store, just computed - currentCost?: number; - systemKeyCost?: number; - hasTokenFee?: boolean; - hasSystemSecret?: boolean; -}; - -export type PluginDataType = { - diagram?: string; - userGuide?: string; - courseUrl?: string; - name?: string; - avatar?: string; - error?: string; - status?: PluginStatusType; -}; - -type HandleType = { - left: boolean; - right: boolean; - top: boolean; - bottom: boolean; -}; -// system template -export type FlowNodeTemplateType = FlowNodeCommonType & { - id: string; // node id, unique - templateType: string; - status?: PluginStatusType; - - showSourceHandle?: boolean; - showTargetHandle?: boolean; - - // info - isTool?: boolean; // can be connected by tool - - // action - forbidDelete?: boolean; // forbid delete - unique?: boolean; - - diagram?: string; // diagram url - courseUrl?: string; // course url - userGuide?: string; // user guide - tags?: string[] | null; - - // @deprecated - sourceHandle?: HandleType; - targetHandle?: HandleType; -}; - -export type NodeTemplateListItemType = { - id: string; // 系统节点-系统节点的 id, 系统插件-插件的 id,团队应用的 id - flowNodeType: FlowNodeTypeEnum; // render node card - parentId?: ParentIdType; - isFolder?: boolean; - templateType?: string; - tags?: string[] | null; - avatar?: string; - name: string; - intro?: string; // template list intro - isTool?: boolean; - authorAvatar?: string; - author?: string; - unique?: boolean; // 唯一的 - currentCost?: number; // 当前积分消耗 - systemKeyCost?: number; // 系统密钥费用,统一为数字 - hasTokenFee?: boolean; // 是否配置积分 - instructions?: string; // 使用说明 - courseUrl?: string; // 教程链接 - sourceMember?: SourceMember; - toolSource?: 'uploaded' | 'built-in'; // Plugin source type -}; - -export type NodeTemplateListType = { - type: string; - label: string; - list: NodeTemplateListItemType[]; -}[]; - -// react flow node type -export type FlowNodeItemType = FlowNodeTemplateType & { - nodeId: string; - parentNodeId?: string; - isError?: boolean; - searchedText?: string; - debugResult?: { - status: 'running' | 'success' | 'skipped' | 'failed'; - message?: string; - showResult?: boolean; // show and hide result modal - response?: ChatHistoryItemResType; - isExpired?: boolean; - workflowInteractiveResponse?: WorkflowInteractiveResponseType; - }; - isFolded?: boolean; -}; - -// store node type -export type StoreNodeItemType = FlowNodeCommonType & { - nodeId: string; - // isEntry: boolean; - position?: { - x: number; - y: number; - }; -}; diff --git a/packages/global/core/workflow/type/node.ts b/packages/global/core/workflow/type/node.ts new file mode 100644 index 000000000..b71315805 --- /dev/null +++ b/packages/global/core/workflow/type/node.ts @@ -0,0 +1,212 @@ +import { FlowNodeTypeEnum } from '../node/constant'; +import { FlowNodeInputItemTypeSchema, FlowNodeOutputItemTypeSchema } from './io'; +import { HttpToolConfigTypeSchema } from '../../app/tool/httpTool/type'; +import { McpToolConfigSchema } from '../../app/tool/mcpTool/type'; +import { ParentIdSchema } from '../../../common/parentFolder/type'; +import { InteractiveNodeResponseTypeSchema } from '../template/system/interactive/type'; +import { StoreSecretValueTypeSchema } from '../../../common/secret/type'; +import { PluginStatusSchema } from '../../plugin/type'; +import { SourceMemberSchema } from '../../../support/user/type'; +import z from 'zod'; + +export const NodeToolConfigTypeSchema = z.object({ + mcpToolSet: z + .object({ + toolId: z.string(), + url: z.string(), + headerSecret: StoreSecretValueTypeSchema.optional(), + toolList: z.array(McpToolConfigSchema) + }) + .optional(), + mcpTool: z + .object({ + toolId: z.string() + }) + .optional(), + systemTool: z + .object({ + toolId: z.string() + }) + .optional(), + systemToolSet: z + .object({ + toolId: z.string(), + toolList: z.array( + z.object({ + toolId: z.string(), + name: z.string(), + description: z.string() + }) + ) + }) + .optional(), + httpToolSet: z + .object({ + toolList: z.array(HttpToolConfigTypeSchema), + baseUrl: z.string().optional(), + apiSchemaStr: z.string().optional(), + customHeaders: z.string().optional(), + headerSecret: StoreSecretValueTypeSchema.optional() + }) + .optional(), + httpTool: z + .object({ + toolId: z.string() + }) + .optional() +}); +export type NodeToolConfigType = z.infer; + +export const ToolDataSchema = z.object({ + diagram: z.string().optional(), + userGuide: z.string().optional(), + courseUrl: z.string().optional(), + name: z.string().optional(), + avatar: z.string().optional(), + error: z.string().optional(), + status: PluginStatusSchema.optional() +}); + +export const FlowNodeCommonTypeSchema = z.object({ + parentNodeId: z.string().optional(), + flowNodeType: z.enum(FlowNodeTypeEnum), // render node card + abandon: z.boolean().optional(), // abandon node + + avatar: z.string().optional(), // avatar + name: z.string(), // name + intro: z.string().optional(), // template list intro + toolDescription: z.string().optional(), // tool description + showStatus: z.boolean().optional(), // chatting response step status + + version: z.string().optional(), // version + versionLabel: z.string().optional(), // Just ui show + isLatestVersion: z.boolean().optional(), // Just ui show + + // data + catchError: z.boolean().optional(), + inputs: z.array(FlowNodeInputItemTypeSchema), // inputs + outputs: z.array(FlowNodeOutputItemTypeSchema), // outputs + + // plugin data + pluginId: z.string().optional(), // plugin id + isFolder: z.boolean().optional(), + pluginData: ToolDataSchema.optional(), + + // tool data + toolConfig: NodeToolConfigTypeSchema.optional(), + + // Not store, just computed + currentCost: z.number().optional(), + systemKeyCost: z.number().optional(), + hasTokenFee: z.boolean().optional(), + hasSystemSecret: z.boolean().optional() +}); +export type FlowNodeCommonType = z.infer; + +const HandleTypeSchema = z.object({ + left: z.boolean(), + right: z.boolean(), + top: z.boolean(), + bottom: z.boolean() +}); + +// system template +export const FlowNodeTemplateTypeSchema = FlowNodeCommonTypeSchema.and( + z.object({ + id: z.string(), + templateType: z.string(), + status: PluginStatusSchema.optional(), + + showSourceHandle: z.boolean().optional(), + showTargetHandle: z.boolean().optional(), + + // Info + isTool: z.boolean().optional(), // can be connected by tool + + // Action + forbidDelete: z.boolean().optional(), // forbid delete + unique: z.boolean().optional(), + + diagram: z.string().optional(), + courseUrl: z.string().optional(), + userGuide: z.string().optional(), + tags: z.array(z.string()).nullish(), + + // @deprecated + sourceHandle: HandleTypeSchema.optional(), + targetHandle: HandleTypeSchema.optional() + }) +); +export type FlowNodeTemplateType = z.infer; + +// Api response +export const NodeTemplateListItemTypeSchema = z.object({ + id: z.string(), // 系统节点-系统节点的 id, 系统插件-插件的 id,团队应用的 id + flowNodeType: z.enum(FlowNodeTypeEnum), // render node card + parentId: ParentIdSchema.optional(), + isFolder: z.boolean().optional(), + templateType: z.string().optional(), + tags: z.array(z.string()).nullish(), + avatar: z.string().optional(), + name: z.string(), + intro: z.string().optional(), // template list intro + isTool: z.boolean().optional(), + + authorAvatar: z.string().optional(), + author: z.string().optional(), + + unique: z.boolean().optional(), + + currentCost: z.number().optional(), // 当前积分消耗 + systemKeyCost: z.number().optional(), // 系统密钥费用,统一为数字 + hasTokenFee: z.boolean().optional(), + instructions: z.string().optional(), // 使用说明 + courseUrl: z.string().optional(), + sourceMember: SourceMemberSchema.optional(), + toolSource: z.enum(['uploaded', 'built-in']).optional() +}); +export type NodeTemplateListItemType = z.infer; +export const NodeTemplateListTypeSchema = z.array( + z.object({ + type: z.string(), + label: z.string(), + list: z.array(NodeTemplateListItemTypeSchema) + }) +); +export type NodeTemplateListType = z.infer; + +// react flow node type +export const FlowNodeItemSchema = FlowNodeTemplateTypeSchema.and( + z.object({ + nodeId: z.string(), + parentNodeId: z.string().optional(), + isError: z.boolean().optional(), + searchedText: z.string().optional(), + debugResult: z + .object({ + status: z.enum(['running', 'success', 'skipped', 'failed']), + message: z.string().optional(), + showResult: z.boolean().optional(), + response: z.any().optional(), + isExpired: z.boolean().optional(), + interactiveResponse: InteractiveNodeResponseTypeSchema.optional() + }) + .optional(), + isFolded: z.boolean().optional() + }) +); +export type FlowNodeItemType = z.infer; + +// store node type +export const StoreNodeItemTypeSchema = FlowNodeCommonTypeSchema.and( + z.object({ + nodeId: z.string(), + position: z + .object({ + x: z.number(), + y: z.number() + }) + .optional() + }) +); +export type StoreNodeItemType = z.infer; diff --git a/packages/global/core/workflow/utils.ts b/packages/global/core/workflow/utils.ts index 4e420c384..6feb1bc78 100644 --- a/packages/global/core/workflow/utils.ts +++ b/packages/global/core/workflow/utils.ts @@ -17,7 +17,7 @@ import { type FlowNodeOutputItemType, type ReferenceArrayValueType, type ReferenceItemValueType -} from './type/io.d'; +} from './type/io'; import { type StoreNodeItemType } from './type/node'; import type { VariableItemType, @@ -28,7 +28,7 @@ import type { AppChatConfigType, AppAutoExecuteConfigType, AppQGConfigType, - AppSchema + AppSchemaType } from '../app/type'; import { type EditorVariablePickerType } from '../../../web/components/common/Textarea/PromptEditor/type'; import { @@ -428,7 +428,7 @@ export const removeUnauthModels = async ({ modules, allowedModels = new Set() }: { - modules: AppSchema['modules']; + modules: AppSchemaType['modules']; allowedModels?: Set; }) => { if (modules) { diff --git a/packages/global/openapi/core/plugin/marketplace/api.ts b/packages/global/openapi/core/plugin/marketplace/api.ts index ebf5a1bcc..521aa9ebc 100644 --- a/packages/global/openapi/core/plugin/marketplace/api.ts +++ b/packages/global/openapi/core/plugin/marketplace/api.ts @@ -12,18 +12,22 @@ export type MarketplaceToolListItemType = ToolSimpleType & { downloadCount: number; }; -export const MarketplaceToolDetailItemSchema = formatToolDetailSchema.extend({ - readme: z.string().optional() -}); +export const MarketplaceToolDetailItemSchema = formatToolDetailSchema.and( + z.object({ + readme: z.string().optional() + }) +); export const MarketplaceToolDetailSchema = z.object({ tools: z.array(MarketplaceToolDetailItemSchema) }); // List -export const GetMarketplaceToolsBodySchema = PaginationSchema.extend({ - searchKey: z.string().optional(), - tags: z.array(z.string()).nullish() -}); +export const GetMarketplaceToolsBodySchema = PaginationSchema.and( + z.object({ + searchKey: z.string().optional(), + tags: z.array(z.string()).nullish() + }) +); export type GetMarketplaceToolsBodyType = z.infer; export const MarketplaceToolsResponseSchema = z.object({ diff --git a/packages/global/openapi/support/wallet/discountCoupon/api.ts b/packages/global/openapi/support/wallet/discountCoupon/api.ts index b62c1fdc5..9d4b23f1d 100644 --- a/packages/global/openapi/support/wallet/discountCoupon/api.ts +++ b/packages/global/openapi/support/wallet/discountCoupon/api.ts @@ -17,17 +17,21 @@ export const DiscountCouponSchema = z.object({ export type DiscountCouponSchemaType = z.infer; -export const DiscountCouponItemSchema = DiscountCouponSchema.extend({ - name: z.string().meta({ description: '优惠券名称' }), - description: z.string().meta({ description: '优惠券描述' }), - discount: z.number().min(0).max(1).meta({ description: '折扣率' }), - iconZh: z.string().meta({ description: '中文图标路径' }), - iconEn: z.string().meta({ description: '英文图标路径' }), - status: z.enum(DiscountCouponStatusEnum).meta({ description: '优惠券状态' }), - billId: ObjectIdSchema.optional().meta({ - description: '关联的订单 ID, 被使用后该值存在' +export const DiscountCouponItemSchema = DiscountCouponSchema.and( + z.object({ + name: z.string().meta({ description: '优惠券名称' }), + description: z.string().meta({ description: '优惠券描述' }), + discount: z.number().min(0).max(1).meta({ description: '折扣率' }), + iconZh: z.string().meta({ description: '中文图标路径' }), + iconEn: z.string().meta({ description: '英文图标路径' }), + status: z.enum(DiscountCouponStatusEnum).meta({ description: '优惠券状态' }), + billId: ObjectIdSchema.optional().meta({ + description: '关联的订单 ID, 被使用后该值存在' + }) }) -}); -export const DiscountCouponListResponseSchema = z.array(DiscountCouponItemSchema); +); +export const DiscountCouponListResponseSchema = z + .array(DiscountCouponItemSchema) + .meta({ description: '优惠券列表' }); export type DiscountCouponListResponseType = z.infer; diff --git a/packages/global/support/outLink/type.d.ts b/packages/global/support/outLink/type.d.ts index d2bd692e4..9d2ac1c8a 100644 --- a/packages/global/support/outLink/type.d.ts +++ b/packages/global/support/outLink/type.d.ts @@ -1,4 +1,4 @@ -import { AppSchema } from '../../core/app/type'; +import { AppSchemaType } from '../../core/app/type'; import type { PublishChannelEnum } from './constant'; import { RequireOnlyOne } from '../../common/type/utils'; diff --git a/packages/global/support/user/type.ts b/packages/global/support/user/type.ts index ea62d6140..d6bb756df 100644 --- a/packages/global/support/user/type.ts +++ b/packages/global/support/user/type.ts @@ -1,9 +1,9 @@ +import z from 'zod'; import type { LangEnum } from '../../common/i18n/type'; import type { TeamPermission } from '../permission/user/controller'; import type { UserStatusEnum } from './constant'; import { TeamMemberStatusEnum } from './team/constant'; import type { TeamTmbItemType } from './team/type'; -import z from 'zod'; export type UserModelSchema = { _id: string; diff --git a/packages/service/common/s3/sources/helperbot/index.ts b/packages/service/common/s3/sources/helperbot/index.ts index 805a9cafe..c2876c088 100644 --- a/packages/service/common/s3/sources/helperbot/index.ts +++ b/packages/service/common/s3/sources/helperbot/index.ts @@ -61,7 +61,7 @@ export class S3HelperBotSource { // 获取文件流 getFileStream(key: string) { - return this.bucket.getObject(key); + return this.bucket.getFileStream(key); } // 获取文件状态 diff --git a/packages/service/common/vectorDB/controller.ts b/packages/service/common/vectorDB/controller.ts index 492ded73d..92c586233 100644 --- a/packages/service/common/vectorDB/controller.ts +++ b/packages/service/common/vectorDB/controller.ts @@ -4,7 +4,7 @@ import { ObVectorCtrl } from './oceanbase'; import { getVectorsByText } from '../../core/ai/embedding'; import type { EmbeddingRecallCtrlProps } from './controller.d'; import { type DelDatasetVectorCtrlProps, type InsertVectorProps } from './controller.d'; -import { type EmbeddingModelItemType } from '@fastgpt/global/core/ai/model.d'; +import { type EmbeddingModelItemType } from '@fastgpt/global/core/ai/model'; import { MILVUS_ADDRESS, PG_ADDRESS, OCEANBASE_ADDRESS } from './constants'; import { MilvusCtrl } from './milvus'; import { diff --git a/packages/service/core/ai/audio/transcriptions.ts b/packages/service/core/ai/audio/transcriptions.ts index a74057224..ba126cf6d 100644 --- a/packages/service/core/ai/audio/transcriptions.ts +++ b/packages/service/core/ai/audio/transcriptions.ts @@ -2,7 +2,7 @@ import type fs from 'fs'; import { getAxiosConfig } from '../config'; import axios from 'axios'; import FormData from 'form-data'; -import { type STTModelType } from '@fastgpt/global/core/ai/model.d'; +import { type STTModelType } from '@fastgpt/global/core/ai/model'; import { UserError } from '@fastgpt/global/common/error/utils'; export const aiTranscriptions = async ({ diff --git a/packages/service/core/ai/config/utils.ts b/packages/service/core/ai/config/utils.ts index 4d0b7947b..c1f87fe74 100644 --- a/packages/service/core/ai/config/utils.ts +++ b/packages/service/core/ai/config/utils.ts @@ -1,5 +1,5 @@ import type { SystemDefaultModelType, SystemModelItemType } from '../type'; -import { ModelTypeEnum } from '@fastgpt/global/core/ai/model'; +import { ModelTypeEnum } from '@fastgpt/global/core/ai/constants'; import { MongoSystemModel } from './schema'; import { type LLMModelItemType, @@ -7,7 +7,7 @@ import { type TTSModelType, type STTModelType, type RerankModelItemType -} from '@fastgpt/global/core/ai/model.d'; +} from '@fastgpt/global/core/ai/model'; import { debounce } from 'lodash'; import { getModelProvider } from '../../../core/app/provider/controller'; import { findModelFromAlldata } from '../model'; diff --git a/packages/service/core/ai/embedding/index.ts b/packages/service/core/ai/embedding/index.ts index 5f81a2c62..8772d2e77 100644 --- a/packages/service/core/ai/embedding/index.ts +++ b/packages/service/core/ai/embedding/index.ts @@ -1,4 +1,4 @@ -import { type EmbeddingModelItemType } from '@fastgpt/global/core/ai/model.d'; +import { type EmbeddingModelItemType } from '@fastgpt/global/core/ai/model'; import { getAIApi } from '../config'; import { countPromptTokens } from '../../../common/string/tiktoken/index'; import { EmbeddingTypeEnm } from '@fastgpt/global/core/ai/constants'; diff --git a/packages/service/core/ai/functions/createQuestionGuide.ts b/packages/service/core/ai/functions/createQuestionGuide.ts index a2f57d062..f8f5a3a54 100644 --- a/packages/service/core/ai/functions/createQuestionGuide.ts +++ b/packages/service/core/ai/functions/createQuestionGuide.ts @@ -1,4 +1,4 @@ -import type { ChatCompletionMessageParam } from '@fastgpt/global/core/ai/type.d'; +import type { ChatCompletionMessageParam } from '@fastgpt/global/core/ai/type'; import { QuestionGuidePrompt, QuestionGuideFooterPrompt diff --git a/packages/service/core/ai/llm/compress/index.ts b/packages/service/core/ai/llm/compress/index.ts index 1c992a78d..b25d33e8b 100644 --- a/packages/service/core/ai/llm/compress/index.ts +++ b/packages/service/core/ai/llm/compress/index.ts @@ -1,4 +1,4 @@ -import type { LLMModelItemType } from '@fastgpt/global/core/ai/model.d'; +import type { LLMModelItemType } from '@fastgpt/global/core/ai/model'; import { countGptMessagesTokens } from '../../../../common/string/tiktoken'; import { addLog } from '../../../../common/system/log'; import { calculateCompressionThresholds } from './constants'; diff --git a/packages/service/core/ai/llm/compress/prompt.ts b/packages/service/core/ai/llm/compress/prompt.ts index 3d298000c..1f34b5480 100644 --- a/packages/service/core/ai/llm/compress/prompt.ts +++ b/packages/service/core/ai/llm/compress/prompt.ts @@ -1,4 +1,4 @@ -import type { LLMModelItemType } from '@fastgpt/global/core/ai/model.d'; +import type { LLMModelItemType } from '@fastgpt/global/core/ai/model'; import type { ChatCompletionMessageParam } from '@fastgpt/global/core/ai/type'; import { calculateCompressionThresholds } from './constants'; diff --git a/packages/service/core/ai/llm/request.ts b/packages/service/core/ai/llm/request.ts index eb9317c64..e8c953b50 100644 --- a/packages/service/core/ai/llm/request.ts +++ b/packages/service/core/ai/llm/request.ts @@ -26,7 +26,7 @@ import { ChatCompletionRequestMessageRoleEnum } from '@fastgpt/global/core/ai/co import { countGptMessagesTokens } from '../../../common/string/tiktoken/index'; import { loadRequestMessages } from './utils'; import { addLog } from '../../../common/system/log'; -import type { LLMModelItemType } from '@fastgpt/global/core/ai/model.d'; +import type { LLMModelItemType } from '@fastgpt/global/core/ai/model'; import { i18nT } from '../../../../web/i18n/utils'; import { getErrText } from '@fastgpt/global/common/error/utils'; import json5 from 'json5'; diff --git a/packages/service/core/ai/llm/utils.ts b/packages/service/core/ai/llm/utils.ts index 9af77f773..cb364e093 100644 --- a/packages/service/core/ai/llm/utils.ts +++ b/packages/service/core/ai/llm/utils.ts @@ -6,7 +6,7 @@ import type { ChatCompletionContentPartText, ChatCompletionMessageParam, SdkChatCompletionMessageParam -} from '@fastgpt/global/core/ai/type.d'; +} from '@fastgpt/global/core/ai/type'; import axios from 'axios'; import { ChatCompletionRequestMessageRoleEnum } from '@fastgpt/global/core/ai/constants'; import { i18nT } from '../../../../web/i18n/utils'; diff --git a/packages/service/core/ai/model.ts b/packages/service/core/ai/model.ts index 5f3ced278..79ed84b8f 100644 --- a/packages/service/core/ai/model.ts +++ b/packages/service/core/ai/model.ts @@ -1,6 +1,6 @@ import { cloneDeep } from 'lodash'; import { type SystemModelItemType } from './type'; -import type { LLMModelItemType } from '@fastgpt/global/core/ai/model.d'; +import type { LLMModelItemType } from '@fastgpt/global/core/ai/model'; export const getDefaultLLMModel = () => global?.systemDefaultModel.llm!; export const getLLMModel = (model?: string | LLMModelItemType) => { diff --git a/packages/service/core/ai/rerank/index.ts b/packages/service/core/ai/rerank/index.ts index e5db1eae1..1e3026d2f 100644 --- a/packages/service/core/ai/rerank/index.ts +++ b/packages/service/core/ai/rerank/index.ts @@ -2,7 +2,7 @@ import { addLog } from '../../../common/system/log'; import { POST } from '../../../common/api/serverRequest'; import { getDefaultRerankModel } from '../model'; import { getAxiosConfig } from '../config'; -import { type RerankModelItemType } from '@fastgpt/global/core/ai/model.d'; +import { type RerankModelItemType } from '@fastgpt/global/core/ai/model'; import { countPromptTokens } from '../../../common/string/tiktoken'; type PostReRankResponse = { diff --git a/packages/service/core/ai/type.d.ts b/packages/service/core/ai/type.ts similarity index 90% rename from packages/service/core/ai/type.d.ts rename to packages/service/core/ai/type.ts index f091b552c..c841c20fb 100644 --- a/packages/service/core/ai/type.d.ts +++ b/packages/service/core/ai/type.ts @@ -1,12 +1,11 @@ -import type { ModelTypeEnum } from '@fastgpt/global/core/ai/model'; +import type { ModelTypeEnum } from '@fastgpt/global/core/ai/constants'; import type { STTModelType, RerankModelItemType, TTSModelType, EmbeddingModelItemType, LLMModelItemType -} from '@fastgpt/global/core/ai/model.d'; -import type { ModelProviderListType } from '@fastgpt/global/core/app/model/type'; +} from '@fastgpt/global/core/ai/model'; import type { AiproxyMapProviderType, I18nStringStrictType diff --git a/packages/service/core/ai/utils.ts b/packages/service/core/ai/utils.ts index 187e45ea5..873150911 100644 --- a/packages/service/core/ai/utils.ts +++ b/packages/service/core/ai/utils.ts @@ -1,4 +1,4 @@ -import { type LLMModelItemType } from '@fastgpt/global/core/ai/model.d'; +import { type LLMModelItemType } from '@fastgpt/global/core/ai/model'; import type { CompletionFinishReason, CompletionUsage } from '@fastgpt/global/core/ai/type'; import { getLLMDefaultUsage } from '@fastgpt/global/core/ai/constants'; import { removeDatasetCiteText } from '@fastgpt/global/core/ai/llm/utils'; diff --git a/packages/service/core/app/controller.ts b/packages/service/core/app/controller.ts index fb07552a2..b5620f07c 100644 --- a/packages/service/core/app/controller.ts +++ b/packages/service/core/app/controller.ts @@ -1,4 +1,4 @@ -import { type AppSchema } from '@fastgpt/global/core/app/type'; +import { type AppSchemaType } from '@fastgpt/global/core/app/type'; import { NodeInputKeyEnum } from '@fastgpt/global/core/workflow/constants'; import { FlowNodeInputTypeEnum, @@ -92,7 +92,7 @@ export async function findAppAndAllChildren({ teamId: string; appId: string; fields?: string; -}): Promise { +}): Promise { const find = async (id: string) => { const children = await MongoApp.find( { @@ -140,7 +140,7 @@ export const deleteAppDataProcessor = async ({ app, teamId }: { - app: AppSchema; + app: AppSchemaType; teamId: string; }) => { const appId = String(app._id); diff --git a/packages/service/core/app/http.ts b/packages/service/core/app/http.ts index cae7736e6..26dbe4f72 100644 --- a/packages/service/core/app/http.ts +++ b/packages/service/core/app/http.ts @@ -3,7 +3,7 @@ import { getSecretValue } from '../../common/secret/utils'; import axios from 'axios'; import { getErrText } from '@fastgpt/global/common/error/utils'; import type { RequireOnlyOne } from '@fastgpt/global/common/type/utils'; -import type { HttpToolConfigType } from '@fastgpt/global/core/app/type'; +import type { HttpToolConfigType } from '@fastgpt/global/core/app/tool/httpTool/type'; import { contentTypeMap, ContentTypes } from '@fastgpt/global/core/workflow/constants'; import { replaceEditorVariable } from '@fastgpt/global/core/workflow/runtime/utils'; diff --git a/packages/service/core/app/mcp.ts b/packages/service/core/app/mcp.ts index 3c5239b15..aeba9d72e 100644 --- a/packages/service/core/app/mcp.ts +++ b/packages/service/core/app/mcp.ts @@ -1,7 +1,7 @@ import { Client } from '@modelcontextprotocol/sdk/client/index.js'; import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js'; import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js'; -import type { AppSchema } from '@fastgpt/global/core/app/type'; +import type { AppSchemaType } from '@fastgpt/global/core/app/type'; import { type McpToolConfigType } from '@fastgpt/global/core/app/tool/mcpTool/type'; import { addLog } from '../../common/system/log'; import { retryFn } from '@fastgpt/global/common/system/utils'; @@ -154,7 +154,7 @@ export class MCPClient { } } -export const getMCPChildren = async (app: AppSchema) => { +export const getMCPChildren = async (app: AppSchemaType) => { const isNewMcp = !!app.modules[0].toolConfig?.mcpToolSet; const id = String(app._id); diff --git a/packages/service/core/app/schema.ts b/packages/service/core/app/schema.ts index 2cf83b770..cd52be565 100644 --- a/packages/service/core/app/schema.ts +++ b/packages/service/core/app/schema.ts @@ -1,6 +1,6 @@ import { AppTypeEnum } from '@fastgpt/global/core/app/constants'; import { Schema, getMongoModel } from '../../common/mongo'; -import type { AppSchema as AppType } from '@fastgpt/global/core/app/type.d'; +import type { AppSchemaType as AppType } from '@fastgpt/global/core/app/type'; import { TeamCollectionName, TeamMemberCollectionName diff --git a/packages/service/core/app/tool/controller.ts b/packages/service/core/app/tool/controller.ts index 3bf7c20a0..040567670 100644 --- a/packages/service/core/app/tool/controller.ts +++ b/packages/service/core/app/tool/controller.ts @@ -1,7 +1,7 @@ import type { NodeToolConfigType, FlowNodeTemplateType -} from '@fastgpt/global/core/workflow/type/node.d'; +} from '@fastgpt/global/core/workflow/type/node'; import { FlowNodeOutputTypeEnum, FlowNodeInputTypeEnum, diff --git a/packages/service/core/app/version/controller.ts b/packages/service/core/app/version/controller.ts index d7bcb69b5..710b3bfcd 100644 --- a/packages/service/core/app/version/controller.ts +++ b/packages/service/core/app/version/controller.ts @@ -1,8 +1,8 @@ -import { type AppSchema } from '@fastgpt/global/core/app/type'; +import { type AppSchemaType } from '@fastgpt/global/core/app/type'; import { MongoAppVersion } from './schema'; import { Types } from '../../../common/mongo'; -export const getAppLatestVersion = async (appId: string, app?: AppSchema) => { +export const getAppLatestVersion = async (appId: string, app?: AppSchemaType) => { const version = await MongoAppVersion.findOne({ appId, isPublish: true @@ -37,7 +37,7 @@ export const getAppVersionById = async ({ }: { appId: string; versionId?: string; - app?: AppSchema; + app?: AppSchemaType; }) => { // 检查 versionId 是否符合 ObjectId 格式 if (versionId && Types.ObjectId.isValid(versionId)) { diff --git a/packages/service/core/dataset/search/controller.ts b/packages/service/core/dataset/search/controller.ts index 71428b4aa..8a443bd25 100644 --- a/packages/service/core/dataset/search/controller.ts +++ b/packages/service/core/dataset/search/controller.ts @@ -30,7 +30,7 @@ import { MongoDatasetDataText } from '../data/dataTextSchema'; import { type ChatItemType } from '@fastgpt/global/core/chat/type'; import type { NodeInputKeyEnum } from '@fastgpt/global/core/workflow/constants'; import { datasetSearchQueryExtension } from './utils'; -import type { RerankModelItemType } from '@fastgpt/global/core/ai/model.d'; +import type { RerankModelItemType } from '@fastgpt/global/core/ai/model'; import { formatDatasetDataValue } from '../data/controller'; import { pushTrack } from '../../../common/middle/tracks/utils'; import { replaceS3KeyToPreviewUrl } from '../../../core/dataset/utils'; diff --git a/packages/service/core/workflow/dispatch/ai/agent/sub/model/index.ts b/packages/service/core/workflow/dispatch/ai/agent/sub/model/index.ts index d269096cc..6409f68e4 100644 --- a/packages/service/core/workflow/dispatch/ai/agent/sub/model/index.ts +++ b/packages/service/core/workflow/dispatch/ai/agent/sub/model/index.ts @@ -1,4 +1,4 @@ -import type { ChatCompletionMessageParam } from '@fastgpt/global/core/ai/type.d'; +import type { ChatCompletionMessageParam } from '@fastgpt/global/core/ai/type'; import { createLLMResponse, type ResponseEvents } from '../../../../../../ai/llm/request'; import { getLLMModel } from '../../../../../../ai/model'; import { formatModelChars2Points } from '../../../../../../../support/wallet/usage/utils'; diff --git a/packages/service/core/workflow/dispatch/ai/agent/sub/plan/index.ts b/packages/service/core/workflow/dispatch/ai/agent/sub/plan/index.ts index 8c4512573..6431893f8 100644 --- a/packages/service/core/workflow/dispatch/ai/agent/sub/plan/index.ts +++ b/packages/service/core/workflow/dispatch/ai/agent/sub/plan/index.ts @@ -1,7 +1,4 @@ -import type { - ChatCompletionMessageParam, - ChatCompletionTool -} from '@fastgpt/global/core/ai/type.d'; +import type { ChatCompletionMessageParam, ChatCompletionTool } from '@fastgpt/global/core/ai/type'; import { createLLMResponse } from '../../../../../../ai/llm/request'; import { getPlanAgentSystemPrompt, diff --git a/packages/service/core/workflow/dispatch/ai/chat.ts b/packages/service/core/workflow/dispatch/ai/chat.ts index b4afc8dd4..4e4c00888 100644 --- a/packages/service/core/workflow/dispatch/ai/chat.ts +++ b/packages/service/core/workflow/dispatch/ai/chat.ts @@ -3,7 +3,7 @@ import type { ChatItemType, UserChatItemFileItemType } from '@fastgpt/global/cor import { ChatRoleEnum } from '@fastgpt/global/core/chat/constants'; import { SseResponseEventEnum } from '@fastgpt/global/core/workflow/runtime/constants'; import { textAdaptGptResponse } from '@fastgpt/global/core/workflow/runtime/utils'; -import type { LLMModelItemType } from '@fastgpt/global/core/ai/model.d'; +import type { LLMModelItemType } from '@fastgpt/global/core/ai/model'; import type { ChatDispatchProps, DispatchNodeResultType @@ -20,7 +20,7 @@ import { getQuotePrompt, getDocumentQuotePrompt } from '@fastgpt/global/core/ai/prompt/AIChat'; -import type { AIChatNodeProps } from '@fastgpt/global/core/workflow/runtime/type.d'; +import type { AIChatNodeProps } from '@fastgpt/global/core/workflow/runtime/type'; import { replaceVariable } from '@fastgpt/global/common/string/tools'; import type { ModuleDispatchProps } from '@fastgpt/global/core/workflow/runtime/type'; import { getLLMModel } from '../../../ai/model'; diff --git a/packages/service/core/workflow/dispatch/ai/classifyQuestion.ts b/packages/service/core/workflow/dispatch/ai/classifyQuestion.ts index 1716f1978..bc12a8c7e 100644 --- a/packages/service/core/workflow/dispatch/ai/classifyQuestion.ts +++ b/packages/service/core/workflow/dispatch/ai/classifyQuestion.ts @@ -7,14 +7,13 @@ import { NodeOutputKeyEnum } from '@fastgpt/global/core/workflow/constants'; import { DispatchNodeResponseKeyEnum } from '@fastgpt/global/core/workflow/runtime/constants'; import type { ModuleDispatchProps } from '@fastgpt/global/core/workflow/runtime/type'; import { getCQSystemPrompt } from '@fastgpt/global/core/ai/prompt/agent'; -import { type LLMModelItemType } from '@fastgpt/global/core/ai/model.d'; +import { type LLMModelItemType } from '@fastgpt/global/core/ai/model'; import { getLLMModel } from '../../../ai/model'; import { getHistories } from '../utils'; import { formatModelChars2Points } from '../../../../support/wallet/usage/utils'; import { type DispatchNodeResultType } from '@fastgpt/global/core/workflow/runtime/type'; import { getHandleId } from '@fastgpt/global/core/workflow/utils'; import { addLog } from '../../../../common/system/log'; -import { ModelTypeEnum } from '../../../../../global/core/ai/model'; import { createLLMResponse } from '../../../ai/llm/request'; type Props = ModuleDispatchProps<{ diff --git a/packages/service/core/workflow/dispatch/ai/extract.ts b/packages/service/core/workflow/dispatch/ai/extract.ts index 8951bf6c3..6339ac814 100644 --- a/packages/service/core/workflow/dispatch/ai/extract.ts +++ b/packages/service/core/workflow/dispatch/ai/extract.ts @@ -12,7 +12,7 @@ import { import { DispatchNodeResponseKeyEnum } from '@fastgpt/global/core/workflow/runtime/constants'; import type { ModuleDispatchProps } from '@fastgpt/global/core/workflow/runtime/type'; import { sliceJsonStr } from '@fastgpt/global/common/string/tools'; -import { type LLMModelItemType } from '@fastgpt/global/core/ai/model.d'; +import { type LLMModelItemType } from '@fastgpt/global/core/ai/model'; import { getNodeErrResponse, getHistories } from '../utils'; import { getLLMModel } from '../../../ai/model'; import { formatModelChars2Points } from '../../../../support/wallet/usage/utils'; diff --git a/packages/service/core/workflow/dispatch/ai/tool/type.ts b/packages/service/core/workflow/dispatch/ai/tool/type.ts index 6bc6202d8..123a5c8b5 100644 --- a/packages/service/core/workflow/dispatch/ai/tool/type.ts +++ b/packages/service/core/workflow/dispatch/ai/tool/type.ts @@ -8,7 +8,7 @@ import type { RuntimeNodeItemType } from '@fastgpt/global/core/workflow/runtime/ import type { DispatchFlowResponse } from '../../type'; import type { AIChatItemValueItemType, ChatItemType } from '@fastgpt/global/core/chat/type'; import type { ToolCallChildrenInteractive } from '@fastgpt/global/core/workflow/template/system/interactive/type'; -import type { LLMModelItemType } from '@fastgpt/global/core/ai/model.d'; +import type { LLMModelItemType } from '@fastgpt/global/core/ai/model'; import type { JSONSchemaInputType } from '@fastgpt/global/core/app/jsonschema'; export type DispatchToolModuleProps = ModuleDispatchProps<{ diff --git a/packages/service/core/workflow/dispatch/child/runApp.ts b/packages/service/core/workflow/dispatch/child/runApp.ts index 9d1c0c856..0aef10c7c 100644 --- a/packages/service/core/workflow/dispatch/child/runApp.ts +++ b/packages/service/core/workflow/dispatch/child/runApp.ts @@ -58,7 +58,9 @@ export const dispatchRunAppNode = async (props: Props): Promise => { const userInputFiles = (() => { if (fileUrlList) { - return fileUrlList.map((url) => parseUrlToFileType(url)).filter(Boolean); + return fileUrlList + .map((url) => parseUrlToFileType(url)) + .filter((file): file is NonNullable => Boolean(file)); } // Adapt version 4.8.13 upgrade return files; diff --git a/packages/service/core/workflow/dispatch/child/runTool.ts b/packages/service/core/workflow/dispatch/child/runTool.ts index ec805a77e..53116346b 100644 --- a/packages/service/core/workflow/dispatch/child/runTool.ts +++ b/packages/service/core/workflow/dispatch/child/runTool.ts @@ -10,7 +10,7 @@ import { NodeInputKeyEnum } from '@fastgpt/global/core/workflow/constants'; import { MCPClient } from '../../../app/mcp'; import { getSecretValue } from '../../../../common/secret/utils'; import type { McpToolDataType } from '@fastgpt/global/core/app/tool/mcpTool/type'; -import type { HttpToolConfigType } from '@fastgpt/global/core/app/type'; +import type { HttpToolConfigType } from '@fastgpt/global/core/app/tool/httpTool/type'; import { APIRunSystemTool } from '../../../app/tool/api'; import { MongoSystemTool } from '../../../plugin/tool/systemToolSchema'; import { SystemToolSecretInputTypeEnum } from '@fastgpt/global/core/app/tool/systemTool/constants'; diff --git a/packages/service/core/workflow/dispatch/dataset/search.ts b/packages/service/core/workflow/dispatch/dataset/search.ts index 6be9a3820..e52a1a47d 100644 --- a/packages/service/core/workflow/dispatch/dataset/search.ts +++ b/packages/service/core/workflow/dispatch/dataset/search.ts @@ -1,4 +1,4 @@ -import { type DispatchNodeResultType } from '@fastgpt/global/core/workflow/runtime/type.d'; +import { type DispatchNodeResultType } from '@fastgpt/global/core/workflow/runtime/type'; import { formatModelChars2Points } from '../../../../support/wallet/usage/utils'; import type { SelectedDatasetType } from '@fastgpt/global/core/workflow/type/io'; import type { SearchDataResponseItemType } from '@fastgpt/global/core/dataset/type'; diff --git a/packages/service/core/workflow/dispatch/index.ts b/packages/service/core/workflow/dispatch/index.ts index dac861b5a..2aa4eae83 100644 --- a/packages/service/core/workflow/dispatch/index.ts +++ b/packages/service/core/workflow/dispatch/index.ts @@ -22,7 +22,7 @@ import type { ModuleDispatchProps, SystemVariablesType } from '@fastgpt/global/core/workflow/runtime/type'; -import type { RuntimeNodeItemType } from '@fastgpt/global/core/workflow/runtime/type.d'; +import type { RuntimeNodeItemType } from '@fastgpt/global/core/workflow/runtime/type'; import { getErrText, UserError } from '@fastgpt/global/common/error/utils'; import { filterPublicNodeResponseData } from '@fastgpt/global/core/chat/utils'; import { diff --git a/packages/service/core/workflow/dispatch/plugin/runOutput.ts b/packages/service/core/workflow/dispatch/plugin/runOutput.ts index 08cf7abf5..180002899 100644 --- a/packages/service/core/workflow/dispatch/plugin/runOutput.ts +++ b/packages/service/core/workflow/dispatch/plugin/runOutput.ts @@ -1,5 +1,5 @@ import type { ModuleDispatchProps } from '@fastgpt/global/core/workflow/runtime/type'; -import { type DispatchNodeResultType } from '@fastgpt/global/core/workflow/runtime/type.d'; +import { type DispatchNodeResultType } from '@fastgpt/global/core/workflow/runtime/type'; import { DispatchNodeResponseKeyEnum } from '@fastgpt/global/core/workflow/runtime/constants'; export type PluginOutputProps = ModuleDispatchProps<{ diff --git a/packages/service/core/workflow/dispatch/type.ts b/packages/service/core/workflow/dispatch/type.ts index fb05c0051..568efd41a 100644 --- a/packages/service/core/workflow/dispatch/type.ts +++ b/packages/service/core/workflow/dispatch/type.ts @@ -12,7 +12,7 @@ import type { InteractiveNodeResponseType, WorkflowInteractiveResponseType } from '@fastgpt/global/core/workflow/template/system/interactive/type'; -import type { RuntimeEdgeItemType } from '@fastgpt/global/core/workflow/type/edge'; +import { type RuntimeEdgeItemType } from '@fastgpt/global/core/workflow/type/edge'; import type { ChatNodeUsageType } from '@fastgpt/global/support/wallet/bill/type'; import z from 'zod'; diff --git a/packages/service/core/workflow/dispatch/utils.ts b/packages/service/core/workflow/dispatch/utils.ts index e52443d8c..ad2456860 100644 --- a/packages/service/core/workflow/dispatch/utils.ts +++ b/packages/service/core/workflow/dispatch/utils.ts @@ -5,10 +5,10 @@ import { NodeOutputKeyEnum, VariableInputEnum } from '@fastgpt/global/core/workf import type { VariableItemType } from '@fastgpt/global/core/app/type'; import { encryptSecret } from '../../../common/secret/aes256gcm'; import { - type RuntimeEdgeItemType, type RuntimeNodeItemType, type SystemVariablesType } from '@fastgpt/global/core/workflow/runtime/type'; +import type { RuntimeEdgeItemType } from '@fastgpt/global/core/workflow/type/edge'; import { responseWrite } from '../../../common/response'; import { type NextApiResponse } from 'next'; import { @@ -24,7 +24,7 @@ import { MongoApp } from '../../../core/app/schema'; import { getMCPChildren } from '../../../core/app/mcp'; import { getSystemToolRunTimeNodeFromSystemToolset } from '../utils'; import type { localeType } from '@fastgpt/global/common/i18n/type'; -import type { HttpToolConfigType } from '@fastgpt/global/core/app/type'; +import type { HttpToolConfigType } from '@fastgpt/global/core/app/tool/httpTool/type'; import type { WorkflowResponseType } from './type'; export const getWorkflowResponseWrite = ({ diff --git a/packages/service/support/permission/app/auth.ts b/packages/service/support/permission/app/auth.ts index 909a8831d..6c1b73bfd 100644 --- a/packages/service/support/permission/app/auth.ts +++ b/packages/service/support/permission/app/auth.ts @@ -1,6 +1,6 @@ /* Auth app permission */ import { MongoApp } from '../../../core/app/schema'; -import { type AppDetailType } from '@fastgpt/global/core/app/type.d'; +import { type AppDetailType } from '@fastgpt/global/core/app/type'; import { NullRoleVal, PerResourceTypeEnum, diff --git a/packages/service/type.d.ts b/packages/service/type.d.ts index 213e14d8f..5ef1304c0 100644 --- a/packages/service/type.d.ts +++ b/packages/service/type.d.ts @@ -9,7 +9,7 @@ import { STTModelType, EmbeddingModelItemType, LLMModelItemType -} from '@fastgpt/global/core/ai/model.d'; +} from '@fastgpt/global/core/ai/model'; import type { SubPlanType } from '@fastgpt/global/support/wallet/sub/type'; import type { WorkerNameEnum, WorkerPool } from './worker/utils'; import { Worker } from 'worker_threads'; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 78ded05a2..5e47c035b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -24590,4 +24590,4 @@ snapshots: immer: 9.0.21 react: 18.3.1 - zwitch@2.0.4: {} \ No newline at end of file + zwitch@2.0.4: {} diff --git a/projects/app/src/components/PromptTemplate/index.tsx b/projects/app/src/components/PromptTemplate/index.tsx index 7ca8d7994..4a525c563 100644 --- a/projects/app/src/components/PromptTemplate/index.tsx +++ b/projects/app/src/components/PromptTemplate/index.tsx @@ -1,7 +1,7 @@ import React, { useState } from 'react'; import MyModal from '@fastgpt/web/components/common/MyModal'; import { Box, Button, Flex, Grid, useTheme } from '@chakra-ui/react'; -import { type PromptTemplateItem } from '@fastgpt/global/core/ai/type.d'; +import { type PromptTemplateItem } from '@fastgpt/global/core/ai/type'; import { ModalBody, ModalFooter } from '@chakra-ui/react'; import { useTranslation } from 'next-i18next'; const PromptTemplate = ({ diff --git a/projects/app/src/components/common/folder/Path.tsx b/projects/app/src/components/common/folder/Path.tsx index 3b58924da..804301e0d 100644 --- a/projects/app/src/components/common/folder/Path.tsx +++ b/projects/app/src/components/common/folder/Path.tsx @@ -1,5 +1,8 @@ import { Box, type BoxProps, Flex } from '@chakra-ui/react'; -import { type ParentTreePathItemType } from '@fastgpt/global/common/parentFolder/type'; +import type { + ParentIdType, + ParentTreePathItemType +} from '@fastgpt/global/common/parentFolder/type'; import React, { useMemo } from 'react'; import { useTranslation } from 'next-i18next'; import MyIcon from '@fastgpt/web/components/common/Icon'; @@ -10,7 +13,7 @@ const FolderPath = (props: { paths: ParentTreePathItemType[]; rootName?: string; FirstPathDom?: React.ReactNode; - onClick: (parentId: string) => void; + onClick: (parentId: ParentIdType) => void; fontSize?: string; hoverStyle?: BoxProps; forbidLastClick?: boolean; diff --git a/projects/app/src/components/core/ai/AISettingModal/index.tsx b/projects/app/src/components/core/ai/AISettingModal/index.tsx index 6bde63162..0e11f242e 100644 --- a/projects/app/src/components/core/ai/AISettingModal/index.tsx +++ b/projects/app/src/components/core/ai/AISettingModal/index.tsx @@ -23,10 +23,10 @@ import { } from '@chakra-ui/react'; import { useSystemStore } from '@/web/common/system/useSystemStore'; import { NodeInputKeyEnum } from '@fastgpt/global/core/workflow/constants'; -import type { SettingAIDataType } from '@fastgpt/global/core/app/type.d'; +import type { SettingAIDataType } from '@fastgpt/global/core/app/type'; import { getDocPath } from '@/web/common/system/doc'; import AIModelSelector from '@/components/Select/AIModelSelector'; -import { type LLMModelItemType } from '@fastgpt/global/core/ai/model.d'; +import { type LLMModelItemType } from '@fastgpt/global/core/ai/model'; import QuestionTip from '@fastgpt/web/components/common/MyTooltip/QuestionTip'; import { getWebLLMModel } from '@/web/common/system/utils'; import MyIcon from '@fastgpt/web/components/common/Icon'; diff --git a/projects/app/src/components/core/ai/ModelTable/index.tsx b/projects/app/src/components/core/ai/ModelTable/index.tsx index 250e067fc..0fbd0a0e6 100644 --- a/projects/app/src/components/core/ai/ModelTable/index.tsx +++ b/projects/app/src/components/core/ai/ModelTable/index.tsx @@ -17,7 +17,7 @@ import { import { useTranslation } from 'next-i18next'; import React, { useMemo, useRef, useState } from 'react'; import MySelect from '@fastgpt/web/components/common/MySelect'; -import { modelTypeList, ModelTypeEnum } from '@fastgpt/global/core/ai/model'; +import { modelTypeList, ModelTypeEnum } from '@fastgpt/global/core/ai/constants'; import SearchInput from '@fastgpt/web/components/common/Input/SearchInput'; import { useSystemStore } from '@/web/common/system/useSystemStore'; import Avatar from '@fastgpt/web/components/common/Avatar'; diff --git a/projects/app/src/components/core/ai/SettingLLMModel/index.tsx b/projects/app/src/components/core/ai/SettingLLMModel/index.tsx index 2f3e6744a..e85e8afce 100644 --- a/projects/app/src/components/core/ai/SettingLLMModel/index.tsx +++ b/projects/app/src/components/core/ai/SettingLLMModel/index.tsx @@ -2,7 +2,7 @@ import React, { useEffect, useMemo } from 'react'; import { useSystemStore } from '@/web/common/system/useSystemStore'; import { LLMModelTypeEnum, llmModelTypeFilterMap } from '@fastgpt/global/core/ai/constants'; import { Box, css, HStack, IconButton, useDisclosure } from '@chakra-ui/react'; -import type { SettingAIDataType } from '@fastgpt/global/core/app/type.d'; +import type { SettingAIDataType } from '@fastgpt/global/core/app/type'; import AISettingModal, { type AIChatSettingsModalProps } from '@/components/core/ai/AISettingModal'; import MyTooltip from '@fastgpt/web/components/common/MyTooltip'; import { useTranslation } from 'next-i18next'; diff --git a/projects/app/src/components/core/app/DatasetParamsModal.tsx b/projects/app/src/components/core/app/DatasetParamsModal.tsx index fca020b45..86bec37db 100644 --- a/projects/app/src/components/core/app/DatasetParamsModal.tsx +++ b/projects/app/src/components/core/app/DatasetParamsModal.tsx @@ -172,7 +172,7 @@ const DatasetParamsModal = ({ /> {currentTabType === SearchSettingTabEnum.searchMode && ( - + py={2.5} gridGap={4} list={[ diff --git a/projects/app/src/components/core/app/FileSelect.tsx b/projects/app/src/components/core/app/FileSelect.tsx index af567648f..a1a35fd28 100644 --- a/projects/app/src/components/core/app/FileSelect.tsx +++ b/projects/app/src/components/core/app/FileSelect.tsx @@ -14,7 +14,7 @@ import { } from '@chakra-ui/react'; import React, { useState } from 'react'; import { useTranslation } from 'next-i18next'; -import type { AppFileSelectConfigType } from '@fastgpt/global/core/app/type.d'; +import type { AppFileSelectConfigType } from '@fastgpt/global/core/app/type'; import MyModal from '@fastgpt/web/components/common/MyModal'; import ChatFunctionTip from './Tip'; import FormLabel from '@fastgpt/web/components/common/MyBox/FormLabel'; diff --git a/projects/app/src/components/core/app/InputGuideConfig.tsx b/projects/app/src/components/core/app/InputGuideConfig.tsx index 0fb5a9de7..38e5b81df 100644 --- a/projects/app/src/components/core/app/InputGuideConfig.tsx +++ b/projects/app/src/components/core/app/InputGuideConfig.tsx @@ -12,7 +12,7 @@ import { } from '@chakra-ui/react'; import React, { useMemo, useState } from 'react'; import { useTranslation } from 'next-i18next'; -import type { ChatInputGuideConfigType } from '@fastgpt/global/core/app/type.d'; +import type { ChatInputGuideConfigType } from '@fastgpt/global/core/app/type'; import MyModal from '@fastgpt/web/components/common/MyModal'; import MyInput from '@/components/MyInput'; import QuestionTip from '@fastgpt/web/components/common/MyTooltip/QuestionTip'; diff --git a/projects/app/src/components/core/app/QGConfig.tsx b/projects/app/src/components/core/app/QGConfig.tsx index 4bb8e43c0..3e0a1b560 100644 --- a/projects/app/src/components/core/app/QGConfig.tsx +++ b/projects/app/src/components/core/app/QGConfig.tsx @@ -12,7 +12,7 @@ import { import React from 'react'; import { useTranslation } from 'next-i18next'; -import type { AppQGConfigType } from '@fastgpt/global/core/app/type.d'; +import type { AppQGConfigType } from '@fastgpt/global/core/app/type'; import MyModal from '@fastgpt/web/components/common/MyModal'; import QuestionTip from '@fastgpt/web/components/common/MyTooltip/QuestionTip'; import { defaultQGConfig } from '@fastgpt/global/core/app/constants'; diff --git a/projects/app/src/components/core/app/TTSSelect.tsx b/projects/app/src/components/core/app/TTSSelect.tsx index e20dff0a1..4f7c2bb4c 100644 --- a/projects/app/src/components/core/app/TTSSelect.tsx +++ b/projects/app/src/components/core/app/TTSSelect.tsx @@ -4,7 +4,7 @@ import { Box, Button, Flex, ModalBody, useDisclosure, Image, HStack } from '@cha import React, { useCallback, useMemo } from 'react'; import { useTranslation } from 'next-i18next'; import { TTSTypeEnum } from '@/web/core/app/constants'; -import type { AppTTSConfigType } from '@fastgpt/global/core/app/type.d'; +import type { AppTTSConfigType } from '@fastgpt/global/core/app/type'; import { useAudioPlay } from '@/web/common/utils/voice'; import { useSystemStore } from '@/web/common/system/useSystemStore'; import MyModal from '@fastgpt/web/components/common/MyModal'; diff --git a/projects/app/src/components/core/app/VariableEdit.tsx b/projects/app/src/components/core/app/VariableEdit.tsx index df3f1f85d..ed4ef6e5a 100644 --- a/projects/app/src/components/core/app/VariableEdit.tsx +++ b/projects/app/src/components/core/app/VariableEdit.tsx @@ -16,7 +16,7 @@ import { VariableInputEnum, WorkflowIOValueTypeEnum } from '@fastgpt/global/core/workflow/constants'; -import type { VariableItemType } from '@fastgpt/global/core/app/type.d'; +import type { VariableItemType } from '@fastgpt/global/core/app/type'; import MyIcon from '@fastgpt/web/components/common/Icon'; import { useTranslation } from 'next-i18next'; import { formatEditorVariablePickerIcon } from '@fastgpt/global/core/workflow/utils'; diff --git a/projects/app/src/components/core/app/VariableEditModal/index.tsx b/projects/app/src/components/core/app/VariableEditModal/index.tsx index 5786735ec..b3fc3ea42 100644 --- a/projects/app/src/components/core/app/VariableEditModal/index.tsx +++ b/projects/app/src/components/core/app/VariableEditModal/index.tsx @@ -1,7 +1,7 @@ import React, { useCallback, useMemo, useEffect } from 'react'; import { Flex, Stack } from '@chakra-ui/react'; import { VariableInputEnum } from '@fastgpt/global/core/workflow/constants'; -import type { VariableItemType } from '@fastgpt/global/core/app/type.d'; +import type { VariableItemType } from '@fastgpt/global/core/app/type'; import { useForm } from 'react-hook-form'; import MyModal from '@fastgpt/web/components/common/MyModal'; import { useTranslation } from 'next-i18next'; diff --git a/projects/app/src/components/core/app/WhisperConfig.tsx b/projects/app/src/components/core/app/WhisperConfig.tsx index 19f8988d9..a8a221824 100644 --- a/projects/app/src/components/core/app/WhisperConfig.tsx +++ b/projects/app/src/components/core/app/WhisperConfig.tsx @@ -3,7 +3,7 @@ import MyTooltip from '@fastgpt/web/components/common/MyTooltip'; import { Box, Button, Flex, ModalBody, useDisclosure, Switch } from '@chakra-ui/react'; import React from 'react'; import { useTranslation } from 'next-i18next'; -import type { AppWhisperConfigType } from '@fastgpt/global/core/app/type.d'; +import type { AppWhisperConfigType } from '@fastgpt/global/core/app/type'; import MyModal from '@fastgpt/web/components/common/MyModal'; import QuestionTip from '@fastgpt/web/components/common/MyTooltip/QuestionTip'; import { defaultWhisperConfig } from '@fastgpt/global/core/app/constants'; diff --git a/projects/app/src/components/core/dataset/SelectModal.tsx b/projects/app/src/components/core/dataset/SelectModal.tsx index 21c7abdcd..04b7f8aec 100644 --- a/projects/app/src/components/core/dataset/SelectModal.tsx +++ b/projects/app/src/components/core/dataset/SelectModal.tsx @@ -1,15 +1,15 @@ import { getDatasets, getDatasetPaths } from '@/web/core/dataset/api'; import MyModal from '@fastgpt/web/components/common/MyModal'; -import { useQuery } from '@tanstack/react-query'; -import React, { type Dispatch, useMemo, useState } from 'react'; +import React, { type Dispatch, useState } from 'react'; import { useTranslation } from 'next-i18next'; import { Box } from '@chakra-ui/react'; import FolderPath from '@/components/common/folder/Path'; import MyBox from '@fastgpt/web/components/common/MyBox'; import { useRequest2 } from '@fastgpt/web/hooks/useRequest'; +import type { ParentIdType } from '@fastgpt/global/common/parentFolder/type'; type PathItemType = { - parentId: string; + parentId: ParentIdType; parentName: string; }; @@ -23,7 +23,7 @@ const DatasetSelectContainer = ({ children }: { isOpen: boolean; - setParentId: Dispatch; + setParentId: Dispatch; paths: PathItemType[]; onClose: () => void; tips?: string | null; @@ -69,7 +69,7 @@ const DatasetSelectContainer = ({ }; export function useDatasetSelect() { - const [parentId, setParentId] = useState(''); + const [parentId, setParentId] = useState(''); const [searchKey, setSearchKey] = useState(''); const { diff --git a/projects/app/src/global/core/api/datasetReq.d.ts b/projects/app/src/global/core/api/datasetReq.d.ts index aca0ebe7f..1cdd4f1a2 100644 --- a/projects/app/src/global/core/api/datasetReq.d.ts +++ b/projects/app/src/global/core/api/datasetReq.d.ts @@ -8,15 +8,16 @@ import type { SearchTestItemType } from '@/types/core/dataset'; import { UploadChunkItemType } from '@fastgpt/global/core/dataset/type'; import { DatasetCollectionSchemaType } from '@fastgpt/global/core/dataset/type'; import { PermissionTypeEnum } from '@fastgpt/global/support/permission/constant'; -import type { LLMModelItemType } from '@fastgpt/global/core/ai/model.d'; +import type { LLMModelItemType } from '@fastgpt/global/core/ai/model'; import type { PaginationProps } from '@fastgpt/web/common/fetch/type'; +import type { ParentIdType } from '@fastgpt/global/common/parentFolder/type'; /* ===== dataset ===== */ /* ======= collections =========== */ export type GetDatasetCollectionsProps = PaginationProps<{ datasetId: string; - parentId?: string; + parentId?: ParentIdType; searchText?: string; filterTags?: string[]; simple?: boolean; diff --git a/projects/app/src/global/core/app/api.d.ts b/projects/app/src/global/core/app/api.d.ts index 2cd97161b..15eb3fbd4 100644 --- a/projects/app/src/global/core/app/api.d.ts +++ b/projects/app/src/global/core/app/api.d.ts @@ -1,6 +1,6 @@ import type { ParentIdType } from '@fastgpt/global/common/parentFolder/type'; import type { AppTypeEnum } from '@fastgpt/global/core/app/constants'; -import type { AppSchema } from '@fastgpt/global/core/app/type'; +import type { AppSchemaType } from '@fastgpt/global/core/app/type'; export type AppUpdateParams = { parentId?: ParentIdType; @@ -8,16 +8,16 @@ export type AppUpdateParams = { type?: AppTypeEnum; avatar?: string; intro?: string; - nodes?: AppSchema['modules']; - edges?: AppSchema['edges']; - chatConfig?: AppSchema['chatConfig']; - teamTags?: AppSchema['teamTags']; + nodes?: AppSchemaType['modules']; + edges?: AppSchemaType['edges']; + chatConfig?: AppSchemaType['chatConfig']; + teamTags?: AppSchemaType['teamTags']; }; export type PostPublishAppProps = { - nodes: AppSchema['modules']; - edges: AppSchema['edges']; - chatConfig: AppSchema['chatConfig']; + nodes: AppSchemaType['modules']; + edges: AppSchemaType['edges']; + chatConfig: AppSchemaType['chatConfig']; isPublish?: boolean; versionName?: string; autoSave?: boolean; // If it is automatically saved, only one copy of the entire app will be stored, overwriting the old version @@ -26,9 +26,9 @@ export type PostPublishAppProps = { export type PostRevertAppProps = { versionId: string; // edit workflow - editNodes: AppSchema['modules']; - editEdges: AppSchema['edges']; - editChatConfig: AppSchema['chatConfig']; + editNodes: AppSchemaType['modules']; + editEdges: AppSchemaType['edges']; + editChatConfig: AppSchemaType['chatConfig']; }; export type AppChangeOwnerBody = { diff --git a/projects/app/src/global/core/chat/api.d.ts b/projects/app/src/global/core/chat/api.d.ts index 8be1c1992..35fbdcc1f 100644 --- a/projects/app/src/global/core/chat/api.d.ts +++ b/projects/app/src/global/core/chat/api.d.ts @@ -1,4 +1,4 @@ -import type { AppChatConfigType, AppTTSConfigType } from '@fastgpt/global/core/app/type.d'; +import type { AppChatConfigType, AppTTSConfigType } from '@fastgpt/global/core/app/type'; import type { AdminFbkType } from '@fastgpt/global/core/chat/type'; import { ChatItemType } from '@fastgpt/global/core/chat/type'; import type { OutLinkChatAuthProps } from '@fastgpt/global/support/permission/chat'; diff --git a/projects/app/src/global/core/workflow/api.d.ts b/projects/app/src/global/core/workflow/api.d.ts index c622a7ff8..09d23b399 100644 --- a/projects/app/src/global/core/workflow/api.d.ts +++ b/projects/app/src/global/core/workflow/api.d.ts @@ -1,4 +1,4 @@ -import type { AppSchema } from '@fastgpt/global/core/app/type'; +import type { AppSchemaType } from '@fastgpt/global/core/app/type'; import type { ChatHistoryItemResType } from '@fastgpt/global/core/chat/type'; import type { RuntimeNodeItemType } from '@fastgpt/global/core/workflow/runtime/type'; import type { WorkflowInteractiveResponseType } from '@fastgpt/global/core/workflow/template/system/interactive/type'; @@ -15,7 +15,7 @@ export type PostWorkflowDebugProps = { appId: string; query?: UserChatItemValueItemType[]; history?: ChatItemType[]; - chatConfig?: AppSchema['chatConfig']; + chatConfig?: AppSchemaType['chatConfig']; usageId?: string; }; diff --git a/projects/app/src/pageComponents/account/model/AddModelBox.tsx b/projects/app/src/pageComponents/account/model/AddModelBox.tsx index 96eedadf2..f5f76b1c1 100644 --- a/projects/app/src/pageComponents/account/model/AddModelBox.tsx +++ b/projects/app/src/pageComponents/account/model/AddModelBox.tsx @@ -19,7 +19,7 @@ import { import { useTranslation } from 'next-i18next'; import React, { useMemo, useRef, useState } from 'react'; import MySelect from '@fastgpt/web/components/common/MySelect'; -import { ModelTypeEnum } from '@fastgpt/global/core/ai/model'; +import { ModelTypeEnum } from '@fastgpt/global/core/ai/constants'; import Avatar from '@fastgpt/web/components/common/Avatar'; import { useRequest2 } from '@fastgpt/web/hooks/useRequest'; import { getSystemModelDefaultConfig, putSystemModel } from '@/web/core/ai/config'; diff --git a/projects/app/src/pageComponents/account/model/Channel/EditChannelModal.tsx b/projects/app/src/pageComponents/account/model/Channel/EditChannelModal.tsx index 0220ba20c..9ff9e3179 100644 --- a/projects/app/src/pageComponents/account/model/Channel/EditChannelModal.tsx +++ b/projects/app/src/pageComponents/account/model/Channel/EditChannelModal.tsx @@ -25,7 +25,7 @@ import { useForm } from 'react-hook-form'; import { AddModelButton } from '../AddModelBox'; import dynamic from 'next/dynamic'; import { type SystemModelItemType } from '@fastgpt/service/core/ai/type'; -import type { ModelTypeEnum } from '@fastgpt/global/core/ai/model'; +import type { ModelTypeEnum } from '@fastgpt/global/core/ai/constants'; import { useSystemStore } from '@/web/common/system/useSystemStore'; import { getSystemModelList } from '@/web/core/ai/config'; import { useRequest2 } from '@fastgpt/web/hooks/useRequest'; diff --git a/projects/app/src/pageComponents/account/model/ModelConfigTable.tsx b/projects/app/src/pageComponents/account/model/ModelConfigTable.tsx index 7422a9d7b..bed63c975 100644 --- a/projects/app/src/pageComponents/account/model/ModelConfigTable.tsx +++ b/projects/app/src/pageComponents/account/model/ModelConfigTable.tsx @@ -19,7 +19,7 @@ import { import { useTranslation } from 'next-i18next'; import React, { useCallback, useMemo, useRef, useState } from 'react'; import MySelect from '@fastgpt/web/components/common/MySelect'; -import { modelTypeList, ModelTypeEnum } from '@fastgpt/global/core/ai/model'; +import { modelTypeList, ModelTypeEnum } from '@fastgpt/global/core/ai/constants'; import SearchInput from '@fastgpt/web/components/common/Input/SearchInput'; import Avatar from '@fastgpt/web/components/common/Avatar'; import MyTag from '@fastgpt/web/components/common/Tag/index'; diff --git a/projects/app/src/pageComponents/app/detail/Edit/ChatAgent/ChatTest.tsx b/projects/app/src/pageComponents/app/detail/Edit/ChatAgent/ChatTest.tsx index 132918df4..bea87f794 100644 --- a/projects/app/src/pageComponents/app/detail/Edit/ChatAgent/ChatTest.tsx +++ b/projects/app/src/pageComponents/app/detail/Edit/ChatAgent/ChatTest.tsx @@ -5,7 +5,7 @@ import MyTooltip from '@fastgpt/web/components/common/MyTooltip'; import MyIcon from '@fastgpt/web/components/common/Icon'; import { useSafeState } from 'ahooks'; -import type { AppFormEditFormType } from '@fastgpt/global/core/app/type'; +import type { AppFormEditFormType } from '@fastgpt/global/core/app/formEdit/type'; import { useContextSelector } from 'use-context-selector'; import { AppContext } from '../../context'; import { useChatTest } from '../../useChatTest'; diff --git a/projects/app/src/pageComponents/app/detail/Edit/ChatAgent/Edit.tsx b/projects/app/src/pageComponents/app/detail/Edit/ChatAgent/Edit.tsx index 60fa2dd04..27e86aa5c 100644 --- a/projects/app/src/pageComponents/app/detail/Edit/ChatAgent/Edit.tsx +++ b/projects/app/src/pageComponents/app/detail/Edit/ChatAgent/Edit.tsx @@ -4,7 +4,8 @@ import { Box, Flex } from '@chakra-ui/react'; import ChatTest from './ChatTest'; import AppCard from '../FormComponent/AppCard'; import EditForm from './EditForm'; -import type { SkillEditType, AppFormEditFormType } from '@fastgpt/global/core/app/type'; +import type { SkillEditType } from '@fastgpt/global/core/app/formEdit/type'; +import type { AppFormEditFormType } from '@fastgpt/global/core/app/formEdit/type'; import { cardStyles } from '../../constants'; import { useSystem } from '@fastgpt/web/hooks/useSystem'; import { type SimpleAppSnapshotType } from '../FormComponent/useSnapshots'; @@ -37,6 +38,7 @@ const Edit = ({ gap={1} borderRadius={'lg'} overflowY={['auto', 'unset']} + overflowX={'hidden'} position={'relative'} > {/* Top agent editor */} diff --git a/projects/app/src/pageComponents/app/detail/Edit/ChatAgent/EditForm.tsx b/projects/app/src/pageComponents/app/detail/Edit/ChatAgent/EditForm.tsx index 46b5e03a4..ee0fce912 100644 --- a/projects/app/src/pageComponents/app/detail/Edit/ChatAgent/EditForm.tsx +++ b/projects/app/src/pageComponents/app/detail/Edit/ChatAgent/EditForm.tsx @@ -10,7 +10,8 @@ import { HStack, Input } from '@chakra-ui/react'; -import type { AppFormEditFormType, SkillEditType } from '@fastgpt/global/core/app/type.d'; +import type { SkillEditType } from '@fastgpt/global/core/app/formEdit/type'; +import type { AppFormEditFormType } from '@fastgpt/global/core/app/formEdit/type'; import { useRouter } from 'next/router'; import { useTranslation } from 'next-i18next'; @@ -442,9 +443,9 @@ const EditForm = ({ ({ datasetId: item.datasetId, - vectorModel: item.vectorModel, name: item.name, - avatar: item.avatar + avatar: item.avatar, + vectorModel: item.vectorModel }))} onClose={onCloseKbSelect} onChange={(e) => { diff --git a/projects/app/src/pageComponents/app/detail/Edit/ChatAgent/SkillEdit/ChatTest.tsx b/projects/app/src/pageComponents/app/detail/Edit/ChatAgent/SkillEdit/ChatTest.tsx index c00e810d0..ffcebcc3b 100644 --- a/projects/app/src/pageComponents/app/detail/Edit/ChatAgent/SkillEdit/ChatTest.tsx +++ b/projects/app/src/pageComponents/app/detail/Edit/ChatAgent/SkillEdit/ChatTest.tsx @@ -3,7 +3,8 @@ import { useTranslation } from 'next-i18next'; import React, { useMemo } from 'react'; import MyTooltip from '@fastgpt/web/components/common/MyTooltip'; import MyIcon from '@fastgpt/web/components/common/Icon'; -import type { AppFormEditFormType, SkillEditType } from '@fastgpt/global/core/app/type'; +import type { SkillEditType } from '@fastgpt/global/core/app/formEdit/type'; +import type { AppFormEditFormType } from '@fastgpt/global/core/app/formEdit/type'; import { useContextSelector } from 'use-context-selector'; import { AppContext } from '../../../context'; import MyBox from '@fastgpt/web/components/common/MyBox'; diff --git a/projects/app/src/pageComponents/app/detail/Edit/ChatAgent/SkillEdit/EditForm.tsx b/projects/app/src/pageComponents/app/detail/Edit/ChatAgent/SkillEdit/EditForm.tsx index 4c53f4f19..ac1f98b80 100644 --- a/projects/app/src/pageComponents/app/detail/Edit/ChatAgent/SkillEdit/EditForm.tsx +++ b/projects/app/src/pageComponents/app/detail/Edit/ChatAgent/SkillEdit/EditForm.tsx @@ -12,11 +12,9 @@ import { IconButton, Textarea } from '@chakra-ui/react'; -import type { - AppFileSelectConfigType, - AppFormEditFormType, - SkillEditType -} from '@fastgpt/global/core/app/type.d'; +import type { AppFileSelectConfigType } from '@fastgpt/global/core/app/type'; +import type { SkillEditType } from '@fastgpt/global/core/app/formEdit/type'; +import type { AppFormEditFormType } from '@fastgpt/global/core/app/formEdit/type'; import { useRouter } from 'next/router'; import { useTranslation } from 'next-i18next'; @@ -40,12 +38,12 @@ import { getWebLLMModel } from '@/web/common/system/utils'; import ToolSelect from '../../FormComponent/ToolSelector/ToolSelect'; import OptimizerPopover from '@/components/common/PromptEditor/OptimizerPopover'; import type { FlowNodeTemplateType } from '@fastgpt/global/core/workflow/type/node'; -import { type SelectedToolItemType, useSkillManager } from '../hooks/useSkillManager'; +import { useSkillManager } from '../hooks/useSkillManager'; import { useMemoEnhance } from '@fastgpt/web/hooks/useMemoEnhance'; import { cardStyles } from '../../../constants'; import { defaultSkill as defaultEditSkill } from './Row'; import { useForm } from 'react-hook-form'; -import type { LLMModelItemType } from '@fastgpt/global/core/ai/model.d'; +import type { LLMModelItemType } from '@fastgpt/global/core/ai/model'; import { SmallAddIcon } from '@chakra-ui/icons'; import { getNanoid } from '@fastgpt/global/common/string/tools'; @@ -257,9 +255,9 @@ const EditForm = ({ ({ datasetId: item.datasetId, - vectorModel: item.vectorModel, name: item.name, - avatar: item.avatar + avatar: item.avatar, + vectorModel: item.vectorModel }))} onClose={onCloseKbSelect} onChange={(e) => { diff --git a/projects/app/src/pageComponents/app/detail/Edit/ChatAgent/SkillEdit/Row.tsx b/projects/app/src/pageComponents/app/detail/Edit/ChatAgent/SkillEdit/Row.tsx index 637ecb00c..e651e6da4 100644 --- a/projects/app/src/pageComponents/app/detail/Edit/ChatAgent/SkillEdit/Row.tsx +++ b/projects/app/src/pageComponents/app/detail/Edit/ChatAgent/SkillEdit/Row.tsx @@ -5,7 +5,7 @@ import FormLabel from '@fastgpt/web/components/common/MyBox/FormLabel'; import QuestionTip from '@fastgpt/web/components/common/MyTooltip/QuestionTip'; import { SmallAddIcon } from '@chakra-ui/icons'; import { useTranslation } from 'next-i18next'; -import type { SkillEditType } from '@fastgpt/global/core/app/type'; +import type { SkillEditType } from '@fastgpt/global/core/app/formEdit/type'; import MyIconButton from '@fastgpt/web/components/common/Icon/button'; export const defaultSkill: SkillEditType = { diff --git a/projects/app/src/pageComponents/app/detail/Edit/ChatAgent/hooks/useSkillManager.tsx b/projects/app/src/pageComponents/app/detail/Edit/ChatAgent/hooks/useSkillManager.tsx index af80948e5..679e30fd9 100644 --- a/projects/app/src/pageComponents/app/detail/Edit/ChatAgent/hooks/useSkillManager.tsx +++ b/projects/app/src/pageComponents/app/detail/Edit/ChatAgent/hooks/useSkillManager.tsx @@ -18,7 +18,7 @@ import { NodeOutputKeyEnum } from '@fastgpt/global/core/workflow/constants'; import { getNanoid } from '@fastgpt/global/common/string/tools'; import type { SkillLabelItemType } from '@fastgpt/web/components/common/Textarea/PromptEditor/plugins/SkillLabelPlugin'; import dynamic from 'next/dynamic'; -import type { AppFormEditFormType } from '@fastgpt/global/core/app/type'; +import type { AppFormEditFormType } from '@fastgpt/global/core/app/formEdit/type'; import { getAppToolTemplates, getToolPreviewNode, diff --git a/projects/app/src/pageComponents/app/detail/Edit/ChatAgent/utils.ts b/projects/app/src/pageComponents/app/detail/Edit/ChatAgent/utils.ts index 77daa5d85..f494c957d 100644 --- a/projects/app/src/pageComponents/app/detail/Edit/ChatAgent/utils.ts +++ b/projects/app/src/pageComponents/app/detail/Edit/ChatAgent/utils.ts @@ -1,12 +1,10 @@ -import type { - AppChatConfigType, - AppFormEditFormType, - SkillEditType -} from '@fastgpt/global/core/app/type'; +import type { SkillEditType } from '@fastgpt/global/core/app/formEdit/type'; +import type { AppChatConfigType } from '@fastgpt/global/core/app/type'; +import type { AppFormEditFormType } from '@fastgpt/global/core/app/formEdit/type'; import type { FlowNodeTemplateType, StoreNodeItemType -} from '@fastgpt/global/core/workflow/type/node.d'; +} from '@fastgpt/global/core/workflow/type/node'; import { FlowNodeInputTypeEnum, FlowNodeTypeEnum diff --git a/projects/app/src/pageComponents/app/detail/Edit/FormComponent/AppCard.tsx b/projects/app/src/pageComponents/app/detail/Edit/FormComponent/AppCard.tsx index bc3049ab3..10f33e862 100644 --- a/projects/app/src/pageComponents/app/detail/Edit/FormComponent/AppCard.tsx +++ b/projects/app/src/pageComponents/app/detail/Edit/FormComponent/AppCard.tsx @@ -10,7 +10,8 @@ import { ModalFooter } from '@chakra-ui/react'; import { useRouter } from 'next/router'; -import { type AppSchema, type AppFormEditFormType } from '@fastgpt/global/core/app/type.d'; +import { type AppSchemaType } from '@fastgpt/global/core/app/type'; +import type { AppFormEditFormType } from '@fastgpt/global/core/app/formEdit/type'; import { useTranslation } from 'next-i18next'; import Avatar from '@fastgpt/web/components/common/Avatar'; import MyIcon from '@fastgpt/web/components/common/Icon'; @@ -45,7 +46,7 @@ const AppCard = ({ const appId = appDetail._id; const { feConfigs } = useSystemStore(); - const [TeamTagsSet, setTeamTagsSet] = useState(); + const [TeamTagsSet, setTeamTagsSet] = useState(); // transition to workflow const [transitionCreateNew, setTransitionCreateNew] = useState(); diff --git a/projects/app/src/pageComponents/app/detail/Edit/FormComponent/ChatTest.tsx b/projects/app/src/pageComponents/app/detail/Edit/FormComponent/ChatTest.tsx index be9e3e2af..e6087aec8 100644 --- a/projects/app/src/pageComponents/app/detail/Edit/FormComponent/ChatTest.tsx +++ b/projects/app/src/pageComponents/app/detail/Edit/FormComponent/ChatTest.tsx @@ -5,7 +5,7 @@ import MyTooltip from '@fastgpt/web/components/common/MyTooltip'; import MyIcon from '@fastgpt/web/components/common/Icon'; import { useSafeState } from 'ahooks'; -import type { AppFormEditFormType } from '@fastgpt/global/core/app/type'; +import type { AppFormEditFormType } from '@fastgpt/global/core/app/formEdit/type'; import { useContextSelector } from 'use-context-selector'; import { AppContext } from '../../context'; import { useChatTest } from '../../useChatTest'; diff --git a/projects/app/src/pageComponents/app/detail/Edit/FormComponent/Header.tsx b/projects/app/src/pageComponents/app/detail/Edit/FormComponent/Header.tsx index 1b625d3ec..a2e7e383b 100644 --- a/projects/app/src/pageComponents/app/detail/Edit/FormComponent/Header.tsx +++ b/projects/app/src/pageComponents/app/detail/Edit/FormComponent/Header.tsx @@ -8,7 +8,7 @@ import { Box, Flex, IconButton } from '@chakra-ui/react'; import { useRouter } from 'next/router'; import RouteTab from '../../RouteTab'; import { useTranslation } from 'next-i18next'; -import type { AppFormEditFormType } from '@fastgpt/global/core/app/type'; +import type { AppFormEditFormType } from '@fastgpt/global/core/app/formEdit/type'; import { TabEnum } from '../../context'; import MyIcon from '@fastgpt/web/components/common/Icon'; import MyTag from '@fastgpt/web/components/common/Tag/index'; @@ -34,6 +34,7 @@ import { storeNode2FlowNode } from '@/web/core/workflow/utils'; import type { AppForm2WorkflowFnType, Form2WorkflowFnType } from './type.d'; +import type { ParentIdType } from '@fastgpt/global/common/parentFolder/type'; const Header = ({ forbiddenSaveSnapshot, @@ -72,11 +73,11 @@ const Header = ({ } ); const onClickRoute = useCallback( - (parentId: string) => { + (parentId: ParentIdType) => { router.push({ pathname: '/dashboard/agent', query: { - parentId, + parentId: parentId || '', type: lastAppListRouteType } }); diff --git a/projects/app/src/pageComponents/app/detail/Edit/FormComponent/ToolSelector/ToolSelect.tsx b/projects/app/src/pageComponents/app/detail/Edit/FormComponent/ToolSelector/ToolSelect.tsx index 6682937d6..bedda97fa 100644 --- a/projects/app/src/pageComponents/app/detail/Edit/FormComponent/ToolSelector/ToolSelect.tsx +++ b/projects/app/src/pageComponents/app/detail/Edit/FormComponent/ToolSelector/ToolSelect.tsx @@ -4,11 +4,9 @@ import MyIcon from '@fastgpt/web/components/common/Icon'; import { useTranslation } from 'next-i18next'; import QuestionTip from '@fastgpt/web/components/common/MyTooltip/QuestionTip'; import { SmallAddIcon } from '@chakra-ui/icons'; -import type { - SelectedToolItemType, - AppFormEditFormType, - AppFileSelectConfigType -} from '@fastgpt/global/core/app/type'; +import type { AppFileSelectConfigType } from '@fastgpt/global/core/app/type'; +import type { AppFormEditFormType } from '@fastgpt/global/core/app/formEdit/type'; +import type { SelectedToolItemType } from '@fastgpt/global/core/app/formEdit/type'; import MyTooltip from '@fastgpt/web/components/common/MyTooltip'; import { hoverDeleteStyles } from '@fastgpt/web/components/common/Icon/delete'; import ToolSelectModal from './ToolSelectModal'; @@ -22,7 +20,7 @@ import { PluginStatusEnum, PluginStatusMap } from '@fastgpt/global/core/plugin/t import MyTag from '@fastgpt/web/components/common/Tag/index'; import { checkNeedsUserConfiguration } from '../../ChatAgent/utils'; import MyIconButton from '@fastgpt/web/components/common/Icon/button'; -import type { LLMModelItemType } from '@fastgpt/global/core/ai/model.d'; +import type { LLMModelItemType } from '@fastgpt/global/core/ai/model'; const ToolSelect = ({ selectedModel, diff --git a/projects/app/src/pageComponents/app/detail/Edit/FormComponent/ToolSelector/ToolSelectModal.tsx b/projects/app/src/pageComponents/app/detail/Edit/FormComponent/ToolSelector/ToolSelectModal.tsx index 6c7b93601..167ef2c3a 100644 --- a/projects/app/src/pageComponents/app/detail/Edit/FormComponent/ToolSelector/ToolSelectModal.tsx +++ b/projects/app/src/pageComponents/app/detail/Edit/FormComponent/ToolSelector/ToolSelectModal.tsx @@ -9,7 +9,7 @@ import EmptyTip from '@fastgpt/web/components/common/EmptyTip'; import { type FlowNodeTemplateType, type NodeTemplateListItemType -} from '@fastgpt/global/core/workflow/type/node.d'; +} from '@fastgpt/global/core/workflow/type/node'; import MyIcon from '@fastgpt/web/components/common/Icon'; import { getToolPreviewNode, getAppToolTemplates, getAppToolPaths } from '@/web/core/app/api/tool'; import MyBox from '@fastgpt/web/components/common/MyBox'; @@ -25,9 +25,10 @@ import SearchInput from '@fastgpt/web/components/common/Input/SearchInput'; import { useMemoizedFn } from 'ahooks'; import MyAvatar from '@fastgpt/web/components/common/Avatar'; import { FlowNodeInputTypeEnum } from '@fastgpt/global/core/workflow/node/constant'; -import type { SelectedToolItemType, AppFormEditFormType } from '@fastgpt/global/core/app/type'; +import type { AppFormEditFormType } from '@fastgpt/global/core/app/formEdit/type'; +import type { SelectedToolItemType } from '@fastgpt/global/core/app/formEdit/type'; import { useToast } from '@fastgpt/web/hooks/useToast'; -import type { LLMModelItemType } from '@fastgpt/global/core/ai/model.d'; +import type { LLMModelItemType } from '@fastgpt/global/core/ai/model'; import { workflowStartNodeId } from '@/web/core/app/constants'; import CostTooltip from '@/components/core/app/tool/CostTooltip'; import { useSafeTranslation } from '@fastgpt/web/hooks/useSafeTranslation'; diff --git a/projects/app/src/pageComponents/app/detail/Edit/FormComponent/type.d.ts b/projects/app/src/pageComponents/app/detail/Edit/FormComponent/type.d.ts index 9c62bbe34..a48797359 100644 --- a/projects/app/src/pageComponents/app/detail/Edit/FormComponent/type.d.ts +++ b/projects/app/src/pageComponents/app/detail/Edit/FormComponent/type.d.ts @@ -1,4 +1,5 @@ -import type { AppChatConfigType, AppFormEditFormType } from '@fastgpt/global/core/app/type'; +import type { AppChatConfigType } from '@fastgpt/global/core/app/type'; +import type { AppFormEditFormType } from '@fastgpt/global/core/app/formEdit/type'; import type { WorkflowType } from '../ChatAgent/utils'; import type { StoreNodeItemType } from '@fastgpt/global/core/workflow/type/node'; diff --git a/projects/app/src/pageComponents/app/detail/Edit/FormComponent/useSnapshots.tsx b/projects/app/src/pageComponents/app/detail/Edit/FormComponent/useSnapshots.tsx index 3af5684bc..bedeffdcb 100644 --- a/projects/app/src/pageComponents/app/detail/Edit/FormComponent/useSnapshots.tsx +++ b/projects/app/src/pageComponents/app/detail/Edit/FormComponent/useSnapshots.tsx @@ -1,7 +1,7 @@ import { useMemoizedFn } from 'ahooks'; import { useRef, useState } from 'react'; import { formatTime2YMDHMS } from '@fastgpt/global/common/string/time'; -import { type AppFormEditFormType } from '@fastgpt/global/core/app/type'; +import type { AppFormEditFormType } from '@fastgpt/global/core/app/formEdit/type'; import { isEqual } from 'lodash'; export type SimpleAppSnapshotType = { diff --git a/projects/app/src/pageComponents/app/detail/Edit/HTTPTools/AppCard.tsx b/projects/app/src/pageComponents/app/detail/Edit/HTTPTools/AppCard.tsx index 1b7e3eb8b..be7e5599b 100644 --- a/projects/app/src/pageComponents/app/detail/Edit/HTTPTools/AppCard.tsx +++ b/projects/app/src/pageComponents/app/detail/Edit/HTTPTools/AppCard.tsx @@ -6,7 +6,7 @@ import Avatar from '@fastgpt/web/components/common/Avatar'; import { useTranslation } from 'next-i18next'; import MyIcon from '@fastgpt/web/components/common/Icon'; import MyMenu from '@fastgpt/web/components/common/MyMenu'; -import { type AppSchema } from '@fastgpt/global/core/app/type'; +import { type AppSchemaType } from '@fastgpt/global/core/app/type'; import TagsEditModal from '../../TagsEditModal'; const AppCard = () => { @@ -16,7 +16,7 @@ const AppCard = () => { const onOpenInfoEdit = useContextSelector(AppContext, (v) => v.onOpenInfoEdit); const onDelApp = useContextSelector(AppContext, (v) => v.onDelApp); - const [TeamTagsSet, setTeamTagsSet] = useState(); + const [TeamTagsSet, setTeamTagsSet] = useState(); return ( <> diff --git a/projects/app/src/pageComponents/app/detail/Edit/HTTPTools/ChatTest.tsx b/projects/app/src/pageComponents/app/detail/Edit/HTTPTools/ChatTest.tsx index 39ff8bd57..b352e1fd5 100644 --- a/projects/app/src/pageComponents/app/detail/Edit/HTTPTools/ChatTest.tsx +++ b/projects/app/src/pageComponents/app/detail/Edit/HTTPTools/ChatTest.tsx @@ -7,7 +7,7 @@ import ChatRecordContextProvider from '@/web/core/chat/context/chatRecordContext import { Box, Button, Center, Flex, HStack } from '@chakra-ui/react'; import { cardStyles } from '../../constants'; import { useTranslation } from 'next-i18next'; -import { type HttpToolConfigType } from '@fastgpt/global/core/app/type'; +import { type HttpToolConfigType } from '@fastgpt/global/core/app/tool/httpTool/type'; import { useForm } from 'react-hook-form'; import { useRequest2 } from '@fastgpt/web/hooks/useRequest'; import Markdown from '@/components/Markdown'; diff --git a/projects/app/src/pageComponents/app/detail/Edit/HTTPTools/Edit.tsx b/projects/app/src/pageComponents/app/detail/Edit/HTTPTools/Edit.tsx index 68efc2a0f..1cdca59fb 100644 --- a/projects/app/src/pageComponents/app/detail/Edit/HTTPTools/Edit.tsx +++ b/projects/app/src/pageComponents/app/detail/Edit/HTTPTools/Edit.tsx @@ -7,7 +7,7 @@ import AppCard from './AppCard'; import ChatTest from './ChatTest'; import MyBox from '@fastgpt/web/components/common/MyBox'; import EditForm from './EditForm'; -import { type HttpToolConfigType } from '@fastgpt/global/core/app/type'; +import { type HttpToolConfigType } from '@fastgpt/global/core/app/tool/httpTool/type'; import { useContextSelector } from 'use-context-selector'; import { AppContext } from '../../context'; import { FlowNodeTypeEnum } from '@fastgpt/global/core/workflow/node/constant'; diff --git a/projects/app/src/pageComponents/app/detail/Edit/HTTPTools/EditForm.tsx b/projects/app/src/pageComponents/app/detail/Edit/HTTPTools/EditForm.tsx index a41098b61..54c29851a 100644 --- a/projects/app/src/pageComponents/app/detail/Edit/HTTPTools/EditForm.tsx +++ b/projects/app/src/pageComponents/app/detail/Edit/HTTPTools/EditForm.tsx @@ -16,7 +16,7 @@ import { useRequest2 } from '@fastgpt/web/hooks/useRequest'; import { AppContext } from '../../context'; import { useContextSelector } from 'use-context-selector'; import MyIconButton from '@fastgpt/web/components/common/Icon/button'; -import { type HttpToolConfigType } from '@fastgpt/global/core/app/type'; +import { type HttpToolConfigType } from '@fastgpt/global/core/app/tool/httpTool/type'; import MyModal from '@fastgpt/web/components/common/MyModal'; import Avatar from '@fastgpt/web/components/common/Avatar'; import MyBox from '@fastgpt/web/components/common/MyBox'; diff --git a/projects/app/src/pageComponents/app/detail/Edit/HTTPTools/Header.tsx b/projects/app/src/pageComponents/app/detail/Edit/HTTPTools/Header.tsx index dddde80ca..ca089b4b0 100644 --- a/projects/app/src/pageComponents/app/detail/Edit/HTTPTools/Header.tsx +++ b/projects/app/src/pageComponents/app/detail/Edit/HTTPTools/Header.tsx @@ -8,6 +8,7 @@ import { getAppFolderPath } from '@/web/core/app/api/app'; import { useCallback } from 'react'; import { useRouter } from 'next/router'; import { useSystemStore } from '@/web/common/system/useSystemStore'; +import type { ParentIdType } from '@fastgpt/global/common/parentFolder/type'; const Header = () => { const { t } = useTranslation(); @@ -25,11 +26,11 @@ const Header = () => { ); const onClickRoute = useCallback( - (parentId: string) => { + (parentId: ParentIdType) => { router.push({ pathname: '/dashboard/tool', query: { - parentId, + parentId: parentId || '', type: lastAppListRouteType } }); diff --git a/projects/app/src/pageComponents/app/detail/Edit/HTTPTools/ManualToolModal.tsx b/projects/app/src/pageComponents/app/detail/Edit/HTTPTools/ManualToolModal.tsx index 0bd7ad381..97be9d693 100644 --- a/projects/app/src/pageComponents/app/detail/Edit/HTTPTools/ManualToolModal.tsx +++ b/projects/app/src/pageComponents/app/detail/Edit/HTTPTools/ManualToolModal.tsx @@ -47,7 +47,7 @@ import type { StoreSecretValueType } from '@fastgpt/global/common/secret/type'; import MyIcon from '@fastgpt/web/components/common/Icon'; import HttpInput from '@fastgpt/web/components/common/Input/HttpInput'; import { putUpdateHttpPlugin } from '@/web/core/app/api/tool'; -import type { HttpToolConfigType } from '@fastgpt/global/core/app/type'; +import type { HttpToolConfigType } from '@fastgpt/global/core/app/tool/httpTool/type'; import { FlowNodeTypeEnum } from '@fastgpt/global/core/workflow/node/constant'; import CurlImportModal from './CurlImportModal'; import { useSystemStore } from '@/web/common/system/useSystemStore'; diff --git a/projects/app/src/pageComponents/app/detail/Edit/MCPTools/AppCard.tsx b/projects/app/src/pageComponents/app/detail/Edit/MCPTools/AppCard.tsx index 1b7e3eb8b..be7e5599b 100644 --- a/projects/app/src/pageComponents/app/detail/Edit/MCPTools/AppCard.tsx +++ b/projects/app/src/pageComponents/app/detail/Edit/MCPTools/AppCard.tsx @@ -6,7 +6,7 @@ import Avatar from '@fastgpt/web/components/common/Avatar'; import { useTranslation } from 'next-i18next'; import MyIcon from '@fastgpt/web/components/common/Icon'; import MyMenu from '@fastgpt/web/components/common/MyMenu'; -import { type AppSchema } from '@fastgpt/global/core/app/type'; +import { type AppSchemaType } from '@fastgpt/global/core/app/type'; import TagsEditModal from '../../TagsEditModal'; const AppCard = () => { @@ -16,7 +16,7 @@ const AppCard = () => { const onOpenInfoEdit = useContextSelector(AppContext, (v) => v.onOpenInfoEdit); const onDelApp = useContextSelector(AppContext, (v) => v.onDelApp); - const [TeamTagsSet, setTeamTagsSet] = useState(); + const [TeamTagsSet, setTeamTagsSet] = useState(); return ( <> diff --git a/projects/app/src/pageComponents/app/detail/Edit/MCPTools/Header.tsx b/projects/app/src/pageComponents/app/detail/Edit/MCPTools/Header.tsx index 5b4167765..70017665d 100644 --- a/projects/app/src/pageComponents/app/detail/Edit/MCPTools/Header.tsx +++ b/projects/app/src/pageComponents/app/detail/Edit/MCPTools/Header.tsx @@ -11,6 +11,7 @@ import { useSystemStore } from '@/web/common/system/useSystemStore'; import { type McpToolConfigType } from '@fastgpt/global/core/app/tool/mcpTool/type'; import { postUpdateMCPTools } from '@/web/core/app/api/tool'; import { type StoreSecretValueType } from '@fastgpt/global/common/secret/type'; +import type { ParentIdType } from '@fastgpt/global/common/parentFolder/type'; const Header = ({ url, @@ -36,11 +37,11 @@ const Header = ({ ); const onClickRoute = useCallback( - (parentId: string) => { + (parentId: ParentIdType) => { router.push({ pathname: '/dashboard/tool', query: { - parentId, + parentId: parentId || '', type: lastAppListRouteType } }); diff --git a/projects/app/src/pageComponents/app/detail/Edit/SimpleApp/Edit.tsx b/projects/app/src/pageComponents/app/detail/Edit/SimpleApp/Edit.tsx index e6f787f77..cd0ae50f8 100644 --- a/projects/app/src/pageComponents/app/detail/Edit/SimpleApp/Edit.tsx +++ b/projects/app/src/pageComponents/app/detail/Edit/SimpleApp/Edit.tsx @@ -3,7 +3,7 @@ import { Box } from '@chakra-ui/react'; import AppCard from '../FormComponent/AppCard'; import EditForm from './EditForm'; -import { type AppFormEditFormType } from '@fastgpt/global/core/app/type'; +import type { AppFormEditFormType } from '@fastgpt/global/core/app/formEdit/type'; import { cardStyles } from '../../constants'; import styles from '../FormComponent/styles.module.scss'; diff --git a/projects/app/src/pageComponents/app/detail/Edit/SimpleApp/EditForm.tsx b/projects/app/src/pageComponents/app/detail/Edit/SimpleApp/EditForm.tsx index 317c53ebc..59a2b0713 100644 --- a/projects/app/src/pageComponents/app/detail/Edit/SimpleApp/EditForm.tsx +++ b/projects/app/src/pageComponents/app/detail/Edit/SimpleApp/EditForm.tsx @@ -9,7 +9,7 @@ import { Button, HStack } from '@chakra-ui/react'; -import type { AppFormEditFormType } from '@fastgpt/global/core/app/type.d'; +import type { AppFormEditFormType } from '@fastgpt/global/core/app/formEdit/type'; import { useRouter } from 'next/router'; import { useTranslation } from 'next-i18next'; @@ -473,9 +473,9 @@ const EditForm = ({ ({ datasetId: item.datasetId, - vectorModel: item.vectorModel, name: item.name, - avatar: item.avatar + avatar: item.avatar, + vectorModel: item.vectorModel }))} onClose={onCloseDatasetSelect} onChange={(e) => { diff --git a/projects/app/src/pageComponents/app/detail/Edit/SimpleApp/utils.ts b/projects/app/src/pageComponents/app/detail/Edit/SimpleApp/utils.ts index ccf76e5f9..ca5bcefc2 100644 --- a/projects/app/src/pageComponents/app/detail/Edit/SimpleApp/utils.ts +++ b/projects/app/src/pageComponents/app/detail/Edit/SimpleApp/utils.ts @@ -1,5 +1,6 @@ -import { type AppChatConfigType, type AppFormEditFormType } from '@fastgpt/global/core/app/type'; -import { type StoreNodeItemType } from '@fastgpt/global/core/workflow/type/node.d'; +import type { AppChatConfigType } from '@fastgpt/global/core/app/type'; +import type { AppFormEditFormType } from '@fastgpt/global/core/app/formEdit/type'; +import { type StoreNodeItemType } from '@fastgpt/global/core/workflow/type/node'; import { FlowNodeInputTypeEnum, FlowNodeTypeEnum @@ -36,6 +37,7 @@ import { DatasetSearchModeEnum } from '@fastgpt/global/core/dataset/constants'; import { getAppChatConfig } from '@fastgpt/global/core/workflow/utils'; import { getDefaultAppForm } from '@fastgpt/global/core/app/utils'; import type { FlowNodeInputItemType } from '@fastgpt/global/core/workflow/type/io'; +import { LLMModelTypeEnum } from '@fastgpt/global/core/ai/constants'; /* format app nodes to edit form */ export const appWorkflow2Form = ({ @@ -593,7 +595,7 @@ export function form2AppWorkflow( ], label: 'core.module.input.label.aiModel', valueType: WorkflowIOValueTypeEnum.string, - llmModelType: 'all', + llmModelType: LLMModelTypeEnum.all, value: formData.aiSettings.model }, { diff --git a/projects/app/src/pageComponents/app/detail/Edit/component/ConfigToolModal.tsx b/projects/app/src/pageComponents/app/detail/Edit/component/ConfigToolModal.tsx index 466df63ba..605667752 100644 --- a/projects/app/src/pageComponents/app/detail/Edit/component/ConfigToolModal.tsx +++ b/projects/app/src/pageComponents/app/detail/Edit/component/ConfigToolModal.tsx @@ -4,7 +4,6 @@ import React from 'react'; import { useTranslation } from 'next-i18next'; import MyIcon from '@fastgpt/web/components/common/Icon'; import { Box } from '@chakra-ui/react'; -import { type AppFormEditFormType } from '@fastgpt/global/core/app/type'; import { childAppSystemKey } from '../FormComponent/ToolSelector/ToolSelectModal'; import { Controller, useForm } from 'react-hook-form'; import { WorkflowIOValueTypeEnum } from '@fastgpt/global/core/workflow/constants'; diff --git a/projects/app/src/pageComponents/app/detail/ExportConfigPopover.tsx b/projects/app/src/pageComponents/app/detail/ExportConfigPopover.tsx index ead4ed108..92e957a9c 100644 --- a/projects/app/src/pageComponents/app/detail/ExportConfigPopover.tsx +++ b/projects/app/src/pageComponents/app/detail/ExportConfigPopover.tsx @@ -6,7 +6,8 @@ import { filterSensitiveNodesData } from '@/web/core/workflow/utils'; import { useCopyData } from '@fastgpt/web/hooks/useCopyData'; import MyPopover from '@fastgpt/web/components/common/MyPopover'; import { fileDownload } from '@/web/common/file/utils'; -import { type AppChatConfigType, type AppFormEditFormType } from '@fastgpt/global/core/app/type'; +import type { AppChatConfigType } from '@fastgpt/global/core/app/type'; +import type { AppFormEditFormType } from '@fastgpt/global/core/app/formEdit/type'; import MyBox from '@fastgpt/web/components/common/MyBox'; import { filterSensitiveFormData } from '@/web/core/app/utils'; import { type RequireOnlyOne } from '@fastgpt/global/common/type/utils'; diff --git a/projects/app/src/pageComponents/app/detail/InfoModal.tsx b/projects/app/src/pageComponents/app/detail/InfoModal.tsx index 82deaa627..5fce27994 100644 --- a/projects/app/src/pageComponents/app/detail/InfoModal.tsx +++ b/projects/app/src/pageComponents/app/detail/InfoModal.tsx @@ -18,7 +18,7 @@ import { Textarea } from '@chakra-ui/react'; import type { RequireOnlyOne } from '@fastgpt/global/common/type/utils'; -import type { AppSchema } from '@fastgpt/global/core/app/type.d'; +import type { AppSchemaType } from '@fastgpt/global/core/app/type'; import { AppRoleList } from '@fastgpt/global/support/permission/app/constant'; import Avatar from '@fastgpt/web/components/common/Avatar'; import MyIcon from '@fastgpt/web/components/common/Icon'; @@ -56,7 +56,7 @@ const InfoModal = ({ onClose }: { onClose: () => void }) => { // submit config const { runAsync: saveSubmitSuccess, loading: btnLoading } = useRequest2( - async (data: AppSchema) => { + async (data: AppSchemaType) => { await updateAppDetail({ name: data.name, avatar: data.avatar, diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/ChatTest.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/ChatTest.tsx index a4983d396..d6c0efd05 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/ChatTest.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/ChatTest.tsx @@ -1,4 +1,4 @@ -import type { StoreNodeItemType } from '@fastgpt/global/core/workflow/type/node.d'; +import type { StoreNodeItemType } from '@fastgpt/global/core/workflow/type/node'; import React, { useMemo } from 'react'; import { SmallCloseIcon } from '@chakra-ui/icons'; import { Box, Flex, IconButton } from '@chakra-ui/react'; diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/NodeTemplatesModal.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/NodeTemplatesModal.tsx index 8cb45319c..e099e6e66 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/NodeTemplatesModal.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/NodeTemplatesModal.tsx @@ -1,4 +1,4 @@ -import type { FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node.d'; +import type { FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node'; import { type Node } from 'reactflow'; import NodeTemplateListHeader from './components/NodeTemplates/header'; import NodeTemplateList from './components/NodeTemplates/list'; diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/components/ButtonEdge.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/components/ButtonEdge.tsx index da8824785..be953206e 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/components/ButtonEdge.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/components/ButtonEdge.tsx @@ -2,7 +2,7 @@ import React, { useCallback, useMemo, useState } from 'react'; import { BezierEdge, getBezierPath, EdgeLabelRenderer, type EdgeProps } from 'reactflow'; import { Box, Flex } from '@chakra-ui/react'; import MyIcon from '@fastgpt/web/components/common/Icon'; -import { NodeOutputKeyEnum, RuntimeEdgeStatusEnum } from '@fastgpt/global/core/workflow/constants'; +import { NodeOutputKeyEnum } from '@fastgpt/global/core/workflow/constants'; import { useContextSelector } from 'use-context-selector'; import { useThrottleEffect } from 'ahooks'; import { @@ -117,9 +117,9 @@ const ButtonEdge = (props: EdgeProps) => { // debug mode const colorMap = { - [RuntimeEdgeStatusEnum.active]: '#487FFF', - [RuntimeEdgeStatusEnum.waiting]: '#5E8FFF', - [RuntimeEdgeStatusEnum.skipped]: '#8A95A7' + active: '#487FFF', + waiting: '#5E8FFF', + skipped: '#8A95A7' }; return colorMap[targetEdge.status]; }, [highlightEdge, sourceHandleId, targetHandleId, workflowDebugData?.runtimeEdges]); diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/components/NodeTemplates/header.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/components/NodeTemplates/header.tsx index 5e2bf7971..b879a8927 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/components/NodeTemplates/header.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/components/NodeTemplates/header.tsx @@ -29,7 +29,7 @@ export type NodeTemplateListHeaderProps = { searchKey: string; setSearchKey: Dispatch>; onUpdateTemplateType: (type: TemplateTypeEnum) => void; - onUpdateParentId: (parentId: string) => void; + onUpdateParentId: (parentId: ParentIdType) => void; selectedTagIds: string[]; setSelectedTagIds: (e: string[]) => any; diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/index.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/index.tsx index 4b9a423bb..06b1edc19 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/index.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/index.tsx @@ -2,7 +2,7 @@ import dynamic from 'next/dynamic'; import ButtonEdge from './components/ButtonEdge'; import NodeTemplatesModal from './NodeTemplatesModal'; import 'reactflow/dist/style.css'; -import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node.d'; +import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node'; import { connectionLineStyle, defaultEdgeOptions, maxZoom, minZoom } from '../constants'; import 'reactflow/dist/style.css'; import { useContextSelector } from 'use-context-selector'; diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeAnswer.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeAnswer.tsx index af66a1e5a..9b37d5ff5 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeAnswer.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeAnswer.tsx @@ -1,7 +1,7 @@ import React, { useMemo } from 'react'; import { type NodeProps } from 'reactflow'; import NodeCard from './render/NodeCard'; -import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node.d'; +import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node'; import Container from '../components/Container'; import RenderInput from './render/RenderInput'; diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeCQNode.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeCQNode.tsx index ef4194914..8aa01e7c9 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeCQNode.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeCQNode.tsx @@ -2,7 +2,7 @@ import React, { useMemo } from 'react'; import { type NodeProps, Position } from 'reactflow'; import { Box, Button, Flex, Textarea } from '@chakra-ui/react'; import NodeCard from './render/NodeCard'; -import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node.d'; +import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node'; import Container from '../components/Container'; import RenderInput from './render/RenderInput'; import type { ClassifyQuestionAgentItemType } from '@fastgpt/global/core/workflow/template/system/classifyQuestion/type'; @@ -10,7 +10,7 @@ import MyIcon from '@fastgpt/web/components/common/Icon'; import { NodeInputKeyEnum } from '@fastgpt/global/core/workflow/constants'; import { useTranslation } from 'next-i18next'; import MyTooltip from '@fastgpt/web/components/common/MyTooltip'; -import { type FlowNodeInputItemType } from '@fastgpt/global/core/workflow/type/io.d'; +import { type FlowNodeInputItemType } from '@fastgpt/global/core/workflow/type/io'; import { getNanoid } from '@fastgpt/global/common/string/tools'; import { MySourceHandle } from './render/Handle'; import { getHandleId } from '@fastgpt/global/core/workflow/utils'; diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeCode/index.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeCode/index.tsx index f3a10b78a..6c1bf74f8 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeCode/index.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeCode/index.tsx @@ -1,12 +1,12 @@ import React, { useMemo } from 'react'; import { type NodeProps } from 'reactflow'; import NodeCard from '../render/NodeCard'; -import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node.d'; +import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node'; import Container from '../../components/Container'; import RenderInput from '../render/RenderInput'; import { NodeInputKeyEnum } from '@fastgpt/global/core/workflow/constants'; import { useTranslation } from 'next-i18next'; -import { type FlowNodeInputItemType } from '@fastgpt/global/core/workflow/type/io.d'; +import { type FlowNodeInputItemType } from '@fastgpt/global/core/workflow/type/io'; import { useContextSelector } from 'use-context-selector'; import IOTitle from '../../components/IOTitle'; import RenderToolInput from '../render/RenderToolInput'; diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeDatasetConcat.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeDatasetConcat.tsx index 7f9459180..74855892a 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeDatasetConcat.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeDatasetConcat.tsx @@ -1,7 +1,7 @@ import React, { useCallback, useMemo } from 'react'; import { type NodeProps } from 'reactflow'; import NodeCard from './render/NodeCard'; -import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node.d'; +import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node'; import Container from '../components/Container'; import RenderInput from './render/RenderInput'; import { Box, Button, Flex, HStack } from '@chakra-ui/react'; @@ -12,7 +12,7 @@ import { getOneQuoteInputTemplate } from '@fastgpt/global/core/workflow/template import { type FlowNodeInputItemType, type ReferenceItemValueType -} from '@fastgpt/global/core/workflow/type/io.d'; +} from '@fastgpt/global/core/workflow/type/io'; import RenderOutput from './render/RenderOutput'; import IOTitle from '../components/IOTitle'; import { useContextSelector } from 'use-context-selector'; diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeEmpty.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeEmpty.tsx index 6da8b4a62..c49ea4e85 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeEmpty.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeEmpty.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { type NodeProps } from 'reactflow'; import NodeCard from './render/NodeCard'; -import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node.d'; +import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node'; const NodeEmpty = ({ data, selected }: NodeProps) => { return ; diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeExtract/index.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeExtract/index.tsx index cc84da614..0d3a12631 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeExtract/index.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeExtract/index.tsx @@ -12,7 +12,7 @@ import { Flex } from '@chakra-ui/react'; import { type NodeProps } from 'reactflow'; -import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node.d'; +import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node'; import { useTranslation } from 'next-i18next'; import NodeCard from '../render/NodeCard'; import Container from '../../components/Container'; @@ -29,7 +29,7 @@ import RenderToolInput from '../render/RenderToolInput'; import { type FlowNodeInputItemType, type FlowNodeOutputItemType -} from '@fastgpt/global/core/workflow/type/io.d'; +} from '@fastgpt/global/core/workflow/type/io'; import { getNanoid } from '@fastgpt/global/common/string/tools'; import IOTitle from '../../components/IOTitle'; import { useContextSelector } from 'use-context-selector'; diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeHttp/CurlImportModal.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeHttp/CurlImportModal.tsx index 155a8b4b5..9a9e4acad 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeHttp/CurlImportModal.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeHttp/CurlImportModal.tsx @@ -3,7 +3,7 @@ import MyModal from '@fastgpt/web/components/common/MyModal'; import { ModalBody, Button, ModalFooter, Textarea } from '@chakra-ui/react'; import { useTranslation } from 'next-i18next'; import { NodeInputKeyEnum } from '@fastgpt/global/core/workflow/constants'; -import { type FlowNodeInputItemType } from '@fastgpt/global/core/workflow/type/io.d'; +import { type FlowNodeInputItemType } from '@fastgpt/global/core/workflow/type/io'; import { useToast } from '@fastgpt/web/hooks/useToast'; import { useForm } from 'react-hook-form'; import { useContextSelector } from 'use-context-selector'; diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeHttp/index.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeHttp/index.tsx index bf059f5c3..f4f3c71e6 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeHttp/index.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeHttp/index.tsx @@ -1,7 +1,7 @@ import React, { useCallback, useEffect, useMemo, useState, useTransition } from 'react'; import { type NodeProps } from 'reactflow'; import NodeCard from '../render/NodeCard'; -import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node.d'; +import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node'; import Container from '../../components/Container'; import RenderInput from '../render/RenderInput'; import RenderOutput from '../render/RenderOutput'; @@ -32,7 +32,7 @@ import { import { useTranslation } from 'next-i18next'; import LightRowTabs from '@fastgpt/web/components/common/Tabs/LightRowTabs'; import MyIcon from '@fastgpt/web/components/common/Icon'; -import { type FlowNodeInputItemType } from '@fastgpt/global/core/workflow/type/io.d'; +import { type FlowNodeInputItemType } from '@fastgpt/global/core/workflow/type/io'; import { useToast } from '@fastgpt/web/hooks/useToast'; import { type EditorVariableLabelPickerType } from '@fastgpt/web/components/common/Textarea/PromptEditor/type'; import HttpInput from '@fastgpt/web/components/common/Input/HttpInput'; diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeLaf.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeLaf.tsx index 79e80cb7c..57d11d20f 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeLaf.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeLaf.tsx @@ -1,7 +1,7 @@ import React, { useMemo } from 'react'; import { type NodeProps } from 'reactflow'; import NodeCard from './render/NodeCard'; -import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node.d'; +import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node'; import Container from '../components/Container'; import { Box, Button, Center, Flex, useDisclosure } from '@chakra-ui/react'; import { NodeInputKeyEnum } from '@fastgpt/global/core/workflow/constants'; diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodePluginIO/InputTypeConfig.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodePluginIO/InputTypeConfig.tsx index 2d61ad17e..c5ed349f9 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodePluginIO/InputTypeConfig.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodePluginIO/InputTypeConfig.tsx @@ -41,7 +41,7 @@ import { useSystemStore } from '@/web/common/system/useSystemStore'; import FormLabel from '@fastgpt/web/components/common/MyBox/FormLabel'; import RadioGroup from '@fastgpt/web/components/common/Radio/RadioGroup'; import { DatasetSelectModal } from '@/components/core/app/DatasetSelectModal'; -import type { EmbeddingModelItemType } from '@fastgpt/global/core/ai/model.d'; +import type { EmbeddingModelItemType } from '@fastgpt/global/core/ai/model'; import AIModelSelector from '@/components/Select/AIModelSelector'; import { useMemoEnhance } from '@fastgpt/web/hooks/useMemoEnhance'; import { formatTime2YMDHMS } from '@fastgpt/global/common/string/time'; @@ -1010,8 +1010,7 @@ const InputTypeConfig = ({ defaultSelectedDatasets={datasetOptions.map((item: SelectedDatasetType) => ({ datasetId: item.datasetId, name: item.name, - avatar: item.avatar, - vectorModel: {} as EmbeddingModelItemType + avatar: item.avatar }))} onChange={(selectedDatasets) => { const newDatasetList = selectedDatasets.map((item: SelectedDatasetType) => ({ diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodePluginIO/NodePluginConfig.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodePluginIO/NodePluginConfig.tsx index 9851be73e..a9efafa61 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodePluginIO/NodePluginConfig.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodePluginIO/NodePluginConfig.tsx @@ -1,7 +1,7 @@ import React, { type Dispatch, useMemo } from 'react'; import { type NodeProps } from 'reactflow'; import NodeCard from '../render/NodeCard'; -import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node.d'; +import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node'; import { Flex } from '@chakra-ui/react'; import Container from '../../components/Container'; import { useTranslation } from 'next-i18next'; diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodePluginIO/PluginInput.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodePluginIO/PluginInput.tsx index f0215e664..1b38abd7b 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodePluginIO/PluginInput.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodePluginIO/PluginInput.tsx @@ -1,13 +1,13 @@ import React, { useCallback, useMemo, useState } from 'react'; import { type NodeProps } from 'reactflow'; import NodeCard from '../render/NodeCard'; -import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node.d'; +import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node'; import { Box, Button, HStack } from '@chakra-ui/react'; import { SmallAddIcon } from '@chakra-ui/icons'; import { type FlowNodeInputItemType, type FlowNodeOutputItemType -} from '@fastgpt/global/core/workflow/type/io.d'; +} from '@fastgpt/global/core/workflow/type/io'; import Container from '../../components/Container'; import { useTranslation } from 'next-i18next'; import { diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodePluginIO/PluginOutput.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodePluginIO/PluginOutput.tsx index 649f128a7..7498ebbc3 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodePluginIO/PluginOutput.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodePluginIO/PluginOutput.tsx @@ -1,7 +1,7 @@ import React, { useCallback, useState } from 'react'; import { type NodeProps } from 'reactflow'; import NodeCard from '../render/NodeCard'; -import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node.d'; +import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node'; import { Box, Button, Flex } from '@chakra-ui/react'; import { SmallAddIcon } from '@chakra-ui/icons'; import Container from '../../components/Container'; diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeSimple.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeSimple.tsx index e45f55262..84e75bc80 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeSimple.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeSimple.tsx @@ -1,7 +1,7 @@ import React, { useMemo } from 'react'; import { type NodeProps } from 'reactflow'; import NodeCard from './render/NodeCard'; -import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node.d'; +import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node'; import Container from '../components/Container'; import RenderInput from './render/RenderInput'; import RenderOutput from './render/RenderOutput'; diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeSystemConfig.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeSystemConfig.tsx index 4ecfa026b..3d4eade9a 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeSystemConfig.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeSystemConfig.tsx @@ -1,7 +1,7 @@ import React, { type Dispatch, useCallback, useMemo } from 'react'; import { type NodeProps, useViewport } from 'reactflow'; import { Box } from '@chakra-ui/react'; -import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node.d'; +import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node'; import QGConfig from '@/components/core/app/QGConfig'; import TTSSelect from '@/components/core/app/TTSSelect'; diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeToolCall.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeToolCall.tsx index 31bf09e98..1314e6f0f 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeToolCall.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeToolCall.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { type NodeProps } from 'reactflow'; import NodeCard from './render/NodeCard'; -import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node.d'; +import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node'; import Divider from '../components/Divider'; import Container from '../components/Container'; import RenderInput from './render/RenderInput'; diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeUserSelect.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeUserSelect.tsx index 1a426bc8b..323ad6153 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeUserSelect.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeUserSelect.tsx @@ -2,14 +2,14 @@ import React, { useMemo } from 'react'; import { type NodeProps, Position, useViewport } from 'reactflow'; import { Box, Button, HStack, Input } from '@chakra-ui/react'; import NodeCard from './render/NodeCard'; -import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node.d'; +import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node'; import Container from '../components/Container'; import RenderInput from './render/RenderInput'; import MyIcon from '@fastgpt/web/components/common/Icon'; import { NodeInputKeyEnum } from '@fastgpt/global/core/workflow/constants'; import { useTranslation } from 'next-i18next'; import MyTooltip from '@fastgpt/web/components/common/MyTooltip'; -import { type FlowNodeInputItemType } from '@fastgpt/global/core/workflow/type/io.d'; +import { type FlowNodeInputItemType } from '@fastgpt/global/core/workflow/type/io'; import { getNanoid } from '@fastgpt/global/common/string/tools'; import { MySourceHandle } from './render/Handle'; import { getHandleId } from '@fastgpt/global/core/workflow/utils'; diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeWorkflowStart.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeWorkflowStart.tsx index 18ac297a2..1c8d6abf0 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeWorkflowStart.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeWorkflowStart.tsx @@ -1,7 +1,7 @@ import React, { useMemo } from 'react'; import { type NodeProps } from 'reactflow'; import NodeCard from './render/NodeCard'; -import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node.d'; +import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node'; import Container from '../components/Container'; import RenderOutput from './render/RenderOutput'; import IOTitle from '../components/IOTitle'; diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/NodeCard.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/NodeCard.tsx index deeccb994..eae38c04d 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/NodeCard.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/NodeCard.tsx @@ -2,10 +2,7 @@ import React, { useCallback, useMemo } from 'react'; import { Box, Button, Flex, useDisclosure, type FlexProps } from '@chakra-ui/react'; import MyIcon from '@fastgpt/web/components/common/Icon'; import Avatar from '@fastgpt/web/components/common/Avatar'; -import type { - FlowNodeItemType, - StoreNodeItemType -} from '@fastgpt/global/core/workflow/type/node.d'; +import type { FlowNodeItemType, StoreNodeItemType } from '@fastgpt/global/core/workflow/type/node'; import { useTranslation } from 'next-i18next'; import { useEditTitle } from '@/web/common/hooks/useEditTitle'; import { useToast } from '@fastgpt/web/hooks/useToast'; diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderDebug/NodeDebugResponse.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderDebug/NodeDebugResponse.tsx index 99bc6b53a..53506b3c8 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderDebug/NodeDebugResponse.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderDebug/NodeDebugResponse.tsx @@ -5,7 +5,7 @@ import MyIcon from '@fastgpt/web/components/common/Icon'; import { useContextSelector } from 'use-context-selector'; import EmptyTip from '@fastgpt/web/components/common/EmptyTip'; import { WholeResponseContent } from '@/components/core/chat/components/WholeResponseModal'; -import type { FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node.d'; +import type { FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node'; import { FormInputComponent, SelectOptionsComponent @@ -95,7 +95,7 @@ const NodeDebugResponse = ({ nodeId, debugResult }: NodeDebugResponseProps) => { const response = debugResult?.response; - const interactive = debugResult?.workflowInteractiveResponse; + const interactive = debugResult?.interactiveResponse; const onNextInteractive = useCallback( (userContent: string) => { if (!workflowDebugData || !workflowDebugData || !interactive) return; @@ -113,9 +113,9 @@ const NodeDebugResponse = ({ nodeId, debugResult }: NodeDebugResponseProps) => { { interactive: { ...interactive, - entryNodeIds: workflowDebugData.entryNodeIds || [], - memoryEdges: interactive.memoryEdges || [], - nodeOutputs: interactive.nodeOutputs || [] + entryNodeIds: workflowDebugData.entryNodeIds, + memoryEdges: [], + nodeOutputs: [] } } ] diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderInput/Label.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderInput/Label.tsx index 2d5e7db73..cb87af11b 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderInput/Label.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderInput/Label.tsx @@ -1,4 +1,4 @@ -import { type FlowNodeInputItemType } from '@fastgpt/global/core/workflow/type/io.d'; +import { type FlowNodeInputItemType } from '@fastgpt/global/core/workflow/type/io'; import React, { useCallback } from 'react'; import { useTranslation } from 'next-i18next'; import { Box, Flex } from '@chakra-ui/react'; diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderInput/index.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderInput/index.tsx index 62fd0da7c..f0d4f0107 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderInput/index.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderInput/index.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import type { FlowNodeInputItemType } from '@fastgpt/global/core/workflow/type/io.d'; +import type { FlowNodeInputItemType } from '@fastgpt/global/core/workflow/type/io'; import { Box } from '@chakra-ui/react'; import { FlowNodeInputTypeEnum } from '@fastgpt/global/core/workflow/node/constant'; import dynamic from 'next/dynamic'; diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderInput/templates/SelectDataset.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderInput/templates/SelectDataset.tsx index feadfcb6a..5fc606c96 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderInput/templates/SelectDataset.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderInput/templates/SelectDataset.tsx @@ -97,9 +97,9 @@ export const SelectDatasetRender = React.memo(function SelectDatasetRender({ ({ datasetId: item.datasetId, - vectorModel: item.vectorModel, name: item.name, - avatar: item.avatar + avatar: item.avatar, + vectorModel: item.vectorModel }))} onChange={(e) => { onChangeNode({ diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderInput/templates/SettingLLMModel.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderInput/templates/SettingLLMModel.tsx index 02267b7bb..a07b86790 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderInput/templates/SettingLLMModel.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderInput/templates/SettingLLMModel.tsx @@ -1,6 +1,6 @@ import React, { useCallback, useMemo } from 'react'; import type { RenderInputProps } from '../type'; -import type { SettingAIDataType } from '@fastgpt/global/core/app/type.d'; +import type { SettingAIDataType } from '@fastgpt/global/core/app/type'; import SettingLLMModel from '@/components/core/ai/SettingLLMModel'; import { NodeInputKeyEnum } from '@fastgpt/global/core/workflow/constants'; import { useContextSelector } from 'use-context-selector'; diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderInput/type.d.ts b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderInput/type.d.ts index 4fe2544ea..f395a592c 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderInput/type.d.ts +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderInput/type.d.ts @@ -1,4 +1,4 @@ -import type { FlowNodeInputItemType } from '@fastgpt/global/core/workflow/type/io.d'; +import type { FlowNodeInputItemType } from '@fastgpt/global/core/workflow/type/io'; export type RenderInputProps = { inputs?: FlowNodeInputItemType[]; diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderOutput/CatchError.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderOutput/CatchError.tsx index 7ccb7b695..31392faff 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderOutput/CatchError.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderOutput/CatchError.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import type { FlowNodeOutputItemType } from '@fastgpt/global/core/workflow/type/io.d'; +import type { FlowNodeOutputItemType } from '@fastgpt/global/core/workflow/type/io'; import Container from '../../../components/Container'; import RenderOutput from '.'; import { ConnectionSourceHandle } from '../Handle/ConnectionHandle'; diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderOutput/DynamicOutputs.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderOutput/DynamicOutputs.tsx index 79dc05893..22f72c7b4 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderOutput/DynamicOutputs.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderOutput/DynamicOutputs.tsx @@ -1,5 +1,5 @@ import React, { useMemo, useState, useCallback } from 'react'; -import type { FlowNodeOutputItemType } from '@fastgpt/global/core/workflow/type/io.d'; +import type { FlowNodeOutputItemType } from '@fastgpt/global/core/workflow/type/io'; import { Box, Flex, Input, HStack } from '@chakra-ui/react'; import { FlowNodeOutputTypeEnum, diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderOutput/Label.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderOutput/Label.tsx index c882790c4..88bdd78e6 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderOutput/Label.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderOutput/Label.tsx @@ -1,4 +1,4 @@ -import { type FlowNodeOutputItemType } from '@fastgpt/global/core/workflow/type/io.d'; +import { type FlowNodeOutputItemType } from '@fastgpt/global/core/workflow/type/io'; import React from 'react'; import { useTranslation } from 'next-i18next'; import { Box, Flex } from '@chakra-ui/react'; diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderOutput/index.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderOutput/index.tsx index b9d4c7078..33dfde26d 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderOutput/index.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderOutput/index.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useMemo } from 'react'; -import type { FlowNodeOutputItemType } from '@fastgpt/global/core/workflow/type/io.d'; +import type { FlowNodeOutputItemType } from '@fastgpt/global/core/workflow/type/io'; import { FlowNodeOutputTypeEnum } from '@fastgpt/global/core/workflow/node/constant'; import { NodeOutputKeyEnum } from '@fastgpt/global/core/workflow/constants'; import OutputLabel from './Label'; diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderOutput/type.d.ts b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderOutput/type.d.ts index 1979eaa98..d5d1e0531 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderOutput/type.d.ts +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderOutput/type.d.ts @@ -1,4 +1,4 @@ -import type { FlowNodeOutputItemType } from '@fastgpt/global/core/workflow/type/io.d'; +import type { FlowNodeOutputItemType } from '@fastgpt/global/core/workflow/type/io'; export type RenderOutputProps = { outputs?: FlowNodeOutputItemType[]; diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderToolInput/EditFieldModal.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderToolInput/EditFieldModal.tsx index 10b920f4d..f30a0bf9e 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderToolInput/EditFieldModal.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderToolInput/EditFieldModal.tsx @@ -16,7 +16,7 @@ import { useForm } from 'react-hook-form'; import MySelect from '@fastgpt/web/components/common/MySelect'; import { useRequest } from '@fastgpt/web/hooks/useRequest'; import { useToast } from '@fastgpt/web/hooks/useToast'; -import { type FlowNodeInputItemType } from '@fastgpt/global/core/workflow/type/io.d'; +import { type FlowNodeInputItemType } from '@fastgpt/global/core/workflow/type/io'; import { useContextSelector } from 'use-context-selector'; import { toolValueTypeList } from '@fastgpt/global/core/workflow/constants'; import { WorkflowIOValueTypeEnum } from '@fastgpt/global/core/workflow/constants'; diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderToolInput/index.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderToolInput/index.tsx index eec80216d..f8e9a2681 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderToolInput/index.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/render/RenderToolInput/index.tsx @@ -1,5 +1,5 @@ import React, { useMemo, useState } from 'react'; -import type { FlowNodeInputItemType } from '@fastgpt/global/core/workflow/type/io.d'; +import type { FlowNodeInputItemType } from '@fastgpt/global/core/workflow/type/io'; import { Box, Button, diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/context/workflowDebugContext.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/context/workflowDebugContext.tsx index fe11afb06..bf3336ae5 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/context/workflowDebugContext.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/context/workflowDebugContext.tsx @@ -156,6 +156,7 @@ export const WorkflowDebugProvider = ({ children }: { children: React.ReactNode // 4. Store debug result setWorkflowDebugData({ + // memoryNodes和memoryEdges包含了完整的响应,不需要再进行初始化 runtimeNodes: memoryNodes, runtimeEdges: memoryEdges, entryNodeIds, @@ -181,7 +182,7 @@ export const WorkflowDebugProvider = ({ children }: { children: React.ReactNode response: result.response, showResult: true, isExpired: false, - workflowInteractiveResponse: result.interactiveResponse + interactiveResponse: result.interactiveResponse } } }; diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/utils.ts b/projects/app/src/pageComponents/app/detail/WorkflowComponents/utils.ts index 9546cb56c..cda856e10 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/utils.ts +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/utils.ts @@ -9,7 +9,7 @@ import type { StoreEdgeItemType } from '@fastgpt/global/core/workflow/type/edge' import { type FlowNodeItemType, type StoreNodeItemType -} from '@fastgpt/global/core/workflow/type/node.d'; +} from '@fastgpt/global/core/workflow/type/node'; import { type TFunction } from 'i18next'; import { type Edge, type Node } from 'reactflow'; diff --git a/projects/app/src/pageComponents/app/detail/components/QuickCreateDatasetModal.tsx b/projects/app/src/pageComponents/app/detail/components/QuickCreateDatasetModal.tsx index e55103fd4..c70fe7740 100644 --- a/projects/app/src/pageComponents/app/detail/components/QuickCreateDatasetModal.tsx +++ b/projects/app/src/pageComponents/app/detail/components/QuickCreateDatasetModal.tsx @@ -33,6 +33,7 @@ import FileSelector, { type SelectFileItemType } from '@/pageComponents/dataset/detail/Import/components/FileSelector'; import { useRouter } from 'next/router'; +import type { ParentIdType } from '@fastgpt/global/common/parentFolder/type'; const QuickCreateDatasetModal = ({ onClose, @@ -41,7 +42,7 @@ const QuickCreateDatasetModal = ({ }: { onClose: () => void; onSuccess: (dataset: SelectedDatasetType) => void; - parentId: string; + parentId: ParentIdType; }) => { const { t } = useTranslation(); const router = useRouter(); diff --git a/projects/app/src/pageComponents/chat/ChatSetting/FavouriteAppSetting/AddFavouriteAppModal.tsx b/projects/app/src/pageComponents/chat/ChatSetting/FavouriteAppSetting/AddFavouriteAppModal.tsx index a8b1de610..e08220a2c 100644 --- a/projects/app/src/pageComponents/chat/ChatSetting/FavouriteAppSetting/AddFavouriteAppModal.tsx +++ b/projects/app/src/pageComponents/chat/ChatSetting/FavouriteAppSetting/AddFavouriteAppModal.tsx @@ -15,6 +15,7 @@ import FolderPath from '@/components/common/folder/Path'; import { getAppFolderPath } from '@/web/core/app/api/app'; import { ChevronRightIcon } from '@chakra-ui/icons'; import { AppTypeEnum } from '@fastgpt/global/core/app/constants'; +import type { ParentIdType } from '@fastgpt/global/common/parentFolder/type'; type Props = { onClose: () => void; @@ -31,7 +32,7 @@ const AddFavouriteAppModal = ({ onClose, onRefresh }: Props) => { }); const searchAppNameValue = watchSearchValue('name'); - const [parentId, setParentId] = useState(''); + const [parentId, setParentId] = useState(''); const { data: appData = { apps: [], paths: [] }, loading: isFetching } = useRequest2( async () => { const [apps, paths] = await Promise.all([ diff --git a/projects/app/src/pageComponents/chat/ChatSetting/HomepageSetting/AddQuickAppModal.tsx b/projects/app/src/pageComponents/chat/ChatSetting/HomepageSetting/AddQuickAppModal.tsx index 255617669..d9e30b9e0 100644 --- a/projects/app/src/pageComponents/chat/ChatSetting/HomepageSetting/AddQuickAppModal.tsx +++ b/projects/app/src/pageComponents/chat/ChatSetting/HomepageSetting/AddQuickAppModal.tsx @@ -16,6 +16,7 @@ import FolderPath from '@/components/common/folder/Path'; import { AppTypeEnum } from '@fastgpt/global/core/app/constants'; import { getAppFolderPath } from '@/web/core/app/api/app'; import { ChevronRightIcon } from '@chakra-ui/icons'; +import type { ParentIdType } from '@fastgpt/global/common/parentFolder/type'; type Props = { selectedIds: string[]; @@ -37,7 +38,7 @@ const AddQuickAppModal = ({ selectedIds, onClose, onConfirm }: Props) => { }); const searchAppName = watch('name'); - const [parentId, setParentId] = useState(''); + const [parentId, setParentId] = useState(''); const { data: appData = { apps: [], paths: [] as { parentId: string; parentName: string }[] }, diff --git a/projects/app/src/pageComponents/chat/ChatSetting/HomepageSetting/index.tsx b/projects/app/src/pageComponents/chat/ChatSetting/HomepageSetting/index.tsx index b224d69bc..c6b12c211 100644 --- a/projects/app/src/pageComponents/chat/ChatSetting/HomepageSetting/index.tsx +++ b/projects/app/src/pageComponents/chat/ChatSetting/HomepageSetting/index.tsx @@ -18,7 +18,7 @@ import { useRequest2 } from '@fastgpt/web/hooks/useRequest'; import ImageUpload from '@/pageComponents/chat/ChatSetting/ImageUpload'; import { useSystemStore } from '@/web/common/system/useSystemStore'; import ToolSelectModal from '@/pageComponents/chat/ChatSetting/ToolSelectModal'; -import type { FlowNodeTemplateType } from '@fastgpt/global/core/workflow/type/node.d'; +import type { FlowNodeTemplateType } from '@fastgpt/global/core/workflow/type/node'; import Avatar from '@fastgpt/web/components/common/Avatar'; import type { NodeInputKeyEnum } from '@fastgpt/global/core/workflow/constants'; import { useMount } from 'ahooks'; diff --git a/projects/app/src/pageComponents/chat/ChatSetting/ToolSelectModal.tsx b/projects/app/src/pageComponents/chat/ChatSetting/ToolSelectModal.tsx index a1fc916d2..585f1517f 100644 --- a/projects/app/src/pageComponents/chat/ChatSetting/ToolSelectModal.tsx +++ b/projects/app/src/pageComponents/chat/ChatSetting/ToolSelectModal.tsx @@ -9,7 +9,7 @@ import EmptyTip from '@fastgpt/web/components/common/EmptyTip'; import { type FlowNodeTemplateType, type NodeTemplateListItemType -} from '@fastgpt/global/core/workflow/type/node.d'; +} from '@fastgpt/global/core/workflow/type/node'; import MyIcon from '@fastgpt/web/components/common/Icon'; import { getToolPreviewNode, getAppToolTemplates, getAppToolPaths } from '@/web/core/app/api/tool'; import MyBox from '@fastgpt/web/components/common/MyBox'; @@ -21,7 +21,7 @@ import SearchInput from '@fastgpt/web/components/common/Input/SearchInput'; import { useMemoizedFn } from 'ahooks'; import MyAvatar from '@fastgpt/web/components/common/Avatar'; import { FlowNodeInputTypeEnum } from '@fastgpt/global/core/workflow/node/constant'; -import { type AppFormEditFormType } from '@fastgpt/global/core/app/type'; +import type { AppFormEditFormType } from '@fastgpt/global/core/app/formEdit/type'; import { useToast } from '@fastgpt/web/hooks/useToast'; import { workflowStartNodeId } from '@/web/core/app/constants'; import type { ChatSettingType } from '@fastgpt/global/core/chat/setting/type'; diff --git a/projects/app/src/pageComponents/dashboard/agent/TemplateCreatePanel.tsx b/projects/app/src/pageComponents/dashboard/agent/TemplateCreatePanel.tsx index 9c41f1019..c79937409 100644 --- a/projects/app/src/pageComponents/dashboard/agent/TemplateCreatePanel.tsx +++ b/projects/app/src/pageComponents/dashboard/agent/TemplateCreatePanel.tsx @@ -22,9 +22,10 @@ import MyBox from '@fastgpt/web/components/common/MyBox'; import { useLocalStorageState } from 'ahooks'; import { useState } from 'react'; import { getWebReqUrl } from '@fastgpt/web/common/system/utils'; -import { form2AppWorkflow } from '@/web/core/app/utils'; +import { form2AppWorkflow } from '@/pageComponents/app/detail/Edit/SimpleApp/utils'; import { webPushTrack } from '@/web/common/middle/tracks/utils'; import { appTypeTagMap } from '../constant'; +import type { AppFormEditFormType } from '@fastgpt/global/core/app/formEdit/type'; const TemplateCreatePanel = ({ type }: { type: AppTypeEnum | 'all' }) => { const { t } = useTranslation(); @@ -74,7 +75,10 @@ const TemplateCreatePanel = ({ type }: { type: AppTypeEnum | 'all' }) => { const templateDetail = await getTemplateMarketItemDetail(templateId); if (templateDetail.type === AppTypeEnum.simple) { - const completeWorkflow = form2AppWorkflow(templateDetail.workflow, t); + const completeWorkflow = form2AppWorkflow( + templateDetail.workflow as unknown as AppFormEditFormType, + t + ); templateDetail.workflow = completeWorkflow; } diff --git a/projects/app/src/pageComponents/dataset/detail/Info/index.tsx b/projects/app/src/pageComponents/dataset/detail/Info/index.tsx index 4817ed77d..02ed66feb 100644 --- a/projects/app/src/pageComponents/dataset/detail/Info/index.tsx +++ b/projects/app/src/pageComponents/dataset/detail/Info/index.tsx @@ -9,7 +9,7 @@ import { useSystemStore } from '@/web/common/system/useSystemStore'; import { useRequest2 } from '@fastgpt/web/hooks/useRequest'; import AIModelSelector from '@/components/Select/AIModelSelector'; import { postRebuildEmbedding } from '@/web/core/dataset/api'; -import type { EmbeddingModelItemType } from '@fastgpt/global/core/ai/model.d'; +import type { EmbeddingModelItemType } from '@fastgpt/global/core/ai/model'; import { useContextSelector } from 'use-context-selector'; import { DatasetPageContext } from '@/web/core/dataset/context/datasetPageContext'; import MyDivider from '@fastgpt/web/components/common/MyDivider/index'; diff --git a/projects/app/src/pageComponents/dataset/detail/Test.tsx b/projects/app/src/pageComponents/dataset/detail/Test.tsx index 61e59c82f..bc9a0ab70 100644 --- a/projects/app/src/pageComponents/dataset/detail/Test.tsx +++ b/projects/app/src/pageComponents/dataset/detail/Test.tsx @@ -37,7 +37,7 @@ const DatasetParamsModal = dynamic(() => import('@/components/core/app/DatasetPa type FormType = { inputText: string; searchParams: { - searchMode: `${DatasetSearchModeEnum}`; + searchMode: DatasetSearchModeEnum; embeddingWeight?: number; usingReRank?: boolean; diff --git a/projects/app/src/pages/api/admin/initv4141.ts b/projects/app/src/pages/api/admin/initv4141.ts index 378a4055a..396d57077 100644 --- a/projects/app/src/pages/api/admin/initv4141.ts +++ b/projects/app/src/pages/api/admin/initv4141.ts @@ -2,7 +2,7 @@ import { NextAPI } from '@/service/middleware/entry'; import type { ParentIdType } from '@fastgpt/global/common/parentFolder/type'; import { retryFn } from '@fastgpt/global/common/system/utils'; import { AppTypeEnum } from '@fastgpt/global/core/app/constants'; -import type { AppSchema } from '@fastgpt/global/core/app/type'; +import type { AppSchemaType } from '@fastgpt/global/core/app/type'; import { PerResourceTypeEnum } from '@fastgpt/global/support/permission/constant'; import type { ResourcePermissionType } from '@fastgpt/global/support/permission/type'; import type { AnyBulkWriteOperation } from '@fastgpt/service/common/mongo'; @@ -101,7 +101,7 @@ async function appSplitMigration(teamId: string) { // update parentIds // update rps { - const ops: AnyBulkWriteOperation[] = []; + const ops: AnyBulkWriteOperation[] = []; const rpOps: AnyBulkWriteOperation[] = []; for (const folder of allFolders) { diff --git a/projects/app/src/pages/api/admin/initv4820.ts b/projects/app/src/pages/api/admin/initv4820.ts index 333f3e6d2..04c5ad11e 100644 --- a/projects/app/src/pages/api/admin/initv4820.ts +++ b/projects/app/src/pages/api/admin/initv4820.ts @@ -10,7 +10,7 @@ import json5 from 'json5'; import { type FastGPTConfigFileType } from '@fastgpt/global/common/system/types'; import { MongoSystemModel } from '@fastgpt/service/core/ai/config/schema'; import { loadSystemModels } from '@fastgpt/service/core/ai/config/utils'; -import { ModelTypeEnum } from '@fastgpt/global/core/ai/model'; +import { ModelTypeEnum } from '@fastgpt/global/core/ai/constants'; /* 简单版迁移:直接升级到最新镜像,会去除 MongoDatasetData 里的索引。直接执行这个脚本。 diff --git a/projects/app/src/pages/api/core/ai/model/list.ts b/projects/app/src/pages/api/core/ai/model/list.ts index d3e1d940a..bdea90b38 100644 --- a/projects/app/src/pages/api/core/ai/model/list.ts +++ b/projects/app/src/pages/api/core/ai/model/list.ts @@ -1,6 +1,6 @@ import type { ApiRequestProps, ApiResponseType } from '@fastgpt/service/type/next'; import { NextAPI } from '@/service/middleware/entry'; -import type { ModelTypeEnum } from '@fastgpt/global/core/ai/model'; +import type { ModelTypeEnum } from '@fastgpt/global/core/ai/constants'; import { authSystemAdmin } from '@fastgpt/service/support/permission/user/auth'; export type listQuery = {}; diff --git a/projects/app/src/pages/api/core/ai/model/test.ts b/projects/app/src/pages/api/core/ai/model/test.ts index 092a11ed1..5afe51620 100644 --- a/projects/app/src/pages/api/core/ai/model/test.ts +++ b/projects/app/src/pages/api/core/ai/model/test.ts @@ -8,7 +8,7 @@ import { type RerankModelItemType, type STTModelType, type TTSModelType -} from '@fastgpt/global/core/ai/model.d'; +} from '@fastgpt/global/core/ai/model'; import { getAIApi } from '@fastgpt/service/core/ai/config'; import { addLog } from '@fastgpt/service/common/system/log'; import { getVectorsByText } from '@fastgpt/service/core/ai/embedding'; diff --git a/projects/app/src/pages/api/core/ai/model/updateDefault.ts b/projects/app/src/pages/api/core/ai/model/updateDefault.ts index 74e754216..e0792fd5a 100644 --- a/projects/app/src/pages/api/core/ai/model/updateDefault.ts +++ b/projects/app/src/pages/api/core/ai/model/updateDefault.ts @@ -3,7 +3,7 @@ import { NextAPI } from '@/service/middleware/entry'; import { mongoSessionRun } from '@fastgpt/service/common/mongo/sessionRun'; import { MongoSystemModel } from '@fastgpt/service/core/ai/config/schema'; import { updatedReloadSystemModel } from '@fastgpt/service/core/ai/config/utils'; -import type { ModelTypeEnum } from '@fastgpt/global/core/ai/model'; +import type { ModelTypeEnum } from '@fastgpt/global/core/ai/constants'; import { authSystemAdmin } from '@fastgpt/service/support/permission/user/auth'; export type updateDefaultQuery = {}; diff --git a/projects/app/src/pages/api/core/ai/optimizePrompt.ts b/projects/app/src/pages/api/core/ai/optimizePrompt.ts index 5326c8bde..3fb5de3a8 100644 --- a/projects/app/src/pages/api/core/ai/optimizePrompt.ts +++ b/projects/app/src/pages/api/core/ai/optimizePrompt.ts @@ -8,7 +8,7 @@ import { authCert } from '@fastgpt/service/support/permission/auth/common'; import { formatModelChars2Points } from '@fastgpt/service/support/wallet/usage/utils'; import { createUsage } from '@fastgpt/service/support/wallet/usage/controller'; import { UsageSourceEnum } from '@fastgpt/global/support/wallet/usage/constants'; -import { ModelTypeEnum } from '@fastgpt/global/core/ai/model'; +import { ModelTypeEnum } from '@fastgpt/global/core/ai/constants'; import { i18nT } from '@fastgpt/web/i18n/utils'; import { addLog } from '@fastgpt/service/common/system/log'; import { createLLMResponse } from '@fastgpt/service/core/ai/llm/request'; diff --git a/projects/app/src/pages/api/core/app/create.ts b/projects/app/src/pages/api/core/app/create.ts index ea9265c5f..1197d72ac 100644 --- a/projects/app/src/pages/api/core/app/create.ts +++ b/projects/app/src/pages/api/core/app/create.ts @@ -4,7 +4,7 @@ import type { ParentIdType } from '@fastgpt/global/common/parentFolder/type'; import { parseParentIdInMongo } from '@fastgpt/global/common/parentFolder/utils'; import { AppTypeEnum } from '@fastgpt/global/core/app/constants'; import { AppFolderTypeList, ToolTypeList, AppTypeList } from '@fastgpt/global/core/app/constants'; -import type { AppSchema } from '@fastgpt/global/core/app/type'; +import type { AppSchemaType } from '@fastgpt/global/core/app/type'; import { type ShortUrlParams } from '@fastgpt/global/support/marketing/type'; import { OwnerRoleVal, @@ -40,9 +40,9 @@ export type CreateAppBody = { avatar?: string; intro?: string; type?: AppTypeEnum; - modules: AppSchema['modules']; - edges?: AppSchema['edges']; - chatConfig?: AppSchema['chatConfig']; + modules: AppSchemaType['modules']; + edges?: AppSchemaType['edges']; + chatConfig?: AppSchemaType['chatConfig']; templateId?: string; utmParams?: ShortUrlParams; @@ -141,13 +141,13 @@ export const onCreateApp = async ({ name?: string; avatar?: string; type: AppTypeEnum; - modules?: AppSchema['modules']; - edges?: AppSchema['edges']; - chatConfig?: AppSchema['chatConfig']; + modules?: AppSchemaType['modules']; + edges?: AppSchemaType['edges']; + chatConfig?: AppSchemaType['chatConfig']; intro?: string; teamId: string; tmbId: string; - pluginData?: AppSchema['pluginData']; + pluginData?: AppSchemaType['pluginData']; username?: string; userAvatar?: string; templateId?: string; diff --git a/projects/app/src/pages/api/core/app/httpTools/runTool.ts b/projects/app/src/pages/api/core/app/httpTools/runTool.ts index 1cae115f2..cacd82569 100644 --- a/projects/app/src/pages/api/core/app/httpTools/runTool.ts +++ b/projects/app/src/pages/api/core/app/httpTools/runTool.ts @@ -3,7 +3,7 @@ import type { ApiRequestProps, ApiResponseType } from '@fastgpt/service/type/nex import { type StoreSecretValueType } from '@fastgpt/global/common/secret/type'; import type { RunHTTPToolResult } from '@fastgpt/service/core/app/http'; import { runHTTPTool } from '@fastgpt/service/core/app/http'; -import type { HttpToolConfigType } from '@fastgpt/global/core/app/type'; +import type { HttpToolConfigType } from '@fastgpt/global/core/app/tool/httpTool/type'; export type RunHTTPToolQuery = {}; diff --git a/projects/app/src/pages/api/core/app/httpTools/update.ts b/projects/app/src/pages/api/core/app/httpTools/update.ts index 6ee3a5cc9..85690f624 100644 --- a/projects/app/src/pages/api/core/app/httpTools/update.ts +++ b/projects/app/src/pages/api/core/app/httpTools/update.ts @@ -2,7 +2,7 @@ import type { NextApiResponse } from 'next'; import { mongoSessionRun } from '@fastgpt/service/common/mongo/sessionRun'; import { getHTTPToolSetRuntimeNode } from '@fastgpt/global/core/app/tool/httpTool/utils'; import { NextAPI } from '@/service/middleware/entry'; -import type { HttpToolConfigType } from '@fastgpt/global/core/app/type'; +import type { HttpToolConfigType } from '@fastgpt/global/core/app/tool/httpTool/type'; import { type ApiRequestProps } from '@fastgpt/service/type/next'; import { authApp } from '@fastgpt/service/support/permission/app/auth'; import { ManagePermissionVal } from '@fastgpt/global/support/permission/constant'; diff --git a/projects/app/src/pages/api/core/app/template/list.ts b/projects/app/src/pages/api/core/app/template/list.ts index 0eadc278b..cedb416ef 100644 --- a/projects/app/src/pages/api/core/app/template/list.ts +++ b/projects/app/src/pages/api/core/app/template/list.ts @@ -68,7 +68,7 @@ async function handler( filteredItems = shuffled.slice(0, randomNumber); } - const list = filteredItems.map((item) => { + const list = filteredItems.map((item) => { return { templateId: item.templateId, name: item.name, @@ -80,7 +80,7 @@ async function handler( type: item.type, author: item.author, userGuide: item.userGuide, - workflow: {} + workflow: {} as AppTemplateSchemaType['workflow'] }; }); diff --git a/projects/app/src/pages/api/core/app/tool/getPreviewNode.ts b/projects/app/src/pages/api/core/app/tool/getPreviewNode.ts index fc0f0570b..598326fab 100644 --- a/projects/app/src/pages/api/core/app/tool/getPreviewNode.ts +++ b/projects/app/src/pages/api/core/app/tool/getPreviewNode.ts @@ -2,7 +2,7 @@ get plugin preview modules */ import { getChildAppPreviewNode } from '@fastgpt/service/core/app/tool/controller'; -import { type FlowNodeTemplateType } from '@fastgpt/global/core/workflow/type/node.d'; +import { type FlowNodeTemplateType } from '@fastgpt/global/core/workflow/type/node'; import { NextAPI } from '@/service/middleware/entry'; import { type ApiRequestProps } from '@fastgpt/service/type/next'; import type { NextApiResponse } from 'next'; diff --git a/projects/app/src/pages/api/core/app/tool/getSystemToolTemplates.ts b/projects/app/src/pages/api/core/app/tool/getSystemToolTemplates.ts index badccdd62..c319e823b 100644 --- a/projects/app/src/pages/api/core/app/tool/getSystemToolTemplates.ts +++ b/projects/app/src/pages/api/core/app/tool/getSystemToolTemplates.ts @@ -1,4 +1,4 @@ -import { type NodeTemplateListItemType } from '@fastgpt/global/core/workflow/type/node.d'; +import { type NodeTemplateListItemType } from '@fastgpt/global/core/workflow/type/node'; import { NextAPI } from '@/service/middleware/entry'; import { type ParentIdType } from '@fastgpt/global/common/parentFolder/type'; import { type ApiRequestProps } from '@fastgpt/service/type/next'; diff --git a/projects/app/src/pages/api/core/dataset/collection/update.ts b/projects/app/src/pages/api/core/dataset/collection/update.ts index 89e18dc11..73cb9201a 100644 --- a/projects/app/src/pages/api/core/dataset/collection/update.ts +++ b/projects/app/src/pages/api/core/dataset/collection/update.ts @@ -15,9 +15,11 @@ import { mongoSessionRun } from '@fastgpt/service/common/mongo/sessionRun'; import { addAuditLog } from '@fastgpt/service/support/user/audit/util'; import { AuditEventEnum } from '@fastgpt/global/support/user/audit/constants'; import { getI18nDatasetType } from '@fastgpt/service/support/user/audit/util'; +import type { ParentIdType } from '@fastgpt/global/common/parentFolder/type'; + export type UpdateDatasetCollectionParams = { id?: string; - parentId?: string; + parentId?: ParentIdType; name?: string; tags?: string[]; // Not tag id, is tag label forbid?: boolean; diff --git a/projects/app/src/pages/api/core/dataset/createWithFiles.ts b/projects/app/src/pages/api/core/dataset/createWithFiles.ts index d354aaab3..6e6f1c97e 100644 --- a/projects/app/src/pages/api/core/dataset/createWithFiles.ts +++ b/projects/app/src/pages/api/core/dataset/createWithFiles.ts @@ -33,16 +33,17 @@ import { getI18nDatasetType } from '@fastgpt/service/support/user/audit/util'; import { MongoResourcePermission } from '@fastgpt/service/support/permission/schema'; import { getS3AvatarSource } from '@fastgpt/service/common/s3/sources/avatar'; import { createCollectionAndInsertData } from '@fastgpt/service/core/dataset/collection/controller'; -import type { EmbeddingModelItemType } from '@fastgpt/global/core/ai/model.d'; +import type { EmbeddingModelItemType } from '@fastgpt/global/core/ai/model'; import { S3PrivateBucket } from '@fastgpt/service/common/s3/buckets/private'; import { getFileS3Key } from '@fastgpt/service/common/s3/utils'; +import type { ParentIdType } from '@fastgpt/global/common/parentFolder/type'; export type DatasetCreateWithFilesQuery = {}; export type DatasetCreateWithFilesBody = { datasetParams: { name: string; avatar: string; - parentId?: string; + parentId?: ParentIdType; vectorModel?: string; agentModel?: string; vlmModel?: string; diff --git a/projects/app/src/pages/api/v1/chat/completions.ts b/projects/app/src/pages/api/v1/chat/completions.ts index b97374a0f..f7d0d872d 100644 --- a/projects/app/src/pages/api/v1/chat/completions.ts +++ b/projects/app/src/pages/api/v1/chat/completions.ts @@ -9,7 +9,7 @@ import { dispatchWorkFlow } from '@fastgpt/service/core/workflow/dispatch'; import type { ChatCompletionCreateParams, ChatCompletionMessageParam -} from '@fastgpt/global/core/ai/type.d'; +} from '@fastgpt/global/core/ai/type'; import { getWorkflowEntryNodeIds, getMaxHistoryLimitFromNodes, @@ -41,7 +41,7 @@ import { updateApiKeyUsage } from '@fastgpt/service/support/openapi/tools'; import { getRunningUserInfoByTmbId } from '@fastgpt/service/support/user/team/utils'; import { AuthUserTypeEnum } from '@fastgpt/global/support/permission/constant'; import { MongoApp } from '@fastgpt/service/core/app/schema'; -import { type AppSchema } from '@fastgpt/global/core/app/type'; +import { type AppSchemaType } from '@fastgpt/global/core/app/type'; import { type AuthOutLinkChatProps } from '@fastgpt/global/support/outLink/api'; import { MongoChat } from '@fastgpt/service/core/chat/chatSchema'; import { ChatErrEnum } from '@fastgpt/global/common/error/code/chat'; @@ -90,7 +90,7 @@ export type Props = ChatCompletionCreateParams & type AuthResponseType = { teamId: string; tmbId: string; - app: AppSchema; + app: AppSchemaType; responseDetail?: boolean; showNodeStatus?: boolean; authType: `${AuthUserTypeEnum}`; diff --git a/projects/app/src/pages/api/v2/chat/completions.ts b/projects/app/src/pages/api/v2/chat/completions.ts index 3842bfe05..e4555874d 100644 --- a/projects/app/src/pages/api/v2/chat/completions.ts +++ b/projects/app/src/pages/api/v2/chat/completions.ts @@ -9,7 +9,7 @@ import { dispatchWorkFlow } from '@fastgpt/service/core/workflow/dispatch'; import type { ChatCompletionCreateParams, ChatCompletionMessageParam -} from '@fastgpt/global/core/ai/type.d'; +} from '@fastgpt/global/core/ai/type'; import { getWorkflowEntryNodeIds, getMaxHistoryLimitFromNodes, @@ -42,7 +42,7 @@ import { updateApiKeyUsage } from '@fastgpt/service/support/openapi/tools'; import { getRunningUserInfoByTmbId } from '@fastgpt/service/support/user/team/utils'; import { AuthUserTypeEnum } from '@fastgpt/global/support/permission/constant'; import { MongoApp } from '@fastgpt/service/core/app/schema'; -import { type AppSchema } from '@fastgpt/global/core/app/type'; +import { type AppSchemaType } from '@fastgpt/global/core/app/type'; import { type AuthOutLinkChatProps } from '@fastgpt/global/support/outLink/api'; import { MongoChat } from '@fastgpt/service/core/chat/chatSchema'; import { ChatErrEnum } from '@fastgpt/global/common/error/code/chat'; @@ -92,7 +92,7 @@ export type Props = ChatCompletionCreateParams & type AuthResponseType = { teamId: string; tmbId: string; - app: AppSchema; + app: AppSchemaType; responseDetail?: boolean; showNodeStatus?: boolean; authType: `${AuthUserTypeEnum}`; diff --git a/projects/app/src/pages/chat/share.tsx b/projects/app/src/pages/chat/share.tsx index 18aca372c..e948a8ae9 100644 --- a/projects/app/src/pages/chat/share.tsx +++ b/projects/app/src/pages/chat/share.tsx @@ -35,7 +35,7 @@ import ChatRecordContextProvider, { import { useChatStore } from '@/web/core/chat/context/useChatStore'; import { ChatSourceEnum } from '@fastgpt/global/core/chat/constants'; import { useI18nLng } from '@fastgpt/web/hooks/useI18n'; -import { type AppSchema } from '@fastgpt/global/core/app/type'; +import { type AppSchemaType } from '@fastgpt/global/core/app/type'; import ChatQuoteList from '@/pageComponents/chat/ChatQuoteList'; import { useToast } from '@fastgpt/web/hooks/useToast'; import { ChatTypeEnum } from '@/components/core/chat/ChatContainer/ChatBox/constants'; @@ -418,7 +418,7 @@ export async function getServerSideProps(context: any) { }, 'appId showRawSource showNodeStatus responseDetail' ) - .populate<{ associatedApp: AppSchema }>('associatedApp', 'name avatar intro') + .populate<{ associatedApp: AppSchemaType }>('associatedApp', 'name avatar intro') .lean(); } catch (error) { addLog.error('getServerSideProps', error); diff --git a/projects/app/src/pages/dashboard/templateMarket/index.tsx b/projects/app/src/pages/dashboard/templateMarket/index.tsx index ea7d25fc5..4403c45c4 100644 --- a/projects/app/src/pages/dashboard/templateMarket/index.tsx +++ b/projects/app/src/pages/dashboard/templateMarket/index.tsx @@ -5,15 +5,11 @@ import { Box, Button, Flex, Grid, HStack } from '@chakra-ui/react'; import { useRouter } from 'next/router'; import { useTranslation } from 'next-i18next'; import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; -import { useSystemStore } from '@/web/common/system/useSystemStore'; import { type ParentIdType } from '@fastgpt/global/common/parentFolder/type'; import { AppTypeEnum } from '@fastgpt/global/core/app/constants'; -import { - type AppTemplateSchemaType, - type TemplateTypeSchemaType -} from '@fastgpt/global/core/app/type'; -import { appWorkflow2Form } from '@fastgpt/global/core/app/utils'; -import { form2AppWorkflow } from '@/web/core/app/utils'; +import type { AppTemplateSchemaType, TemplateTypeSchemaType } from '@fastgpt/global/core/app/type'; +import type { AppFormEditFormType } from '@fastgpt/global/core/app/formEdit/type'; +import { form2AppWorkflow } from '@/pageComponents/app/detail/Edit/SimpleApp/utils'; import MyBox from '@fastgpt/web/components/common/MyBox'; import { useRequest2 } from '@fastgpt/web/hooks/useRequest'; import { getTemplateMarketItemDetail } from '@/web/core/app/api/template'; @@ -71,7 +67,11 @@ const TemplateMarket = ({ const templateDetail = await getTemplateMarketItemDetail(template.templateId); if (template.type === AppTypeEnum.simple) { - const completeWorkflow = form2AppWorkflow(templateDetail.workflow, t); + // TODO: 特殊类型 + const completeWorkflow = form2AppWorkflow( + templateDetail.workflow as unknown as AppFormEditFormType, + t + ); templateDetail.workflow = completeWorkflow; } diff --git a/projects/app/src/service/core/app/workflow.ts b/projects/app/src/service/core/app/workflow.ts index 070784e17..09429eea1 100644 --- a/projects/app/src/service/core/app/workflow.ts +++ b/projects/app/src/service/core/app/workflow.ts @@ -1,5 +1,5 @@ import { NodeInputKeyEnum } from '@fastgpt/global/core/workflow/constants'; -import type { StoreNodeItemType } from '@fastgpt/global/core/workflow/type/node.d'; +import type { StoreNodeItemType } from '@fastgpt/global/core/workflow/type/node'; import { getLLMModel } from '@fastgpt/service/core/ai/model'; export const getChatModelNameListByModules = (nodes: StoreNodeItemType[]): string[] => { diff --git a/projects/app/src/service/core/dataset/queues/generateQA.ts b/projects/app/src/service/core/dataset/queues/generateQA.ts index a56d491a3..27952f9f5 100644 --- a/projects/app/src/service/core/dataset/queues/generateQA.ts +++ b/projects/app/src/service/core/dataset/queues/generateQA.ts @@ -1,7 +1,7 @@ import { MongoDatasetTraining } from '@fastgpt/service/core/dataset/training/schema'; import { pushLLMTrainingUsage } from '@fastgpt/service/support/wallet/usage/controller'; import { TrainingModeEnum } from '@fastgpt/global/core/dataset/constants'; -import type { ChatCompletionMessageParam } from '@fastgpt/global/core/ai/type.d'; +import type { ChatCompletionMessageParam } from '@fastgpt/global/core/ai/type'; import { addLog } from '@fastgpt/service/common/system/log'; import { replaceVariable } from '@fastgpt/global/common/string/tools'; import { Prompt_AgentQA } from '@fastgpt/global/core/ai/prompt/agent'; @@ -9,7 +9,7 @@ import type { PushDatasetDataChunkProps } from '@fastgpt/global/core/dataset/api import { getLLMModel } from '@fastgpt/service/core/ai/model'; import { checkTeamAiPointsAndLock } from './utils'; import { addMinutes } from 'date-fns'; -import type { LLMModelItemType } from '@fastgpt/global/core/ai/model.d'; +import type { LLMModelItemType } from '@fastgpt/global/core/ai/model'; import { chunkAutoChunkSize, getLLMMaxChunkSize diff --git a/projects/app/src/service/support/mcp/utils.ts b/projects/app/src/service/support/mcp/utils.ts index 117d32f0d..5e5ca4707 100644 --- a/projects/app/src/service/support/mcp/utils.ts +++ b/projects/app/src/service/support/mcp/utils.ts @@ -11,7 +11,7 @@ import { type AppChatConfigType } from '@fastgpt/global/core/app/type'; import { AppTypeEnum } from '@fastgpt/global/core/app/constants'; import { type FlowNodeInputItemType } from '@fastgpt/global/core/workflow/type/io'; import { type toolCallProps } from './type'; -import { type AppSchema } from '@fastgpt/global/core/app/type'; +import { type AppSchemaType } from '@fastgpt/global/core/app/type'; import { getRunningUserInfoByTmbId } from '@fastgpt/service/support/user/team/utils'; import { getNanoid } from '@fastgpt/global/common/string/tools'; import { type AIChatItemType, type UserChatItemType } from '@fastgpt/global/core/chat/type'; @@ -166,7 +166,7 @@ export const getMcpServerTools = async (key: string): Promise => { // Call tool export const callMcpServerTool = async ({ key, toolName, inputs }: toolCallProps) => { - const dispatchApp = async (app: AppSchema, variables: Record) => { + const dispatchApp = async (app: AppSchemaType, variables: Record) => { const isPlugin = app.type === AppTypeEnum.workflowTool; // Get app latest version diff --git a/projects/app/src/types/app.d.ts b/projects/app/src/types/app.d.ts index 19f02f991..d6b49c7ec 100644 --- a/projects/app/src/types/app.d.ts +++ b/projects/app/src/types/app.d.ts @@ -7,10 +7,10 @@ import type { FlowNodeOutputTargetItemType } from '@fastgpt/global/core/workflow import { FlowNodeInputItemType, FlowNodeOutputItemType -} from '@fastgpt/global/core/workflow/type/io.d'; -import type { StoreNodeItemType } from '@fastgpt/global/core/workflow/type/node.d'; +} from '@fastgpt/global/core/workflow/type/io'; +import type { StoreNodeItemType } from '@fastgpt/global/core/workflow/type/node'; import type { FlowNodeTemplateType } from '@fastgpt/global/core/workflow/type/node'; -import type { AppSchema } from '@fastgpt/global/core/app/type'; +import type { AppSchemaType } from '@fastgpt/global/core/app/type'; import { ChatModelType } from '@/constants/model'; import { TeamMemberStatusEnum } from '@fastgpt/global/support/user/team/constant'; import type { SourceMember } from '@fastgpt/global/support/user/type'; @@ -22,7 +22,7 @@ export interface ShareAppItem { name: string; intro: string; userId: string; - share: AppSchema['share']; + share: AppSchemaType['share']; isCollection: boolean; } diff --git a/projects/app/src/types/index.d.ts b/projects/app/src/types/index.d.ts index 730d9e9a6..7dc1bbfb3 100644 --- a/projects/app/src/types/index.d.ts +++ b/projects/app/src/types/index.d.ts @@ -6,7 +6,7 @@ import { RerankModelItemType, EmbeddingModelItemType, STTModelType -} from '@fastgpt/global/core/ai/model.d'; +} from '@fastgpt/global/core/ai/model'; import type { TrackEventName } from '@/web/common/system/constants'; import { SubPlanType } from '@fastgpt/global/support/wallet/sub/type'; diff --git a/projects/app/src/web/common/system/useSystemStore.ts b/projects/app/src/web/common/system/useSystemStore.ts index 5a56c33ad..0807a778e 100644 --- a/projects/app/src/web/common/system/useSystemStore.ts +++ b/projects/app/src/web/common/system/useSystemStore.ts @@ -7,11 +7,11 @@ import type { RerankModelItemType, EmbeddingModelItemType, STTModelType -} from '@fastgpt/global/core/ai/model.d'; +} from '@fastgpt/global/core/ai/model'; import type { InitDateResponse } from '@/pages/api/common/system/getInitData'; import { type FastGPTFeConfigsType } from '@fastgpt/global/common/system/types'; import { type SubPlanType } from '@fastgpt/global/support/wallet/sub/type'; -import { ModelTypeEnum } from '@fastgpt/global/core/ai/model'; +import { ModelTypeEnum } from '@fastgpt/global/core/ai/constants'; import type { TeamErrEnum } from '@fastgpt/global/common/error/code/team'; import type { SystemDefaultModelType } from '@fastgpt/service/core/ai/type'; import { diff --git a/projects/app/src/web/common/system/utils.ts b/projects/app/src/web/common/system/utils.ts index 7fab004d7..d7e7f9947 100644 --- a/projects/app/src/web/common/system/utils.ts +++ b/projects/app/src/web/common/system/utils.ts @@ -1,7 +1,4 @@ -import { - type EmbeddingModelItemType, - type LLMModelItemType -} from '@fastgpt/global/core/ai/model.d'; +import { type EmbeddingModelItemType, type LLMModelItemType } from '@fastgpt/global/core/ai/model'; import { useSystemStore } from './useSystemStore'; import { getWebReqUrl } from '@fastgpt/web/common/system/utils'; diff --git a/projects/app/src/web/common/utils/voice.ts b/projects/app/src/web/common/utils/voice.ts index f6acfba99..3a807b2d6 100644 --- a/projects/app/src/web/common/utils/voice.ts +++ b/projects/app/src/web/common/utils/voice.ts @@ -3,7 +3,7 @@ import { useState, useCallback, useMemo, useRef } from 'react'; import { useToast } from '@fastgpt/web/hooks/useToast'; import { getErrText } from '@fastgpt/global/common/error/utils'; -import type { AppTTSConfigType } from '@fastgpt/global/core/app/type.d'; +import type { AppTTSConfigType } from '@fastgpt/global/core/app/type'; import { TTSTypeEnum } from '@/web/core/app/constants'; import { useTranslation } from 'next-i18next'; import type { OutLinkChatAuthProps } from '@fastgpt/global/support/permission/chat'; diff --git a/projects/app/src/web/core/app/api.ts b/projects/app/src/web/core/app/api.ts index 7d2a795e3..0aa9cd11b 100644 --- a/projects/app/src/web/core/app/api.ts +++ b/projects/app/src/web/core/app/api.ts @@ -1,5 +1,5 @@ import { GET, POST, DELETE, PUT } from '@/web/common/api/request'; -import type { AppDetailType, AppListItemType } from '@fastgpt/global/core/app/type.d'; +import type { AppDetailType, AppListItemType } from '@fastgpt/global/core/app/type'; import type { AppUpdateParams, AppChangeOwnerBody } from '@/global/core/app/api'; import type { CreateAppBody } from '@/pages/api/core/app/create'; import type { ListAppBody } from '@/pages/api/core/app/list'; diff --git a/projects/app/src/web/core/app/constants.ts b/projects/app/src/web/core/app/constants.ts index 26a563818..453b287c3 100644 --- a/projects/app/src/web/core/app/constants.ts +++ b/projects/app/src/web/core/app/constants.ts @@ -1,5 +1,5 @@ import { AppTypeEnum } from '@fastgpt/global/core/app/constants'; -import { type AppDetailType } from '@fastgpt/global/core/app/type.d'; +import { type AppDetailType } from '@fastgpt/global/core/app/type'; import type { DingtalkAppType, FeishuAppType, diff --git a/projects/app/src/web/core/app/templates.ts b/projects/app/src/web/core/app/templates.ts index 476a40360..2414eb101 100644 --- a/projects/app/src/web/core/app/templates.ts +++ b/projects/app/src/web/core/app/templates.ts @@ -1,6 +1,6 @@ import { parseCurl } from '@fastgpt/global/common/string/http'; import { AppTypeEnum } from '@fastgpt/global/core/app/constants'; -import { type AppSchema } from '@fastgpt/global/core/app/type'; +import { type AppSchemaType } from '@fastgpt/global/core/app/type'; import { NodeInputKeyEnum, WorkflowIOValueTypeEnum } from '@fastgpt/global/core/workflow/constants'; import { FlowNodeInputTypeEnum, @@ -417,9 +417,9 @@ export const emptyTemplates = { export const parsePluginFromCurlString = ( curl: string ): { - nodes: AppSchema['modules']; - edges: AppSchema['edges']; - chatConfig: AppSchema['chatConfig']; + nodes: AppSchemaType['modules']; + edges: AppSchemaType['edges']; + chatConfig: AppSchemaType['chatConfig']; } => { const { url, method, headers, body, params, bodyArray } = parseCurl(curl); diff --git a/projects/app/src/web/core/app/utils.ts b/projects/app/src/web/core/app/utils.ts index ea254feb7..7ec792f5c 100644 --- a/projects/app/src/web/core/app/utils.ts +++ b/projects/app/src/web/core/app/utils.ts @@ -1,8 +1,5 @@ -import { - type AppDetailType, - type AppSchema, - type AppFormEditFormType -} from '@fastgpt/global/core/app/type'; +import { type AppDetailType, type AppSchemaType } from '@fastgpt/global/core/app/type'; +import type { AppFormEditFormType } from '@fastgpt/global/core/app/formEdit/type'; import { chatHistoryValueDesc, FlowNodeTypeEnum @@ -61,7 +58,7 @@ export const workflowSystemVariables: EditorVariablePickerType[] = [ } ]; -export const getAppQGuideCustomURL = (appDetail: AppDetailType | AppSchema): string => { +export const getAppQGuideCustomURL = (appDetail: AppDetailType | AppSchemaType): string => { return ( appDetail?.modules .find((m) => m.flowNodeType === FlowNodeTypeEnum.systemConfig) diff --git a/projects/app/src/web/core/chat/utils.ts b/projects/app/src/web/core/chat/utils.ts index 16049e002..494ab2832 100644 --- a/projects/app/src/web/core/chat/utils.ts +++ b/projects/app/src/web/core/chat/utils.ts @@ -1,5 +1,5 @@ import { FlowNodeTypeEnum } from '@fastgpt/global/core/workflow/node/constant'; -import { type StoreNodeItemType } from '@fastgpt/global/core/workflow/type/node.d'; +import { type StoreNodeItemType } from '@fastgpt/global/core/workflow/type/node'; import { useSystemStore } from '@/web/common/system/useSystemStore'; import { NodeInputKeyEnum } from '@fastgpt/global/core/workflow/constants'; import { getWebLLMModel } from '@/web/common/system/utils'; diff --git a/projects/app/src/web/core/dataset/api.ts b/projects/app/src/web/core/dataset/api.ts index 8aeec32a2..8e1bdd1a6 100644 --- a/projects/app/src/web/core/dataset/api.ts +++ b/projects/app/src/web/core/dataset/api.ts @@ -83,7 +83,7 @@ import type { DatasetCreateWithFilesBody, DatasetCreateWithFilesResponse } from '@/pages/api/core/dataset/createWithFiles'; -import type { PresignDatasetFileGetUrlParams } from '@fastgpt/global/core/dataset/v2/api'; +import type { ParentIdType } from '@fastgpt/global/common/parentFolder/type'; /* ======================== dataset ======================= */ export const getDatasets = (data: GetDatasetListBody) => @@ -180,7 +180,7 @@ export const postSearchText = (data: SearchTestProps) => /* ============================= collections ==================================== */ export const getDatasetCollections = (data: GetDatasetCollectionsProps) => POST>(`/core/dataset/collection/listV2`, data); -export const getDatasetCollectionPathById = (parentId: string) => +export const getDatasetCollectionPathById = (parentId: ParentIdType) => GET(`/core/dataset/collection/paths`, { parentId }); export const getDatasetCollectionById = (id: string) => GET(`/core/dataset/collection/detail`, { id }); diff --git a/projects/app/src/web/core/dataset/components/SelectCollections.tsx b/projects/app/src/web/core/dataset/components/SelectCollections.tsx index 79efd244a..136d00bd9 100644 --- a/projects/app/src/web/core/dataset/components/SelectCollections.tsx +++ b/projects/app/src/web/core/dataset/components/SelectCollections.tsx @@ -13,6 +13,7 @@ import { useLoading } from '@fastgpt/web/hooks/useLoading'; import { useContextSelector } from 'use-context-selector'; import { DatasetPageContext } from '../context/datasetPageContext'; import EmptyTip from '@fastgpt/web/components/common/EmptyTip'; +import type { ParentIdType } from '@fastgpt/global/common/parentFolder/type'; const SelectCollections = ({ datasetId, @@ -29,8 +30,8 @@ const SelectCollections = ({ datasetId: string; type: 'folder' | 'collection'; onClose: () => void; - onChange?: (e: { parentId: string; collectionIds: string[] }) => void | Promise; - onSuccess?: (e: { parentId: string; collectionIds: string[] }) => void | Promise; + onChange?: (e: { parentId: ParentIdType; collectionIds: string[] }) => void | Promise; + onSuccess?: (e: { parentId: ParentIdType; collectionIds: string[] }) => void | Promise; defaultSelectedId?: string[]; title?: string; tip?: string; @@ -44,7 +45,7 @@ const SelectCollections = ({ const { Loading } = useLoading(); const [selectedDatasetCollectionIds, setSelectedDatasetCollectionIds] = useState(defaultSelectedId); - const [parentId, setParentId] = useState(''); + const [parentId, setParentId] = useState(''); useQuery(['loadDatasetDetail', datasetId], () => loadDatasetDetail(datasetId)); diff --git a/projects/app/src/web/core/dataset/constants.ts b/projects/app/src/web/core/dataset/constants.ts index 2f0587014..1c34a6be1 100644 --- a/projects/app/src/web/core/dataset/constants.ts +++ b/projects/app/src/web/core/dataset/constants.ts @@ -1,4 +1,4 @@ -import { defaultQAModels, defaultVectorModels } from '@fastgpt/global/core/ai/model'; +import { defaultQAModels, defaultVectorModels } from '@fastgpt/global/core/ai/constants'; import { DatasetCollectionDataProcessModeEnum, DatasetCollectionTypeEnum, diff --git a/projects/app/src/web/core/workflow/adapt.ts b/projects/app/src/web/core/workflow/adapt.ts index 1c429b9b4..fb03ab5f5 100644 --- a/projects/app/src/web/core/workflow/adapt.ts +++ b/projects/app/src/web/core/workflow/adapt.ts @@ -189,7 +189,7 @@ type V1WorkflowType = { max?: number; // slider, number input min?: number; // slider, number input - llmModelType?: `${LLMModelTypeEnum}`; + llmModelType?: LLMModelTypeEnum; }[]; outputs: { type?: OutputTypeEnum; diff --git a/projects/app/src/web/core/workflow/utils.ts b/projects/app/src/web/core/workflow/utils.ts index 7591ec776..80686503c 100644 --- a/projects/app/src/web/core/workflow/utils.ts +++ b/projects/app/src/web/core/workflow/utils.ts @@ -1,7 +1,4 @@ -import type { - StoreNodeItemType, - FlowNodeItemType -} from '@fastgpt/global/core/workflow/type/node.d'; +import type { StoreNodeItemType, FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node'; import type { FlowNodeTemplateType } from '@fastgpt/global/core/workflow/type/node'; import type { Edge, Node, XYPosition } from 'reactflow'; import { moduleTemplatesFlat } from '@fastgpt/global/core/workflow/template/constants'; diff --git a/projects/app/src/web/support/user/team/org/hooks/useOrg.tsx b/projects/app/src/web/support/user/team/org/hooks/useOrg.tsx index b81623837..4407e7ec9 100644 --- a/projects/app/src/web/support/user/team/org/hooks/useOrg.tsx +++ b/projects/app/src/web/support/user/team/org/hooks/useOrg.tsx @@ -2,7 +2,10 @@ import { getOrgChildrenPath } from '@fastgpt/global/support/user/team/org/consta import { type OrgListItemType } from '@fastgpt/global/support/user/team/org/type'; import { memo, useEffect, useMemo, useState } from 'react'; import { useUserStore } from '../../../useUserStore'; -import { type ParentTreePathItemType } from '@fastgpt/global/common/parentFolder/type'; +import type { + ParentIdType, + ParentTreePathItemType +} from '@fastgpt/global/common/parentFolder/type'; import { useRequest2 } from '@fastgpt/web/hooks/useRequest'; import { getOrgList, getOrgMembers } from '../api'; import { useScrollPagination } from '@fastgpt/web/hooks/useScrollPagination'; @@ -84,7 +87,8 @@ function useOrg({ withPermission = true }: { withPermission?: boolean } = {}) { refreshDeps: [path] }); - const onPathClick = (path: string) => { + const onPathClick = (path: ParentIdType) => { + path = path || ''; const pathIds = path.split('/'); setOrgStack(orgStack.filter((org) => pathIds.includes(org.pathId))); setSearchKey(''); diff --git a/projects/app/test/pageComponents/app/detail/WorkflowComponents/utils.test.ts b/projects/app/test/pageComponents/app/detail/WorkflowComponents/utils.test.ts index 25aeb825c..94ebc9740 100644 --- a/projects/app/test/pageComponents/app/detail/WorkflowComponents/utils.test.ts +++ b/projects/app/test/pageComponents/app/detail/WorkflowComponents/utils.test.ts @@ -6,7 +6,7 @@ import { } from '@/pageComponents/app/detail/WorkflowComponents/utils'; import { FlowNodeTypeEnum } from '@fastgpt/global/core/workflow/node/constant'; import { NodeInputKeyEnum } from '@fastgpt/global/core/workflow/constants'; -import type { FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node.d'; +import type { FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node'; import type { AppDetailType } from '@fastgpt/global/core/app/type'; vi.mock('@/web/core/workflow/utils', () => ({ diff --git a/projects/app/test/web/core/app/utils.test.ts b/projects/app/test/web/core/app/utils.test.ts index 06e65be07..0c1af8503 100644 --- a/projects/app/test/web/core/app/utils.test.ts +++ b/projects/app/test/web/core/app/utils.test.ts @@ -4,7 +4,7 @@ import { form2AppWorkflow } from '@/pageComponents/app/detail/Edit/SimpleApp/uti import { FlowNodeTypeEnum } from '@fastgpt/global/core/workflow/node/constant'; import { NodeInputKeyEnum } from '@fastgpt/global/core/workflow/constants'; import { getDefaultAppForm } from '@fastgpt/global/core/app/utils'; -import type { AppFormEditFormType } from '@fastgpt/global/core/app/type'; +import type { AppFormEditFormType } from '@fastgpt/global/core/app/formEdit/type'; describe('form2AppWorkflow', () => { const mockT = (str: string) => str; diff --git a/test/setupModels.ts b/test/setupModels.ts index fd6f8eace..b75564f89 100644 --- a/test/setupModels.ts +++ b/test/setupModels.ts @@ -1,4 +1,4 @@ -import { ModelTypeEnum } from 'packages/global/core/ai/model'; +import { ModelTypeEnum } from 'packages/global/core/ai/constants'; export default async function setupModels() { global.llmModelMap = new Map();