Skip to content

Commit

Permalink
Feat: Workflow loop node;feat: support openai o1;perf: query extensio…
Browse files Browse the repository at this point in the history
…n prompt;fix: intro was not delivered when the datase was created (labring#2719)

* feat: loop node (labring#2675)

* loop node frontend

* loop-node

* fix-code

* fix version

* fix

* fix

* fix

* perf: loop array code

* perf: get histories error tip

* feat: support openai o1

* perf: query extension prompt

* feat: 4811 doc

* remove log

* fix: loop node zindex & variable picker type (labring#2710)

* perf: performance

* perf: workflow performance

* remove uninvalid code

* perf:code

* fix: invoice table refresh

* perf: loop node data type

* fix: loop node store assistants

* perf: target connection

* feat: loop node support help line

* perf: add default icon

---------

Co-authored-by: heheer <[email protected]>
  • Loading branch information
c121914yu and newfish-cmyk authored Sep 15, 2024
1 parent 1ebc95a commit 2bdda46
Show file tree
Hide file tree
Showing 86 changed files with 2,002 additions and 719 deletions.
79 changes: 73 additions & 6 deletions docSite/content/zh-cn/docs/development/upgrading/4811.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,84 @@ weight: 813

### 1. 做好数据备份

### 2. 修改配置文件

如需增加 openai o1 模型,可添加如下配置:

```json
{
"model": "o1-mini",
"name": "o1-mini",
"avatar": "/imgs/model/openai.svg",
"maxContext": 125000,
"maxResponse": 4000,
"quoteMaxToken": 120000,
"maxTemperature": 1.2,
"charsPointsPrice": 0,
"censor": false,
"vision": false,
"datasetProcess": false,
"usedInClassify": true,
"usedInExtractFields": true,
"usedInToolCall": true,
"usedInQueryExtension": true,
"toolChoice": false,
"functionCall": false,
"customCQPrompt": "",
"customExtractPrompt": "",
"defaultSystemChatPrompt": "",
"defaultConfig": {
"temperature": 1,
"max_tokens": null,
"stream": false
}
},
{
"model": "o1-preview",
"name": "o1-preview",
"avatar": "/imgs/model/openai.svg",
"maxContext": 125000,
"maxResponse": 4000,
"quoteMaxToken": 120000,
"maxTemperature": 1.2,
"charsPointsPrice": 0,
"censor": false,
"vision": false,
"datasetProcess": false,
"usedInClassify": true,
"usedInExtractFields": true,
"usedInToolCall": true,
"usedInQueryExtension": true,
"toolChoice": false,
"functionCall": false,
"customCQPrompt": "",
"customExtractPrompt": "",
"defaultSystemChatPrompt": "",
"defaultConfig": {
"temperature": 1,
"max_tokens": null,
"stream": false
}
}
```

-------

### 3. 修改镜像 tag 并重启



## V4.8.11 更新说明

1.
2. 新增 - 聊天记录滚动加载,不再只加载 30 条。
3. 新增 - 工作流增加触摸板优先模式。
4. 新增 - 沙盒增加字符串转 base64 全局方法。
5. 优化 - 工作流嵌套层级限制 20 层,避免因编排不合理导致的无限死循环。
5. 优化 - 工作流 handler 性能优化。
6. 优化 - 工作流快捷键,避免调试测试时也会触发。
7. 优化 - 流输出,切换 tab 时仍可以继续输出。
8. 修复 - 知识库选择权限问题。
9. 修复 - 空 chatId 发起对话,首轮携带用户选择时会异常。
5. 新增 - 支持 openai o1 模型,需增加模型的 `defaultConfig` 配置,覆盖 `temperature``max_tokens``stream`配置,o1 不支持 stream 模式, 详细可重新拉取 `config.json` 配置文件查看。
6. 优化 - 工作流嵌套层级限制 20 层,避免因编排不合理导致的无限死循环。
7. 优化 - 工作流 handler 性能优化。
8. 优化 - 工作流快捷键,避免调试测试时也会触发。
9. 优化 - 流输出,切换 tab 时仍可以继续输出。
10. 修复 - 知识库选择权限问题。
11. 修复 - 空 chatId 发起对话,首轮携带用户选择时会异常。
12. 修复 - createDataset 接口,intro 为赋值。
2 changes: 1 addition & 1 deletion packages/global/core/chat/adapt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ export const runtimePrompt2ChatsValue = (
return value;
};

export const getSystemPrompt = (prompt?: string): ChatItemType[] => {
export const getSystemPrompt_ChatItemType = (prompt?: string): ChatItemType[] => {
if (!prompt) return [];
return [
{
Expand Down
21 changes: 19 additions & 2 deletions packages/global/core/workflow/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export enum WorkflowIOValueTypeEnum {
arrayNumber = 'arrayNumber',
arrayBoolean = 'arrayBoolean',
arrayObject = 'arrayObject',
arrayAny = 'arrayAny',
any = 'any',

chatHistory = 'chatHistory',
Expand Down Expand Up @@ -135,7 +136,17 @@ export enum NodeInputKeyEnum {
fileUrlList = 'fileUrlList',

// user select
userSelectOptions = 'userSelectOptions'
userSelectOptions = 'userSelectOptions',

// loop
loopInputArray = 'loopInputArray',
childrenNodeIdList = 'childrenNodeIdList',
nodeWidth = 'nodeWidth',
nodeHeight = 'nodeHeight',
// loop start
loopStartInput = 'loopStartInput',
// loop end
loopEndInput = 'loopEndInput'
}

export enum NodeOutputKeyEnum {
Expand Down Expand Up @@ -178,7 +189,13 @@ export enum NodeOutputKeyEnum {
ifElseResult = 'ifElseResult',

//user select
selectResult = 'selectResult'
selectResult = 'selectResult',

// loop
loopArray = 'loopArray',

// loop start
loopStartInput = 'loopStartInput'
}

export enum VariableInputEnum {
Expand Down
9 changes: 8 additions & 1 deletion packages/global/core/workflow/node/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ export enum FlowNodeTypeEnum {
textEditor = 'textEditor',
customFeedback = 'customFeedback',
readFiles = 'readFiles',
userSelect = 'userSelect'
userSelect = 'userSelect',
loop = 'loop',
loopStart = 'loopStart',
loopEnd = 'loopEnd'
}

// node IO value type
Expand Down Expand Up @@ -162,6 +165,10 @@ export const FlowValueTypeMap = {
label: 'array<object>',
value: WorkflowIOValueTypeEnum.arrayObject
},
[WorkflowIOValueTypeEnum.arrayAny]: {
label: 'array',
value: WorkflowIOValueTypeEnum.arrayAny
},
[WorkflowIOValueTypeEnum.any]: {
label: 'any',
value: WorkflowIOValueTypeEnum.any
Expand Down
9 changes: 9 additions & 0 deletions packages/global/core/workflow/runtime/type.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,15 @@ export type DispatchNodeResponseType = {

// update var
updateVarResult?: any[];

// loop
loopResult?: any[];
loopInput?: any[];
loopDetail?: ChatHistoryItemResType[];
// loop start
loopInputValue?: any;
// loop end
loopOutputValue?: any;
};

export type DispatchNodeResultType<T = {}> = {
Expand Down
10 changes: 8 additions & 2 deletions packages/global/core/workflow/template/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ import { TextEditorNode } from './system/textEditor';
import { CustomFeedbackNode } from './system/customFeedback';
import { ReadFilesNodes } from './system/readFiles';
import { UserSelectNode } from './system/userSelect/index';
import { LoopNode } from './system/loop/loop';
import { LoopStartNode } from './system/loop/loopStart';
import { LoopEndNode } from './system/loop/loopEnd';

const systemNodes: FlowNodeTemplateType[] = [
AiChatModule,
Expand All @@ -46,7 +49,8 @@ const systemNodes: FlowNodeTemplateType[] = [
LafModule,
IfElseNode,
VariableUpdateNode,
CodeNode
CodeNode,
LoopNode
];
/* app flow module templates */
export const appSystemModuleTemplates: FlowNodeTemplateType[] = [
Expand Down Expand Up @@ -74,5 +78,7 @@ export const moduleTemplatesFlat: FlowNodeTemplateType[] = [
EmptyNode,
RunPluginModule,
RunAppNode,
RunAppModule
RunAppModule,
LoopStartNode,
LoopEndNode
];
22 changes: 22 additions & 0 deletions packages/global/core/workflow/template/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,25 @@ export const Input_Template_File_Link: FlowNodeInputItemType = {
description: i18nT('app:workflow.user_file_input_desc'),
valueType: WorkflowIOValueTypeEnum.arrayString
};

export const Input_Template_Children_Node_List: FlowNodeInputItemType = {
key: NodeInputKeyEnum.childrenNodeIdList,
renderTypeList: [FlowNodeInputTypeEnum.hidden],
valueType: WorkflowIOValueTypeEnum.arrayString,
label: '',
value: []
};
export const Input_Template_Node_Width: FlowNodeInputItemType = {
key: NodeInputKeyEnum.nodeWidth,
renderTypeList: [FlowNodeInputTypeEnum.hidden],
valueType: WorkflowIOValueTypeEnum.number,
label: '',
value: 900
};
export const Input_Template_Node_Height: FlowNodeInputItemType = {
key: NodeInputKeyEnum.nodeHeight,
renderTypeList: [FlowNodeInputTypeEnum.hidden],
valueType: WorkflowIOValueTypeEnum.number,
label: '',
value: 900
};
54 changes: 54 additions & 0 deletions packages/global/core/workflow/template/system/loop/loop.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import {
FlowNodeInputTypeEnum,
FlowNodeOutputTypeEnum,
FlowNodeTypeEnum
} from '../../../node/constant';
import { FlowNodeTemplateType } from '../../../type/node';
import {
FlowNodeTemplateTypeEnum,
NodeInputKeyEnum,
NodeOutputKeyEnum,
WorkflowIOValueTypeEnum
} from '../../../constants';
import { getHandleConfig } from '../../utils';
import { i18nT } from '../../../../../../web/i18n/utils';
import {
Input_Template_Children_Node_List,
Input_Template_Node_Height,
Input_Template_Node_Width
} from '../../input';

export const LoopNode: FlowNodeTemplateType = {
id: FlowNodeTypeEnum.loop,
templateType: FlowNodeTemplateTypeEnum.tools,
flowNodeType: FlowNodeTypeEnum.loop,
sourceHandle: getHandleConfig(true, true, true, true),
targetHandle: getHandleConfig(true, true, true, true),
avatar: 'core/workflow/template/loop',
name: i18nT('workflow:loop'),
intro: i18nT('workflow:intro_loop'),
showStatus: true,
version: '4811',
inputs: [
{
key: NodeInputKeyEnum.loopInputArray,
renderTypeList: [FlowNodeInputTypeEnum.reference],
valueType: WorkflowIOValueTypeEnum.arrayAny,
required: true,
label: i18nT('workflow:loop_input_array'),
value: []
},
Input_Template_Children_Node_List,
Input_Template_Node_Width,
Input_Template_Node_Height
],
outputs: [
{
id: NodeOutputKeyEnum.loopArray,
key: NodeOutputKeyEnum.loopArray,
label: i18nT('workflow:loop_result'),
type: FlowNodeOutputTypeEnum.static,
valueType: WorkflowIOValueTypeEnum.arrayAny
}
]
};
34 changes: 34 additions & 0 deletions packages/global/core/workflow/template/system/loop/loopEnd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { i18nT } from '../../../../../../web/i18n/utils';
import {
FlowNodeTemplateTypeEnum,
NodeInputKeyEnum,
WorkflowIOValueTypeEnum
} from '../../../constants';
import { FlowNodeInputTypeEnum, FlowNodeTypeEnum } from '../../../node/constant';
import { FlowNodeTemplateType } from '../../../type/node';
import { getHandleConfig } from '../../utils';

export const LoopEndNode: FlowNodeTemplateType = {
id: FlowNodeTypeEnum.loopEnd,
templateType: FlowNodeTemplateTypeEnum.systemInput,
flowNodeType: FlowNodeTypeEnum.loopEnd,
sourceHandle: getHandleConfig(false, false, false, false),
targetHandle: getHandleConfig(false, false, false, true),
unique: true,
forbidDelete: true,
avatar: 'core/workflow/template/loopEnd',
name: i18nT('workflow:loop_end'),
showStatus: false,
version: '4811',
inputs: [
{
key: NodeInputKeyEnum.loopEndInput,
renderTypeList: [FlowNodeInputTypeEnum.reference],
valueType: WorkflowIOValueTypeEnum.any,
label: '',
required: true,
value: []
}
],
outputs: []
};
34 changes: 34 additions & 0 deletions packages/global/core/workflow/template/system/loop/loopStart.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { FlowNodeInputTypeEnum, FlowNodeTypeEnum } from '../../../node/constant';
import { FlowNodeTemplateType } from '../../../type/node.d';
import {
FlowNodeTemplateTypeEnum,
NodeInputKeyEnum,
WorkflowIOValueTypeEnum
} from '../../../constants';
import { getHandleConfig } from '../../utils';
import { i18nT } from '../../../../../../web/i18n/utils';

export const LoopStartNode: FlowNodeTemplateType = {
id: FlowNodeTypeEnum.loopStart,
templateType: FlowNodeTemplateTypeEnum.systemInput,
flowNodeType: FlowNodeTypeEnum.loopStart,
sourceHandle: getHandleConfig(false, true, false, false),
targetHandle: getHandleConfig(false, false, false, false),
avatar: 'core/workflow/template/loopStart',
name: i18nT('workflow:loop_start'),
unique: true,
forbidDelete: true,
showStatus: false,
version: '4811',
inputs: [
{
key: NodeInputKeyEnum.loopStartInput,
renderTypeList: [FlowNodeInputTypeEnum.hidden],
valueType: WorkflowIOValueTypeEnum.any,
label: '',
required: true,
value: ''
}
],
outputs: []
};
1 change: 1 addition & 0 deletions packages/global/core/workflow/type/node.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export type NodeTemplateListType = {
// react flow node type
export type FlowNodeItemType = FlowNodeTemplateType & {
nodeId: string;
parentNodeId?: string;
isError?: boolean;
debugResult?: {
status: 'running' | 'success' | 'skipped' | 'failed';
Expand Down
2 changes: 1 addition & 1 deletion packages/global/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"jschardet": "3.1.1",
"nanoid": "^4.0.1",
"next": "14.2.5",
"openai": "4.57.0",
"openai": "4.61.0",
"openapi-types": "^12.1.3",
"timezones-list": "^3.0.2"
},
Expand Down
Loading

0 comments on commit 2bdda46

Please sign in to comment.