style(workflow): normalize line endings and formatting in types file

pull/21667/head
Mminamiyama 11 months ago
parent d10aa05955
commit c72196095c

@ -1,444 +1,444 @@
import type { import type {
Edge as ReactFlowEdge, Edge as ReactFlowEdge,
Node as ReactFlowNode, Node as ReactFlowNode,
Viewport, Viewport,
XYPosition, XYPosition,
} from 'reactflow' } from 'reactflow'
import type { Resolution, TransferMethod } from '@/types/app' import type { Resolution, TransferMethod } from '@/types/app'
import type { ToolDefaultValue } from '@/app/components/workflow/block-selector/types' import type { ToolDefaultValue } from '@/app/components/workflow/block-selector/types'
import type { VarType as VarKindType } from '@/app/components/workflow/nodes/tool/types' import type { VarType as VarKindType } from '@/app/components/workflow/nodes/tool/types'
import type { FileResponse, NodeTracing, PanelProps } from '@/types/workflow' import type { FileResponse, NodeTracing, PanelProps } from '@/types/workflow'
import type { Collection, Tool } from '@/app/components/tools/types' import type { Collection, Tool } from '@/app/components/tools/types'
import type { ChatVarType } from '@/app/components/workflow/panel/chat-variable-panel/type' import type { ChatVarType } from '@/app/components/workflow/panel/chat-variable-panel/type'
import type { import type {
DefaultValueForm, DefaultValueForm,
ErrorHandleTypeEnum, ErrorHandleTypeEnum,
} from '@/app/components/workflow/nodes/_base/components/error-handle/types' } from '@/app/components/workflow/nodes/_base/components/error-handle/types'
import type { WorkflowRetryConfig } from '@/app/components/workflow/nodes/_base/components/retry/types' import type { WorkflowRetryConfig } from '@/app/components/workflow/nodes/_base/components/retry/types'
import type { StructuredOutput } from '@/app/components/workflow/nodes/llm/types' import type { StructuredOutput } from '@/app/components/workflow/nodes/llm/types'
export enum BlockEnum { export enum BlockEnum {
Start = 'start', Start = 'start',
End = 'end', End = 'end',
Answer = 'answer', Answer = 'answer',
LLM = 'llm', LLM = 'llm',
KnowledgeRetrieval = 'knowledge-retrieval', KnowledgeRetrieval = 'knowledge-retrieval',
QuestionClassifier = 'question-classifier', QuestionClassifier = 'question-classifier',
IfElse = 'if-else', IfElse = 'if-else',
Code = 'code', Code = 'code',
TemplateTransform = 'template-transform', TemplateTransform = 'template-transform',
HttpRequest = 'http-request', HttpRequest = 'http-request',
VariableAssigner = 'variable-assigner', VariableAssigner = 'variable-assigner',
VariableAggregator = 'variable-aggregator', VariableAggregator = 'variable-aggregator',
Tool = 'tool', Tool = 'tool',
ParameterExtractor = 'parameter-extractor', ParameterExtractor = 'parameter-extractor',
Iteration = 'iteration', Iteration = 'iteration',
DocExtractor = 'document-extractor', DocExtractor = 'document-extractor',
ListFilter = 'list-operator', ListFilter = 'list-operator',
IterationStart = 'iteration-start', IterationStart = 'iteration-start',
Assigner = 'assigner', // is now named as VariableAssigner Assigner = 'assigner', // is now named as VariableAssigner
Agent = 'agent', Agent = 'agent',
Loop = 'loop', Loop = 'loop',
LoopStart = 'loop-start', LoopStart = 'loop-start',
LoopEnd = 'loop-end', LoopEnd = 'loop-end',
} }
export enum ControlMode { export enum ControlMode {
Pointer = 'pointer', Pointer = 'pointer',
Hand = 'hand', Hand = 'hand',
} }
export enum ErrorHandleMode { export enum ErrorHandleMode {
Terminated = 'terminated', Terminated = 'terminated',
ContinueOnError = 'continue-on-error', ContinueOnError = 'continue-on-error',
RemoveAbnormalOutput = 'remove-abnormal-output', RemoveAbnormalOutput = 'remove-abnormal-output',
} }
export type Branch = { export type Branch = {
id: string id: string
name: string name: string
} }
export type CommonNodeType<T = {}> = { export type CommonNodeType<T = {}> = {
_connectedSourceHandleIds?: string[] _connectedSourceHandleIds?: string[]
_connectedTargetHandleIds?: string[] _connectedTargetHandleIds?: string[]
_targetBranches?: Branch[] _targetBranches?: Branch[]
_isSingleRun?: boolean _isSingleRun?: boolean
_runningStatus?: NodeRunningStatus _runningStatus?: NodeRunningStatus
_runningBranchId?: string _runningBranchId?: string
_singleRunningStatus?: NodeRunningStatus _singleRunningStatus?: NodeRunningStatus
_isCandidate?: boolean _isCandidate?: boolean
_isBundled?: boolean _isBundled?: boolean
_children?: { nodeId: string; nodeType: BlockEnum }[] _children?: { nodeId: string; nodeType: BlockEnum }[]
_isEntering?: boolean _isEntering?: boolean
_showAddVariablePopup?: boolean _showAddVariablePopup?: boolean
_holdAddVariablePopup?: boolean _holdAddVariablePopup?: boolean
_iterationLength?: number _iterationLength?: number
_iterationIndex?: number _iterationIndex?: number
_inParallelHovering?: boolean _inParallelHovering?: boolean
_waitingRun?: boolean _waitingRun?: boolean
_retryIndex?: number _retryIndex?: number
isInIteration?: boolean isInIteration?: boolean
iteration_id?: string iteration_id?: string
selected?: boolean selected?: boolean
title: string title: string
desc: string desc: string
type: BlockEnum type: BlockEnum
width?: number width?: number
height?: number height?: number
position?: XYPosition position?: XYPosition
_loopLength?: number _loopLength?: number
_loopIndex?: number _loopIndex?: number
isInLoop?: boolean isInLoop?: boolean
loop_id?: string loop_id?: string
error_strategy?: ErrorHandleTypeEnum error_strategy?: ErrorHandleTypeEnum
retry_config?: WorkflowRetryConfig retry_config?: WorkflowRetryConfig
default_value?: DefaultValueForm[] default_value?: DefaultValueForm[]
} & T & Partial<Pick<ToolDefaultValue, 'provider_id' | 'provider_type' | 'provider_name' | 'tool_name'>> } & T & Partial<Pick<ToolDefaultValue, 'provider_id' | 'provider_type' | 'provider_name' | 'tool_name'>>
export type CommonEdgeType = { export type CommonEdgeType = {
_hovering?: boolean _hovering?: boolean
_connectedNodeIsHovering?: boolean _connectedNodeIsHovering?: boolean
_connectedNodeIsSelected?: boolean _connectedNodeIsSelected?: boolean
_isBundled?: boolean _isBundled?: boolean
_sourceRunningStatus?: NodeRunningStatus _sourceRunningStatus?: NodeRunningStatus
_targetRunningStatus?: NodeRunningStatus _targetRunningStatus?: NodeRunningStatus
_waitingRun?: boolean _waitingRun?: boolean
isInIteration?: boolean isInIteration?: boolean
iteration_id?: string iteration_id?: string
isInLoop?: boolean isInLoop?: boolean
loop_id?: string loop_id?: string
sourceType: BlockEnum sourceType: BlockEnum
targetType: BlockEnum targetType: BlockEnum
} }
export type Node<T = {}> = ReactFlowNode<CommonNodeType<T>> export type Node<T = {}> = ReactFlowNode<CommonNodeType<T>>
export type SelectedNode = Pick<Node, 'id' | 'data'> export type SelectedNode = Pick<Node, 'id' | 'data'>
export type NodeProps<T = unknown> = { id: string; data: CommonNodeType<T> } export type NodeProps<T = unknown> = { id: string; data: CommonNodeType<T> }
export type NodePanelProps<T> = { export type NodePanelProps<T> = {
id: string id: string
data: CommonNodeType<T> data: CommonNodeType<T>
panelProps: PanelProps panelProps: PanelProps
} }
export type Edge = ReactFlowEdge<CommonEdgeType> export type Edge = ReactFlowEdge<CommonEdgeType>
export type WorkflowDataUpdater = { export type WorkflowDataUpdater = {
nodes: Node[] nodes: Node[]
edges: Edge[] edges: Edge[]
viewport: Viewport viewport: Viewport
} }
export type ValueSelector = string[] // [nodeId, key | obj key path] export type ValueSelector = string[] // [nodeId, key | obj key path]
export type Variable = { export type Variable = {
variable: string variable: string
label?: string | { label?: string | {
nodeType: BlockEnum nodeType: BlockEnum
nodeName: string nodeName: string
variable: string variable: string
} }
value_selector: ValueSelector value_selector: ValueSelector
value_type?: VarType value_type?: VarType
variable_type?: VarKindType variable_type?: VarKindType
value?: string value?: string
options?: string[] options?: string[]
required?: boolean required?: boolean
isParagraph?: boolean isParagraph?: boolean
} }
export type EnvironmentVariable = { export type EnvironmentVariable = {
id: string id: string
name: string name: string
value: any value: any
value_type: 'string' | 'number' | 'secret' value_type: 'string' | 'number' | 'secret'
} }
export type ConversationVariable = { export type ConversationVariable = {
id: string id: string
name: string name: string
value_type: ChatVarType value_type: ChatVarType
value: any value: any
description: string description: string
} }
export type GlobalVariable = { export type GlobalVariable = {
name: string name: string
value_type: 'string' | 'number' value_type: 'string' | 'number'
description: string description: string
} }
export type VariableWithValue = { export type VariableWithValue = {
key: string key: string
value: string value: string
} }
export enum InputVarType { export enum InputVarType {
textInput = 'text-input', textInput = 'text-input',
paragraph = 'paragraph', paragraph = 'paragraph',
select = 'select', select = 'select',
number = 'number', number = 'number',
url = 'url', url = 'url',
files = 'files', files = 'files',
json = 'json', // obj, array json = 'json', // obj, array
contexts = 'contexts', // knowledge retrieval contexts = 'contexts', // knowledge retrieval
iterator = 'iterator', // iteration input iterator = 'iterator', // iteration input
singleFile = 'file', singleFile = 'file',
multiFiles = 'file-list', multiFiles = 'file-list',
loop = 'loop', // loop input loop = 'loop', // loop input
} }
export type InputVar = { export type InputVar = {
type: InputVarType type: InputVarType
label: string | { label: string | {
nodeType: BlockEnum nodeType: BlockEnum
nodeName: string nodeName: string
variable: string variable: string
isChatVar?: boolean isChatVar?: boolean
} }
variable: string variable: string
max_length?: number max_length?: number
default?: string default?: string
required: boolean required: boolean
hint?: string hint?: string
options?: string[] options?: string[]
value_selector?: ValueSelector value_selector?: ValueSelector
getVarValueFromDependent?: boolean getVarValueFromDependent?: boolean
hide?: boolean hide?: boolean
isFileItem?: boolean isFileItem?: boolean
} & Partial<UploadFileSetting> } & Partial<UploadFileSetting>
export type ModelConfig = { export type ModelConfig = {
provider: string provider: string
name: string name: string
mode: string mode: string
completion_params: Record<string, any> completion_params: Record<string, any>
} }
export enum PromptRole { export enum PromptRole {
system = 'system', system = 'system',
user = 'user', user = 'user',
assistant = 'assistant', assistant = 'assistant',
} }
export enum EditionType { export enum EditionType {
basic = 'basic', basic = 'basic',
jinja2 = 'jinja2', jinja2 = 'jinja2',
} }
export type PromptItem = { export type PromptItem = {
id?: string id?: string
role?: PromptRole role?: PromptRole
text: string text: string
edition_type?: EditionType edition_type?: EditionType
jinja2_text?: string jinja2_text?: string
} }
export enum MemoryRole { export enum MemoryRole {
user = 'user', user = 'user',
assistant = 'assistant', assistant = 'assistant',
} }
export type RolePrefix = { export type RolePrefix = {
user: string user: string
assistant: string assistant: string
} }
export type Memory = { export type Memory = {
role_prefix?: RolePrefix role_prefix?: RolePrefix
window: { window: {
enabled: boolean enabled: boolean
size: number | string | null size: number | string | null
} }
query_prompt_template: string query_prompt_template: string
} }
export enum VarType { export enum VarType {
string = 'string', string = 'string',
number = 'number', number = 'number',
secret = 'secret', secret = 'secret',
boolean = 'boolean', boolean = 'boolean',
object = 'object', object = 'object',
file = 'file', file = 'file',
array = 'array', array = 'array',
arrayString = 'array[string]', arrayString = 'array[string]',
arrayNumber = 'array[number]', arrayNumber = 'array[number]',
arrayObject = 'array[object]', arrayObject = 'array[object]',
arrayFile = 'array[file]', arrayFile = 'array[file]',
any = 'any', any = 'any',
arrayAny = 'array[any]', arrayAny = 'array[any]',
} }
export enum ValueType { export enum ValueType {
variable = 'variable', variable = 'variable',
constant = 'constant', constant = 'constant',
} }
export type Var = { export type Var = {
variable: string variable: string
type: VarType type: VarType
children?: Var[] | StructuredOutput // if type is obj, has the children struct children?: Var[] | StructuredOutput // if type is obj, has the children struct
isParagraph?: boolean isParagraph?: boolean
isSelect?: boolean isSelect?: boolean
options?: string[] options?: string[]
required?: boolean required?: boolean
des?: string des?: string
isException?: boolean isException?: boolean
isLoopVariable?: boolean isLoopVariable?: boolean
nodeId?: string nodeId?: string
} }
export type NodeOutPutVar = { export type NodeOutPutVar = {
nodeId: string nodeId: string
title: string title: string
vars: Var[] vars: Var[]
isStartNode?: boolean isStartNode?: boolean
isLoop?: boolean isLoop?: boolean
} }
export type Block = { export type Block = {
classification?: string classification?: string
type: BlockEnum type: BlockEnum
title: string title: string
description?: string description?: string
} }
export type NodeDefault<T> = { export type NodeDefault<T> = {
defaultValue: Partial<T> defaultValue: Partial<T>
defaultRunInputData?: Record<string, any> defaultRunInputData?: Record<string, any>
getAvailablePrevNodes: (isChatMode: boolean) => BlockEnum[] getAvailablePrevNodes: (isChatMode: boolean) => BlockEnum[]
getAvailableNextNodes: (isChatMode: boolean) => BlockEnum[] getAvailableNextNodes: (isChatMode: boolean) => BlockEnum[]
checkValid: (payload: T, t: any, moreDataForCheckValid?: any) => { isValid: boolean; errorMessage?: string } checkValid: (payload: T, t: any, moreDataForCheckValid?: any) => { isValid: boolean; errorMessage?: string }
} }
export type OnSelectBlock = (type: BlockEnum, toolDefaultValue?: ToolDefaultValue) => void export type OnSelectBlock = (type: BlockEnum, toolDefaultValue?: ToolDefaultValue) => void
export enum WorkflowRunningStatus { export enum WorkflowRunningStatus {
Waiting = 'waiting', Waiting = 'waiting',
Running = 'running', Running = 'running',
Succeeded = 'succeeded', Succeeded = 'succeeded',
Failed = 'failed', Failed = 'failed',
Stopped = 'stopped', Stopped = 'stopped',
} }
export enum WorkflowVersion { export enum WorkflowVersion {
Draft = 'draft', Draft = 'draft',
Latest = 'latest', Latest = 'latest',
} }
export enum NodeRunningStatus { export enum NodeRunningStatus {
NotStart = 'not-start', NotStart = 'not-start',
Waiting = 'waiting', Waiting = 'waiting',
Running = 'running', Running = 'running',
Succeeded = 'succeeded', Succeeded = 'succeeded',
Failed = 'failed', Failed = 'failed',
Exception = 'exception', Exception = 'exception',
Retry = 'retry', Retry = 'retry',
Stopped = 'stopped', Stopped = 'stopped',
} }
export type OnNodeAdd = ( export type OnNodeAdd = (
newNodePayload: { newNodePayload: {
nodeType: BlockEnum nodeType: BlockEnum
sourceHandle?: string sourceHandle?: string
targetHandle?: string targetHandle?: string
toolDefaultValue?: ToolDefaultValue toolDefaultValue?: ToolDefaultValue
}, },
oldNodesPayload: { oldNodesPayload: {
prevNodeId?: string prevNodeId?: string
prevNodeSourceHandle?: string prevNodeSourceHandle?: string
nextNodeId?: string nextNodeId?: string
nextNodeTargetHandle?: string nextNodeTargetHandle?: string
} }
) => void ) => void
export type CheckValidRes = { export type CheckValidRes = {
isValid: boolean isValid: boolean
errorMessage?: string errorMessage?: string
} }
export type RunFile = { export type RunFile = {
type: string type: string
transfer_method: TransferMethod[] transfer_method: TransferMethod[]
url?: string url?: string
upload_file_id?: string upload_file_id?: string
related_id?: string related_id?: string
} }
export type WorkflowRunningData = { export type WorkflowRunningData = {
task_id?: string task_id?: string
message_id?: string message_id?: string
conversation_id?: string conversation_id?: string
result: { result: {
workflow_id?: string workflow_id?: string
inputs?: string inputs?: string
process_data?: string process_data?: string
outputs?: string outputs?: string
status: string status: string
error?: string error?: string
elapsed_time?: number elapsed_time?: number
total_tokens?: number total_tokens?: number
created_at?: number created_at?: number
created_by?: string created_by?: string
finished_at?: number finished_at?: number
steps?: number steps?: number
showSteps?: boolean showSteps?: boolean
total_steps?: number total_steps?: number
files?: FileResponse[] files?: FileResponse[]
exceptions_count?: number exceptions_count?: number
} }
tracing?: NodeTracing[] tracing?: NodeTracing[]
} }
export type HistoryWorkflowData = { export type HistoryWorkflowData = {
id: string id: string
status: string status: string
conversation_id?: string conversation_id?: string
finished_at?: number finished_at?: number
} }
export enum ChangeType { export enum ChangeType {
changeVarName = 'changeVarName', changeVarName = 'changeVarName',
remove = 'remove', remove = 'remove',
} }
export type MoreInfo = { export type MoreInfo = {
type: ChangeType type: ChangeType
payload?: { payload?: {
beforeKey: string beforeKey: string
afterKey?: string afterKey?: string
} }
} }
export type ToolWithProvider = Collection & { export type ToolWithProvider = Collection & {
tools: Tool[] tools: Tool[]
} }
export enum SupportUploadFileTypes { export enum SupportUploadFileTypes {
image = 'image', image = 'image',
document = 'document', document = 'document',
audio = 'audio', audio = 'audio',
video = 'video', video = 'video',
custom = 'custom', custom = 'custom',
} }
export type UploadFileSetting = { export type UploadFileSetting = {
allowed_file_upload_methods: TransferMethod[] allowed_file_upload_methods: TransferMethod[]
allowed_file_types: SupportUploadFileTypes[] allowed_file_types: SupportUploadFileTypes[]
allowed_file_extensions?: string[] allowed_file_extensions?: string[]
max_length: number max_length: number
number_limits?: number number_limits?: number
} }
export type VisionSetting = { export type VisionSetting = {
variable_selector: ValueSelector variable_selector: ValueSelector
detail: Resolution detail: Resolution
} }
export enum WorkflowVersionFilterOptions { export enum WorkflowVersionFilterOptions {
all = 'all', all = 'all',
onlyYours = 'onlyYours', onlyYours = 'onlyYours',
} }
export enum VersionHistoryContextMenuOptions { export enum VersionHistoryContextMenuOptions {
restore = 'restore', restore = 'restore',
edit = 'edit', edit = 'edit',
delete = 'delete', delete = 'delete',
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save