From 5dc45509c1ed82fb89aac7922f68292d837fad1d Mon Sep 17 00:00:00 2001 From: Emir Karabeg Date: Thu, 13 Feb 2025 17:59:03 -0800 Subject: [PATCH] Added memory block --- blocks/blocks/evaluator.ts | 2 +- blocks/blocks/function.ts | 2 +- blocks/blocks/memory.ts | 39 +++++++++++++++++++++++++++++++++++ blocks/blocks/router.ts | 2 +- blocks/index.ts | 14 +++---------- components/icons.tsx | 42 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 87 insertions(+), 14 deletions(-) create mode 100644 blocks/blocks/memory.ts diff --git a/blocks/blocks/evaluator.ts b/blocks/blocks/evaluator.ts index cf7baee742..b97f7c20ca 100644 --- a/blocks/blocks/evaluator.ts +++ b/blocks/blocks/evaluator.ts @@ -59,7 +59,7 @@ export const EvaluatorBlock: BlockConfig = { type: 'evaluator', toolbar: { title: 'Evaluator', - description: 'Add an evaluator', + description: 'Evaluate content', bgColor: '#2FA1FF', icon: ChartBarIcon, category: 'blocks', diff --git a/blocks/blocks/function.ts b/blocks/blocks/function.ts index 2170ed2bc2..5f8bb987ae 100644 --- a/blocks/blocks/function.ts +++ b/blocks/blocks/function.ts @@ -6,7 +6,7 @@ export const FunctionBlock: BlockConfig = { type: 'function', toolbar: { title: 'Function', - description: 'Add custom logic', + description: 'Run custom logic', bgColor: '#FF402F', icon: CodeIcon, category: 'blocks', diff --git a/blocks/blocks/memory.ts b/blocks/blocks/memory.ts new file mode 100644 index 0000000000..6e6618ca4c --- /dev/null +++ b/blocks/blocks/memory.ts @@ -0,0 +1,39 @@ +import { BrainIcon } from '@/components/icons' +import { BlockConfig } from '../types' + +export const MemoryBlock: BlockConfig = { + type: 'memory', + toolbar: { + title: 'Memory', + description: 'Add memory store', + bgColor: '#FF65BF', + icon: BrainIcon, + category: 'blocks', + }, + tools: { + access: [], + }, + workflow: { + inputs: { + code: { type: 'string', required: true }, + timeout: { type: 'number', required: false }, + memoryLimit: { type: 'number', required: false }, + }, + outputs: { + response: { + type: { + result: 'any', + stdout: 'string', + executionTime: 'number', + }, + }, + }, + subBlocks: [ + { + id: 'code', + type: 'code', + layout: 'full', + }, + ], + }, +} diff --git a/blocks/blocks/router.ts b/blocks/blocks/router.ts index b4e6efdddb..387e96ced3 100644 --- a/blocks/blocks/router.ts +++ b/blocks/blocks/router.ts @@ -89,7 +89,7 @@ export const RouterBlock: BlockConfig = { type: 'router', toolbar: { title: 'Router', - description: 'Add a router', + description: 'Route workflow', bgColor: '#28C43F', icon: ConnectIcon, category: 'blocks', diff --git a/blocks/index.ts b/blocks/index.ts index 0310d4fac0..791ab0e4fd 100644 --- a/blocks/index.ts +++ b/blocks/index.ts @@ -9,6 +9,7 @@ import { FunctionBlock } from './blocks/function' import { GitHubBlock } from './blocks/github' import { GmailBlock } from './blocks/gmail' import { JinaBlock } from './blocks/jina' +import { MemoryBlock } from './blocks/memory' import { NotionBlock } from './blocks/notion' import { RouterBlock } from './blocks/router' import { SerperBlock } from './blocks/serper' @@ -39,6 +40,7 @@ export { NotionBlock, GmailBlock, XBlock, + MemoryBlock, } // Registry of all block configurations @@ -49,6 +51,7 @@ const blocks: Record = { function: FunctionBlock, router: RouterBlock, evaluator: EvaluatorBlock, + memory: MemoryBlock, crewai_vision: CrewAIVisionBlock, firecrawl_scrape: FirecrawlScrapeBlock, jina_reader: JinaBlock, @@ -63,17 +66,6 @@ const blocks: Record = { x_block: XBlock, } -// Build a reverse mapping of tools to block types -const toolToBlockType = Object.entries(blocks).reduce( - (acc, [blockType, config]) => { - config.tools.access.forEach((toolId) => { - acc[toolId] = blockType - }) - return acc - }, - {} as Record -) - // Helper functions export const getBlock = (type: string): BlockConfig | undefined => blocks[type] diff --git a/components/icons.tsx b/components/icons.tsx index 2957e62f98..92f41c96be 100644 --- a/components/icons.tsx +++ b/components/icons.tsx @@ -1310,3 +1310,45 @@ export const CrunchbaseIcon = (props: SVGProps) => ( ) + +export function BrainIcon(props: SVGProps) { + return ( + + + + + + + ) +}