Skip to content

Commit

Permalink
简单的支持提示词运行tool。优化workflow模板 (labring#49)
Browse files Browse the repository at this point in the history
* remove templates

* fix: request body undefined

* feat: prompt tool run

* feat: workflow tamplates modal

* perf: plugin start
  • Loading branch information
c121914yu committed Mar 20, 2024
1 parent d67972f commit 695db95
Show file tree
Hide file tree
Showing 59 changed files with 1,564 additions and 1,803 deletions.
7 changes: 0 additions & 7 deletions packages/global/core/app/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,9 @@ export type CreateAppParams = {
export interface AppUpdateParams {
name?: string;
type?: `${AppTypeEnum}`;
simpleTemplateId?: string;
avatar?: string;
intro?: string;
modules?: AppSchema['modules'];
permission?: AppSchema['permission'];
teamTags?: AppSchema['teamTags'];
}

export type FormatForm2ModulesProps = {
formData: AppSimpleEditFormType;
chatModelMaxToken: number;
llmModelList: LLMModelItemType[];
};
32 changes: 0 additions & 32 deletions packages/global/core/app/type.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export interface AppSchema {
tmbId: string;
name: string;
type: `${AppTypeEnum}`;
simpleTemplateId: string;
avatar: string;
intro: string;
updateTime: number;
Expand Down Expand Up @@ -94,34 +93,3 @@ export type AppSimpleEditFormType = {
};
};
};

/* simple mode template*/
export type AppSimpleEditConfigTemplateType = {
id: string;
name: string;
desc: string;
systemForm: {
aiSettings?: {
model?: boolean;
systemPrompt?: boolean;
temperature?: boolean;
maxToken?: boolean;
quoteTemplate?: boolean;
quotePrompt?: boolean;
};
dataset?: {
datasets?: boolean;
similarity?: boolean;
limit?: boolean;
searchMode: `${DatasetSearchModeEnum}`;
usingReRank: boolean;
searchEmptyText?: boolean;
};
userGuide?: {
welcomeText?: boolean;
variables?: boolean;
questionGuide?: boolean;
tts?: boolean;
};
};
};
8 changes: 6 additions & 2 deletions packages/global/core/module/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ export enum ModuleInputKeyEnum {
runAppSelectApp = 'app',

// plugin
pluginId = 'pluginId'
pluginId = 'pluginId',
pluginStart = 'pluginStart'
}

export enum ModuleOutputKeyEnum {
Expand Down Expand Up @@ -117,7 +118,10 @@ export enum ModuleOutputKeyEnum {
selectedTools = 'selectedTools',

// http
httpRawResponse = 'httpRawResponse'
httpRawResponse = 'httpRawResponse',

// plugin
pluginStart = 'pluginStart'
}

export enum VariableInputEnum {
Expand Down
14 changes: 7 additions & 7 deletions packages/global/core/module/template/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,7 @@ export const moduleTemplatesFlat: FlowNodeTemplateType[] = [
export const moduleTemplatesList: moduleTemplateListType = [
{
type: FlowNodeTemplateTypeEnum.userGuide,
label: 'core.module.template.Guide module',
list: []
},
{
type: FlowNodeTemplateTypeEnum.systemInput,
label: 'core.module.template.System input module',
label: '',
list: []
},
{
Expand All @@ -109,12 +104,17 @@ export const moduleTemplatesList: moduleTemplateListType = [
},
{
type: FlowNodeTemplateTypeEnum.personalPlugin,
label: 'core.module.template.My plugin module',
label: '',
list: []
},
{
type: FlowNodeTemplateTypeEnum.other,
label: '其他',
list: []
},
{
type: FlowNodeTemplateTypeEnum.systemInput,
label: 'core.module.template.System input module',
list: []
}
];
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const getOneQuoteInputTemplate = (key = getNanoid()) => ({
export const DatasetConcatModule: FlowNodeTemplateType = {
id: FlowNodeTypeEnum.datasetConcatNode,
flowType: FlowNodeTypeEnum.datasetConcatNode,
templateType: FlowNodeTemplateTypeEnum.tools,
templateType: FlowNodeTemplateTypeEnum.other,
avatar: '/imgs/module/concat.svg',
name: '知识库搜索引用合并',
intro: '可以将多个知识库搜索结果进行合并输出。使用 RRF 的合并方式进行最终排序输出。',
Expand Down
36 changes: 32 additions & 4 deletions packages/global/core/module/template/system/pluginInput.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import { FlowNodeTemplateTypeEnum } from '../../constants';
import { FlowNodeTypeEnum } from '../../node/constant';
import {
FlowNodeTemplateTypeEnum,
ModuleIOValueTypeEnum,
ModuleInputKeyEnum,
ModuleOutputKeyEnum
} from '../../constants';
import {
FlowNodeInputTypeEnum,
FlowNodeOutputTypeEnum,
FlowNodeTypeEnum
} from '../../node/constant';
import { FlowNodeTemplateType } from '../../type.d';

export const PluginInputModule: FlowNodeTemplateType = {
Expand All @@ -10,6 +19,25 @@ export const PluginInputModule: FlowNodeTemplateType = {
name: '定义插件输入',
intro: '自定义配置外部输入,使用插件时,仅暴露自定义配置的输入',
showStatus: false,
inputs: [],
outputs: []
inputs: [
{
key: ModuleInputKeyEnum.pluginStart,
type: FlowNodeInputTypeEnum.hidden,
valueType: ModuleIOValueTypeEnum.boolean,
label: '插件开始运行',
description:
'插件开始运行时,会输出一个 True 的标识。有时候,插件不会有额外的的输入,为了顺利的进入下一个阶段,你可以将该值连接到下一个节点的触发器中。',
showTargetInApp: true,
showTargetInPlugin: true
}
],
outputs: [
{
key: ModuleOutputKeyEnum.pluginStart,
label: '插件开始运行',
type: FlowNodeOutputTypeEnum.source,
valueType: ModuleIOValueTypeEnum.boolean,
targets: []
}
]
};
2 changes: 1 addition & 1 deletion packages/global/core/module/template/system/stopTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const StopToolNode: FlowNodeTemplateType = {
templateType: FlowNodeTemplateTypeEnum.functionCall,
flowType: FlowNodeTypeEnum.stopTool,
avatar: '/imgs/module/toolStop.svg',
name: '工具终止',
name: '工具调用终止',
intro:
'该模块需配置工具调用使用。当该模块被执行时,本次工具调用将会强制结束,并且不再调用AI针对工具调用结果回答问题。',
inputs: [Input_Template_Switch],
Expand Down
2 changes: 1 addition & 1 deletion packages/global/core/module/template/system/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const ToolModule: FlowNodeTemplateType = {
templateType: FlowNodeTemplateTypeEnum.functionCall,
avatar: '/imgs/module/tool.svg',
name: '工具调用(实验)',
intro: '通过AI模型自动选择一个或多个工具进行调用。工具可以是其他功能块或插件。',
intro: '通过AI模型自动选择一个或多个功能块进行调用,也可以对插件进行调用。',
showStatus: true,
inputs: [
Input_Template_Switch,
Expand Down
16 changes: 10 additions & 6 deletions packages/global/core/module/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { FlowNodeInputItemType, FlowNodeOutputItemType } from './node/type';
import { AppTTSConfigType, ModuleItemType, VariableItemType } from './type';
import { Input_Template_Switch } from './template/input';
import { EditorVariablePickerType } from '../../../web/components/common/Textarea/PromptEditor/type';
import { Output_Template_Finish } from './template/output';

/* module */
export const getGuideModule = (modules: ModuleItemType[]) =>
Expand Down Expand Up @@ -92,13 +93,16 @@ export const plugin2ModuleIO = (
connected: false
}))
]
: [],
: [Input_Template_Switch],
outputs: pluginOutput
? pluginOutput.outputs.map((item) => ({
...item,
edit: false
}))
: []
? [
...pluginOutput.outputs.map((item) => ({
...item,
edit: false
})),
Output_Template_Finish
]
: [Output_Template_Finish]
};
};

Expand Down
4 changes: 0 additions & 4 deletions packages/service/core/app/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ const AppSchema = new Schema({
default: 'advanced',
enum: Object.keys(AppTypeMap)
},
simpleTemplateId: {
type: String,
required: true
},
avatar: {
type: String,
default: '/icon/logo.svg'
Expand Down
3 changes: 3 additions & 0 deletions packages/web/components/common/Icon/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,11 @@ export const iconPaths = {
'core/dataset/rerank': () => import('./icons/core/dataset/rerank.svg'),
'core/dataset/tableCollection': () => import('./icons/core/dataset/tableCollection.svg'),
'core/dataset/websiteDataset': () => import('./icons/core/dataset/websiteDataset.svg'),
'core/modules/basicNode': () => import('./icons/core/modules/basicNode.svg'),
'core/modules/flowLight': () => import('./icons/core/modules/flowLight.svg'),
'core/modules/previewLight': () => import('./icons/core/modules/previewLight.svg'),
'core/modules/systemPlugin': () => import('./icons/core/modules/systemPlugin.svg'),
'core/modules/teamPlugin': () => import('./icons/core/modules/teamPlugin.svg'),
'core/modules/variable': () => import('./icons/core/modules/variable.svg'),
'core/modules/welcomeText': () => import('./icons/core/modules/welcomeText.svg'),
date: () => import('./icons/date.svg'),
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 6 additions & 4 deletions packages/web/components/common/Tabs/RowTabs.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import { Flex, Box } from '@chakra-ui/react';
import { Flex, Box, BoxProps } from '@chakra-ui/react';
import MyIcon from '../Icon';

type Props = {
type Props = BoxProps & {
list: {
icon?: string;
label: string | React.ReactNode;
Expand All @@ -12,7 +12,7 @@ type Props = {
onChange: (e: string) => void;
};

const RowTabs = ({ list, value, onChange }: Props) => {
const RowTabs = ({ list, value, onChange, py = '7px', ...props }: Props) => {
return (
<Box
display={'inline-flex'}
Expand All @@ -23,15 +23,17 @@ const RowTabs = ({ list, value, onChange }: Props) => {
borderColor={'borderColor.base'}
bg={'myGray.50'}
gap={'4px'}
{...props}
>
{list.map((item) => (
<Flex
key={item.value}
flex={'1 0 0'}
alignItems={'center'}
cursor={'pointer'}
borderRadius={'md'}
px={'12px'}
py={'7px'}
py={py}
userSelect={'none'}
{...(value === item.value
? {
Expand Down
4 changes: 2 additions & 2 deletions projects/app/data/pluginTemplates/textEditor.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"author": "FastGPT Team",
"templateType": "tools",
"name": "core.module.template.textEditor",
"name": "文本加工",
"avatar": "/imgs/module/textEditor.svg",
"intro": "core.module.template.textEditor intro",
"intro": "可对固定或传入的文本进行加工后输出,非字符串类型数据最终会转成字符串类型。",
"showStatus": false,
"modules": [
{
Expand Down
4 changes: 2 additions & 2 deletions projects/app/data/pluginTemplates/tfSwitch.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"author": "FastGPT Team",
"templateType": "tools",
"name": "core.module.template.TFSwitch",
"name": "判断器",
"avatar": "/imgs/module/tfSwitch.svg",
"intro": "core.module.template.TFSwitch intro",
"intro": "根据传入的内容进行 True False 输出。默认情况下,当传入的内容为 false, undefined, null, 0, none 时,会输出 false。你也可以增加一些自定义的字符串来补充输出 false 的内容。非字符、非数字、非布尔类型,直接输出 True。",
"showStatus": false,
"modules": [
{
Expand Down
28 changes: 0 additions & 28 deletions projects/app/data/simpleTemplates/fastgpt-simple.json

This file was deleted.

3 changes: 3 additions & 0 deletions projects/app/public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,7 @@
"Ai chat intro": "Request LLM chat",
"Assigned reply": "Assigned reply",
"Assigned reply intro": "The module can respond directly to a specified piece of content. Often used to guide and prompt. When non-string content is passed in, it is converted to a string for output.",
"Basic Node": "Basic Node",
"Chat entrance": "Chat entrance",
"Chat entrance intro": "When the user sends a content, the flow will start from this module.",
"Classify question": "Classify question",
Expand All @@ -920,11 +921,13 @@
"Http request": "Http request",
"Http request intro": " Can issue an HTTP request to implement more complex operations (Internet search, database query, etc.)",
"My plugin module": "Personal plugins",
"Personal Plugin": "Personal Plugin",
"Query extension": "Query extension",
"Query extension intro": "If the problem completion function is enabled, the accuracy of knowledge base search can be improved in continuous conversations. After this function is enabled, when searching the knowledge base, AI will be used to complete the missing information of the problem according to the conversation records.",
"Response module": "Text output",
"Running app": "Running app",
"Running app intro": "You can select a different app to run",
"System Plugin": "System Plugin",
"System input module": "System input",
"TFSwitch": "TF Switch",
"TFSwitch intro": "Output True False based on what is passed in. By default, false is printed when the content passed in is false, undefined, null, 0, none. You can also add some custom strings to supplement the output of false.",
Expand Down
Loading

0 comments on commit 695db95

Please sign in to comment.