diff --git a/app/w/[id]/workflow.tsx b/app/w/[id]/workflow.tsx index 93372bb593..4c2c17465e 100644 --- a/app/w/[id]/workflow.tsx +++ b/app/w/[id]/workflow.tsx @@ -1,18 +1,15 @@ 'use client' -import { useState, useCallback } from 'react' +import { useCallback } from 'react' import ReactFlow, { Background, - Controls, NodeProps, NodeTypes, EdgeTypes, Connection, - Edge, addEdge, useNodesState, useEdgesState, - XYPosition, useReactFlow, ReactFlowProvider, ConnectionLineType, diff --git a/blocks/configs/agent.ts b/blocks/configs/agent.ts index ce7dcada4a..da1c84dad4 100644 --- a/blocks/configs/agent.ts +++ b/blocks/configs/agent.ts @@ -11,20 +11,22 @@ export const AgentBlock: BlockConfig = { category: 'basic', }, workflow: { - inputs: { - prompt: 'string', - context: 'string', - }, - outputs: { - response: 'string', - tokens: 'number', + outputType: { + default: 'string', + dependsOn: { + subBlockId: 'responseFormat', + condition: { + whenEmpty: 'string', + whenFilled: 'json' + } + } }, subBlocks: [ { title: 'System Prompt', type: 'long-input', layout: 'full', - placeholder: 'Enter prompt', + placeholder: 'Enter prompt' }, { title: 'Context', @@ -53,10 +55,11 @@ export const AgentBlock: BlockConfig = { password: true }, { + id: 'responseFormat', title: 'Response Format', type: 'code', - layout: 'full', - }, - ], - }, + layout: 'full' + } + ] + } } \ No newline at end of file diff --git a/blocks/configs/api.ts b/blocks/configs/api.ts index 16a74e4989..fe90658c34 100644 --- a/blocks/configs/api.ts +++ b/blocks/configs/api.ts @@ -11,15 +11,8 @@ export const ApiBlock: BlockConfig = { category: 'basic', }, workflow: { - inputs: { - url: 'string', - method: 'string', - headers: 'object', - body: 'string', - }, - outputs: { - response: 'string', - statusCode: 'number', + outputType: { + default: 'json' }, subBlocks: [ { diff --git a/blocks/configs/conditional.ts b/blocks/configs/conditional.ts index 359a219abf..8a2e6be6dc 100644 --- a/blocks/configs/conditional.ts +++ b/blocks/configs/conditional.ts @@ -11,13 +11,8 @@ export const ConditionalBlock: BlockConfig = { category: 'basic', }, workflow: { - inputs: { - condition: 'boolean', - value: 'any', - }, - outputs: { - result: 'any', - path: 'string', + outputType: { + default: 'boolean' }, subBlocks: [ { diff --git a/blocks/types/block.ts b/blocks/types/block.ts index 76911b5872..66039a1d12 100644 --- a/blocks/types/block.ts +++ b/blocks/types/block.ts @@ -4,21 +4,35 @@ import type { JSX } from 'react' export type BlockType = 'agent' | 'api' | 'conditional' export type BlockIcon = (props: SVGProps) => JSX.Element export type BlockCategory = 'basic' | 'advanced' +export type OutputType = 'string' | 'number' | 'json' | 'boolean' + export type SubBlockType = 'short-input' | 'long-input' | 'dropdown' | 'slider' | 'table' | 'code' export type SubBlockLayout = 'full' | 'half' export interface SubBlockConfig { + id?: string title: string type: SubBlockType + layout?: SubBlockLayout options?: string[] min?: number max?: number - layout?: SubBlockLayout columns?: string[] placeholder?: string password?: boolean } +export interface OutputTypeConfig { + default: OutputType + dependsOn?: { + subBlockId: string + condition: { + whenEmpty: OutputType + whenFilled: OutputType + } + } +} + export interface BlockConfig { type: BlockType toolbar: { @@ -29,8 +43,7 @@ export interface BlockConfig { category: BlockCategory } workflow: { - inputs: Record - outputs: Record + outputType: OutputTypeConfig subBlocks: SubBlockConfig[] } } \ No newline at end of file