Updated block config structure

This commit is contained in:
Emir Karabeg
2025-01-16 11:28:49 -08:00
parent 7189259488
commit 9ded8a1720
5 changed files with 36 additions and 35 deletions

View File

@@ -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,

View File

@@ -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'
}
]
}
}

View File

@@ -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: [
{

View File

@@ -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: [
{

View File

@@ -4,21 +4,35 @@ import type { JSX } from 'react'
export type BlockType = 'agent' | 'api' | 'conditional'
export type BlockIcon = (props: SVGProps<SVGSVGElement>) => 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<string, string>
outputs: Record<string, string>
outputType: OutputTypeConfig
subBlocks: SubBlockConfig[]
}
}