FEAT: NEW WORKFLOW ENGINE (#3160)

Co-authored-by: Joel <iamjoel007@gmail.com>
Co-authored-by: Yeuoly <admin@srmxy.cn>
Co-authored-by: JzoNg <jzongcode@gmail.com>
Co-authored-by: StyleZhang <jasonapring2015@outlook.com>
Co-authored-by: jyong <jyong@dify.ai>
Co-authored-by: nite-knite <nkCoding@gmail.com>
Co-authored-by: jyong <718720800@qq.com>
This commit is contained in:
takatost
2024-04-08 18:51:46 +08:00
committed by GitHub
parent 2fb9850af5
commit 7753ba2d37
1161 changed files with 103836 additions and 10327 deletions

View File

@@ -44,7 +44,7 @@ export type VariableInput = {
/**
* App modes
*/
export const AppModes = ['completion', 'chat'] as const
export const AppModes = ['advanced-chat', 'agent-chat', 'chat', 'completion', 'workflow'] as const
export type AppMode = typeof AppModes[number]
/**
@@ -228,6 +228,7 @@ export type ModelConfig = {
image: VisionSettings
}
files?: VisionFile[]
created_at?: number
}
export type Language = typeof LanguagesSupported[number]
@@ -278,6 +279,8 @@ export type App = {
id: string
/** Name */
name: string
/** Description */
description: string
/** Icon */
icon: string
@@ -286,7 +289,6 @@ export type App = {
/** Mode */
mode: AppMode
is_agent: boolean
/** Enable web app */
enable_site: boolean
/** Enable web API */

184
web/types/workflow.ts Normal file
View File

@@ -0,0 +1,184 @@
import type { Viewport } from 'reactflow'
import type {
BlockEnum,
Edge,
Node,
} from '@/app/components/workflow/types'
export type NodeTracing = {
id: string
index: number
predecessor_node_id: string
node_id: string
node_type: BlockEnum
title: string
inputs: any
process_data: any
outputs?: any
status: string
error?: string
elapsed_time: number
execution_metadata: {
total_tokens: number
total_price: number
currency: string
}
created_at: number
created_by: {
id: string
name: string
email: string
}
finished_at: number
extras?: any
expand?: boolean // for UI
}
export type FetchWorkflowDraftResponse = {
id: string
graph: {
nodes: Node[]
edges: Edge[]
viewport?: Viewport
}
features?: any
created_at: number
created_by: {
id: string
name: string
email: string
}
updated_at: number
}
export type NodeTracingListResponse = {
data: NodeTracing[]
}
export type WorkflowStartedResponse = {
task_id: string
workflow_run_id: string
event: string
data: {
id: string
workflow_id: string
sequence_number: number
created_at: number
}
}
export type WorkflowFinishedResponse = {
task_id: string
workflow_run_id: string
event: string
data: {
id: string
workflow_id: string
status: string
outputs: any
error: string
elapsed_time: number
total_tokens: number
total_steps: number
created_at: number
finished_at: number
}
}
export type NodeStartedResponse = {
task_id: string
workflow_run_id: string
event: string
data: {
id: string
node_id: string
node_type: string
index: number
predecessor_node_id?: string
inputs: any
created_at: number
extras?: any
}
}
export type NodeFinishedResponse = {
task_id: string
workflow_run_id: string
event: string
data: {
id: string
node_id: string
node_type: string
index: number
predecessor_node_id?: string
inputs: any
process_data: any
outputs: any
status: string
error: string
elapsed_time: number
execution_metadata: {
total_tokens: number
total_price: number
currency: string
}
created_at: number
}
}
export type TextChunkResponse = {
task_id: string
workflow_run_id: string
event: string
data: {
text: string
}
}
export type TextReplaceResponse = {
task_id: string
workflow_run_id: string
event: string
data: {
text: string
}
}
export type WorkflowRunHistory = {
id: string
sequence_number: number
version: string
conversation_id?: string
message_id?: string
graph: {
nodes: Node[]
edges: Edge[]
viewport?: Viewport
}
inputs: Record<string, string>
status: string
outputs: Record<string, any>
error?: string
elapsed_time: number
total_tokens: number
total_steps: number
created_at: number
finished_at: number
created_by_account: {
id: string
name: string
email: string
}
}
export type WorkflowRunHistoryResponse = {
data: WorkflowRunHistory[]
}
export type ChatRunHistoryResponse = {
data: WorkflowRunHistory[]
}
export type NodesDefaultConfigsResponse = {
type: string
config: any
}[]