Skip to content

feat: system tool #4745

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: test-tool
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/global/core/app/mcpTools/utils.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { nanoid } from 'nanoid';
import { i18nT } from '../../../../web/i18n/utils';
import { NodeOutputKeyEnum, WorkflowIOValueTypeEnum } from '../../workflow/constants';
import {
FlowNodeInputTypeEnum,
FlowNodeOutputTypeEnum,
FlowNodeTypeEnum
} from '../../workflow/node/constant';
import { nanoid } from 'nanoid';
import { ToolType } from '../type';
import { i18nT } from '../../../../web/i18n/utils';
import { RuntimeNodeItemType } from '../../workflow/runtime/type';
import { ToolType } from '../type';

export const getMCPToolSetRuntimeNode = ({
url,
Expand Down
8 changes: 5 additions & 3 deletions packages/global/core/plugin/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export const pluginTypeMap = {
};

export enum PluginSourceEnum {
personal = 'personal',
community = 'community',
commercial = 'commercial'
personal = 'personal', // APP
systemTool = 'systemTool', // FastGPT-Tool
commercial = 'commercial', // pro 后台配置的,有 associatedPluginId
// @deprecated
community = 'community'
}
2 changes: 1 addition & 1 deletion packages/global/core/workflow/node/constant.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { WorkflowIOValueTypeEnum } from '../constants';
import { i18nT } from '../../../../web/i18n/utils';
import { WorkflowIOValueTypeEnum } from '../constants';
export enum FlowNodeInputTypeEnum { // render ui
reference = 'reference', // reference to other node output
input = 'input', // one line input
Expand Down
34 changes: 16 additions & 18 deletions packages/global/core/workflow/runtime/type.d.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
import { NextApiResponse } from 'next';
import { WorkflowResponseType } from '../../../../service/core/workflow/dispatch/type';
import { OpenaiAccountType } from '../../../support/user/team/type';
import { ChatNodeUsageType } from '../../../support/wallet/bill/type';
import { CompletionFinishReason } from '../../ai/type';
import { AppSchema } from '../../app/type';
import {
AIChatItemValueItemType,
ChatItemType,
UserChatItemValueItemType,
ToolRunResponseItemType,
NodeOutputItemType,
AIChatItemValueItemType
UserChatItemValueItemType
} from '../../chat/type';
import { FlowNodeInputItemType, FlowNodeOutputItemType } from '../type/io.d';
import { StoreNodeItemType } from '../type/node';
import { DispatchNodeResponseKeyEnum } from './constants';
import { StoreEdgeItemType } from '../type/edge';
import { SearchDataResponseItemType } from '../../dataset/type';
import { NodeInputKeyEnum } from '../constants';
import { ClassifyQuestionAgentItemType } from '../template/system/classifyQuestion/type';
import { NextApiResponse } from 'next';
import { UserModelSchema } from '../../../support/user/type';
import { AppDetailType, AppSchema } from '../../app/type';
import { RuntimeNodeItemType } from '../runtime/type';
import { RuntimeEdgeItemType } from './edge';
import { ReadFileNodeResponse } from '../template/system/readFiles/type';
import { UserSelectOptionType } from '../template/system/userSelect/type';
import { WorkflowResponseType } from '../../../../service/core/workflow/dispatch/type';
import { AiChatQuoteRoleType } from '../template/system/aiChat/type';
import { LafAccountType, OpenaiAccountType } from '../../../support/user/team/type';
import { CompletionFinishReason } from '../../ai/type';
import { ClassifyQuestionAgentItemType } from '../template/system/classifyQuestion/type';
import { WorkflowInteractiveResponseType } from '../template/system/interactive/type';
import { SearchDataResponseItemType } from '../../dataset/type';
import { ReadFileNodeResponse } from '../template/system/readFiles/type';
import { StoreEdgeItemType } from '../type/edge';
import { FlowNodeInputItemType, FlowNodeOutputItemType } from '../type/io.d';
import { StoreNodeItemType } from '../type/node';
import { DispatchNodeResponseKeyEnum } from './constants';
import { RuntimeEdgeItemType } from './edge';
export type ExternalProviderType = {
openaiAccount?: OpenaiAccountType;
externalWorkflowVariables?: Record<string, string>;
Expand Down Expand Up @@ -93,6 +90,7 @@ export type RuntimeNodeItemType = {
intro?: StoreNodeItemType['intro'];
flowNodeType: StoreNodeItemType['flowNodeType'];
showStatus?: StoreNodeItemType['showStatus'];
toolConfig?: StoreNodeItemType['toolConfig'];
isEntry?: boolean;

inputs: FlowNodeInputItemType[];
Expand Down
37 changes: 21 additions & 16 deletions packages/global/core/workflow/runtime/utils.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
import json5 from 'json5';
import { replaceVariable, valToStr } from '../../../common/string/tools';
import { ChatItemValueTypeEnum, ChatRoleEnum } from '../../../core/chat/constants';
import { ChatItemType, NodeOutputItemType } from '../../../core/chat/type';
import { ChatCompletionRequestMessageRoleEnum } from '../../ai/constants';
import { NodeInputKeyEnum, NodeOutputKeyEnum, WorkflowIOValueTypeEnum } from '../constants';
import {
NodeInputKeyEnum,
NodeOutputKeyEnum,
VARIABLE_NODE_ID,
WorkflowIOValueTypeEnum
} from '../constants';
import { FlowNodeTypeEnum } from '../node/constant';
import { StoreNodeItemType } from '../type/node';
import { StoreEdgeItemType } from '../type/edge';
import { RuntimeEdgeItemType, RuntimeNodeItemType } from './type';
import { VARIABLE_NODE_ID } from '../constants';
import { isValidReferenceValueFormat } from '../utils';
import { FlowNodeOutputItemType, ReferenceValueType } from '../type/io';
import { ChatItemType, NodeOutputItemType } from '../../../core/chat/type';
import { ChatItemValueTypeEnum, ChatRoleEnum } from '../../../core/chat/constants';
import { replaceVariable, valToStr } from '../../../common/string/tools';
import json5 from 'json5';
import {
InteractiveNodeResponseType,
WorkflowInteractiveResponseType
} from '../template/system/interactive/type';
import { StoreEdgeItemType } from '../type/edge';
import { FlowNodeOutputItemType, ReferenceValueType } from '../type/io';
import { StoreNodeItemType } from '../type/node';
import { isValidReferenceValueFormat } from '../utils';
import { RuntimeEdgeItemType, RuntimeNodeItemType } from './type';

export const extractDeepestInteractive = (
interactive: WorkflowInteractiveResponseType
Expand Down Expand Up @@ -151,7 +155,7 @@ export const valueTypeFormat = (value: any, type?: WorkflowIOValueTypeEnum) => {
return value;
};

/*
/*
Get interaction information (if any) from the last AI message.
What can be done:
1. Get the interactive data
Expand Down Expand Up @@ -254,7 +258,8 @@ export const storeNodes2RuntimeNodes = (
inputs: node.inputs,
outputs: node.outputs,
pluginId: node.pluginId,
version: node.version
version: node.version,
toolConfig: node.toolConfig
};
}) || []
);
Expand All @@ -268,7 +273,7 @@ export const filterWorkflowEdges = (edges: RuntimeEdgeItemType[]) => {
);
};

/*
/*
1. 输入线分类:普通线和递归线(可以追溯到自身)
2. 起始线全部非 waiting 执行,或递归线全部非 waiting 执行
*/
Expand All @@ -279,7 +284,7 @@ export const checkNodeRunStatus = ({
node: RuntimeNodeItemType;
runtimeEdges: RuntimeEdgeItemType[];
}) => {
/*
/*
区分普通连线和递归连线
递归连线:可以通过往上查询 nodes,最终追溯到自身
*/
Expand Down Expand Up @@ -363,7 +368,7 @@ export const checkNodeRunStatus = ({
return 'wait';
};

/*
/*
Get the value of the reference variable/node output
1. [string,string]
2. [string,string][]
Expand Down
36 changes: 18 additions & 18 deletions packages/global/core/workflow/template/constants.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
import { SystemConfigNode } from './system/systemConfig';
import { PluginConfigNode } from './system/pluginConfig';
import { EmptyNode } from './system/emptyNode';
import { WorkflowStart } from './system/workflowStart';
import { AiChatModule } from './system/aiChat';
import { DatasetSearchModule } from './system/datasetSearch';
import { DatasetConcatModule } from './system/datasetConcat';
import { AssignedAnswerModule } from './system/assignedAnswer';
import { ClassifyQuestionModule } from './system/classifyQuestion/index';
import { ContextExtractModule } from './system/contextExtract/index';
import { DatasetConcatModule } from './system/datasetConcat';
import { DatasetSearchModule } from './system/datasetSearch';
import { EmptyNode } from './system/emptyNode';
import { HttpNode468 } from './system/http468';
import { PluginConfigNode } from './system/pluginConfig';
import { SystemConfigNode } from './system/systemConfig';
import { WorkflowStart } from './system/workflowStart';

import { ToolModule } from './system/tools';
import { StopToolNode } from './system/stopTool';
import { ToolModule } from './system/tools';

import { RunAppModule } from './system/abandoned/runApp/index';
import { PluginInputModule } from './system/pluginInput';
import { PluginOutputModule } from './system/pluginOutput';
import { RunPluginModule } from './system/runPlugin';
import { RunAppNode } from './system/runApp';
import { AiQueryExtension } from './system/queryExtension';
import { RunAppNode } from './system/runApp';
import { RunPluginModule } from './system/runPlugin';

import type { FlowNodeTemplateType } from '../type/node';
import { LafModule } from './system/laf';
import { IfElseNode } from './system/ifElse/index';
import { VariableUpdateNode } from './system/variableUpdate';
import { CodeNode } from './system/sandbox';
import { TextEditorNode } from './system/textEditor';
import { CustomFeedbackNode } from './system/customFeedback';
import { ReadFilesNode } from './system/readFiles';
import { IfElseNode } from './system/ifElse/index';
import { FormInputNode } from './system/interactive/formInput';
import { UserSelectNode } from './system/interactive/userSelect';
import { LafModule } from './system/laf';
import { LoopNode } from './system/loop/loop';
import { LoopStartNode } from './system/loop/loopStart';
import { LoopEndNode } from './system/loop/loopEnd';
import { FormInputNode } from './system/interactive/formInput';
import { ToolParamsNode } from './system/toolParams';
import { LoopStartNode } from './system/loop/loopStart';
import { ReadFilesNode } from './system/readFiles';
import { RunToolNode } from './system/runTool';
import { RunToolSetNode } from './system/runToolSet';
import { CodeNode } from './system/sandbox';
import { TextEditorNode } from './system/textEditor';
import { ToolParamsNode } from './system/toolParams';
import { VariableUpdateNode } from './system/variableUpdate';

const systemNodes: FlowNodeTemplateType[] = [
AiChatModule,
Expand Down
36 changes: 14 additions & 22 deletions packages/global/core/workflow/type/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
import { FlowNodeTypeEnum } from '../node/constant';
import {
WorkflowIOValueTypeEnum,
NodeOutputKeyEnum,
FlowNodeTemplateTypeEnum,
VariableInputEnum
} from '../constants';
import { DispatchNodeResponseKeyEnum } from '../runtime/constants';
import { CustomInputItemType, FlowNodeInputItemType, FlowNodeOutputItemType } from './io.d';
import {
ChatHistoryItemResType,
ChatItemType,
ChatItemValueItemType,
ToolRunResponseItemType
} from '../../chat/type';
import { ChatNodeUsageType } from '../../../support/wallet/bill/type';
import { PluginTypeEnum } from '../../plugin/constants';
import { StoreEdgeItemType } from './edge';
import { AppChatConfigType } from '../../app/type';
import { ParentIdType } from 'common/parentFolder/type';
import { AppTypeEnum } from 'core/app/constants';
import { FlowNodeTemplateType, StoreNodeItemType } from './node';
import { AppChatConfigType } from '../../app/type';
import { StoreEdgeItemType } from './edge';
import { StoreNodeItemType } from './node';

export type localeType = 'en' | 'zh-CN' | 'zh-Hant';
export type I18nStringType =
| {
'zh-CN': string;
'zh-Hant'?: string;
en?: string;
}
| string;

export type WorkflowTemplateBasicType = {
nodes: StoreNodeItemType[];
Expand All @@ -31,9 +23,9 @@ export type WorkflowTemplateType = {
parentId?: ParentIdType;
isFolder?: boolean;

name: string;
name: I18nStringType;
avatar: string;
intro?: string;
intro?: I18nStringType;
author?: string;
courseUrl?: string;
version: string;
Expand Down
34 changes: 10 additions & 24 deletions packages/global/core/workflow/type/node.d.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,8 @@
import { FlowNodeTypeEnum } from '../node/constant';
import {
WorkflowIOValueTypeEnum,
NodeOutputKeyEnum,
FlowNodeTemplateTypeEnum,
VariableInputEnum
} from '../constants';
import { DispatchNodeResponseKeyEnum } from '../runtime/constants';
import { FlowNodeInputItemType, FlowNodeOutputItemType } from './io.d';
import { UserModelSchema } from '../../../support/user/type';
import {
ChatHistoryItemResType,
ChatItemType,
ChatItemValueItemType,
ToolRunResponseItemType,
UserChatItemValueItemType
} from '../../chat/type';
import { ChatNodeUsageType } from '../../../support/wallet/bill/type';
import { RuntimeNodeItemType } from '../runtime/type';
import { PluginTypeEnum } from '../../plugin/constants';
import { RuntimeEdgeItemType, StoreEdgeItemType } from './edge';
import { NextApiResponse } from 'next';
import { AppDetailType, AppSchema } from '../../app/type';
import { ParentIdType } from 'common/parentFolder/type';
import { AppTypeEnum } from 'core/app/constants';
import { ChatHistoryItemResType } from '../../chat/type';
import { FlowNodeTypeEnum } from '../node/constant';
import { WorkflowInteractiveResponseType } from '../template/system/interactive/type';
import { FlowNodeInputItemType, FlowNodeOutputItemType } from './io.d';

export type FlowNodeCommonType = {
parentNodeId?: string;
Expand All @@ -45,6 +24,13 @@ export type FlowNodeCommonType = {
isFolder?: boolean;
// pluginType?: AppTypeEnum;
pluginData?: PluginDataType;

// Tool config: systemTool, mcpTool, httpTool, etc.
toolConfig?: {
systemToolConfig?: {
toolId: string;
};
};
};

export type PluginDataType = {
Expand Down
28 changes: 28 additions & 0 deletions packages/global/core/workflow/type/tool.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export type ToolType = {
type: string;
toolId: string;
isFolder?: boolean;
parentId?: string;
name: {
'zh-CN': string;
'zh-Hant'?: string;
en?: string | undefined;
};
version: string;
versionList: string[];
description: {
'zh-CN': string;
'zh-Hant'?: string;
en?: string | undefined;
};
icon: string;
author?: string | undefined;
docURL?: string | undefined;

workflow?: {
nodes: Array<any>;
edges: Array<any>;
};
inputs?: Array<any>;
outputs?: Array<any>;
};
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy