Modified tools directory to be more generic, updated serializer and executor accordingly

This commit is contained in:
Waleed Latif
2025-01-17 19:08:40 -08:00
parent 85a2528e4d
commit 07cb295200
30 changed files with 1234 additions and 1194 deletions
+28 -3
View File
@@ -1,6 +1,15 @@
import { AgentIcon } from '@/components/icons'
import { BlockConfig } from '../types'
// Map of models to their tools
const MODEL_TOOLS = {
'gpt-4o': 'openai.chat',
'o1-mini': 'openai.chat',
'claude-3-5-sonnet-20241022': 'anthropic.chat',
'gemini-pro': 'google.chat',
'grok-2-latest': 'xai.chat'
} as const;
export const AgentBlock: BlockConfig = {
type: 'agent',
toolbar: {
@@ -22,7 +31,23 @@ export const AgentBlock: BlockConfig = {
}
},
tools: {
access: ['model']
access: ['openai.chat', 'anthropic.chat', 'google.chat', 'xai.chat'],
config: {
tool: (params: Record<string, any>) => {
const model = params.model || 'gpt-4o';
if (!model) {
throw new Error('No model selected');
}
const tool = MODEL_TOOLS[model as keyof typeof MODEL_TOOLS];
if (!tool) {
throw new Error(`Invalid model selected: ${model}`);
}
return tool;
}
}
},
inputs: {
systemPrompt: 'string'
},
subBlocks: [
{
@@ -37,14 +62,14 @@ export const AgentBlock: BlockConfig = {
title: 'Context',
type: 'short-input',
layout: 'full',
placeholder: 'Enter text',
placeholder: 'Enter text'
},
{
id: 'model',
title: 'Model',
type: 'dropdown',
layout: 'half',
options: ['gpt-4o', 'gemini-pro', 'claude-3-5-sonnet-20241022', 'grok-2-latest', 'deepseek-v3'],
options: Object.keys(MODEL_TOOLS)
},
{
id: 'temperature',
+7 -1
View File
@@ -13,7 +13,13 @@ export const ApiBlock: BlockConfig = {
workflow: {
outputType: 'json',
tools: {
access: ['http']
access: ['http.request']
},
inputs: {
url: 'string',
method: 'string',
headers: 'json',
body: 'json'
},
subBlocks: [
{
+3
View File
@@ -15,6 +15,9 @@ export const FunctionBlock: BlockConfig = {
tools: {
access: ['function']
},
inputs: {
code: 'string'
},
subBlocks: [
{
id: 'code',
+6 -2
View File
@@ -4,6 +4,7 @@ import type { JSX } from 'react'
export type BlockIcon = (props: SVGProps<SVGSVGElement>) => JSX.Element
export type BlockCategory = 'basic' | 'advanced'
export type OutputType = 'string' | 'number' | 'json' | 'boolean'
export type ParamType = 'string' | 'number' | 'boolean' | 'json'
export type SubBlockType = 'short-input' | 'long-input' | 'dropdown' | 'slider' | 'table' | 'code'
export type SubBlockLayout = 'full' | 'half'
@@ -44,9 +45,12 @@ export interface BlockConfig {
workflow: {
outputType: OutputTypeConfig
subBlocks: SubBlockConfig[]
tools?: {
tools: {
access: string[]
config?: Record<string, any>
config?: {
tool: (params: Record<string, any>) => string
}
}
inputs?: Record<string, ParamType>
}
}