mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-10 23:48:09 -05:00
Added CrewAI vision block, not functional
This commit is contained in:
58
blocks/blocks/crewai.ts
Normal file
58
blocks/blocks/crewai.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
import { BlockConfig } from '../types'
|
||||
import { CrewAIIcon } from '@/components/icons'
|
||||
|
||||
export const CrewAIVisionBlock: BlockConfig = {
|
||||
type: 'crewaivision',
|
||||
toolbar: {
|
||||
title: 'CrewAI Vision',
|
||||
description: 'Analyze images with CrewAI Vision API',
|
||||
bgColor: '#FF2F5E',
|
||||
icon: CrewAIIcon,
|
||||
category: 'advanced'
|
||||
},
|
||||
tools: {
|
||||
access: ['crewai.vision']
|
||||
},
|
||||
workflow: {
|
||||
inputs: {
|
||||
apiKey: { type: 'string', required: true },
|
||||
imageUrl: { type: 'string', required: false },
|
||||
base64Image: { type: 'string', required: false },
|
||||
model: { type: 'string', required: false }
|
||||
},
|
||||
outputs: {
|
||||
response: 'any'
|
||||
},
|
||||
subBlocks: [
|
||||
{
|
||||
id: 'apiKey',
|
||||
title: 'API Key',
|
||||
type: 'short-input',
|
||||
layout: 'full',
|
||||
placeholder: 'Enter your CrewAI API key',
|
||||
password: true
|
||||
},
|
||||
{
|
||||
id: 'imageUrl',
|
||||
title: 'Image URL',
|
||||
type: 'short-input',
|
||||
layout: 'full',
|
||||
placeholder: 'Enter image URL'
|
||||
},
|
||||
{
|
||||
id: 'base64Image',
|
||||
title: 'Base64 Image',
|
||||
type: 'code',
|
||||
layout: 'full',
|
||||
placeholder: 'Paste base64-encoded data'
|
||||
},
|
||||
{
|
||||
id: 'model',
|
||||
title: 'Vision Model',
|
||||
type: 'dropdown',
|
||||
layout: 'half',
|
||||
options: ['vision-latest', 'vision-beta']
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -4,15 +4,17 @@ import { BlockConfig } from './types'
|
||||
import { AgentBlock } from './blocks/agent'
|
||||
import { ApiBlock } from './blocks/api'
|
||||
import { FunctionBlock } from './blocks/function'
|
||||
import { CrewAIVisionBlock } from './blocks/crewai'
|
||||
|
||||
// Export blocks for ease of use
|
||||
export { AgentBlock, ApiBlock, FunctionBlock }
|
||||
export { AgentBlock, ApiBlock, FunctionBlock, CrewAIVisionBlock }
|
||||
|
||||
// Registry of all block configurations
|
||||
const blocks: Record<string, BlockConfig> = {
|
||||
agent: AgentBlock,
|
||||
api: ApiBlock,
|
||||
function: FunctionBlock
|
||||
function: FunctionBlock,
|
||||
crewaivision: CrewAIVisionBlock
|
||||
}
|
||||
|
||||
// Build a reverse mapping of tools to block types
|
||||
|
||||
@@ -344,7 +344,7 @@ export function SectionIcon(props: SVGProps<SVGSVGElement>) {
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M4.88889 22.2222V7.77778M4.88889 22.2222C4.31752 22.2222 3.75898 22.3917 3.28391 22.7091C2.80883 23.0265 2.43856 23.4777 2.2199 24.0056C2.00125 24.5335 1.94404 25.1143 2.05551 25.6747C2.16698 26.2351 2.44212 26.7498 2.84614 27.1539C3.25016 27.5579 3.76491 27.833 4.3253 27.9445C4.88569 28.056 5.46654 27.9987 5.99442 27.7801C6.5223 27.5614 6.97348 27.1912 7.29091 26.7161C7.60835 26.241 7.77778 25.6825 7.77778 25.1111M4.88889 22.2222C5.65507 22.2222 6.38987 22.5266 6.93164 23.0684C7.47341 23.6101 7.77778 24.3449 7.77778 25.1111M4.88889 7.77778C5.65507 7.77778 6.38987 7.47341 6.93164 6.93164C7.47341 6.38987 7.77778 5.65507 7.77778 4.88889M4.88889 7.77778C4.31752 7.77778 3.75898 7.60835 3.28391 7.29091C2.80883 6.97348 2.43856 6.5223 2.2199 5.99442C2.00125 5.46654 1.94404 4.88569 2.05551 4.3253C2.16698 3.76491 2.44212 3.25016 2.84614 2.84614C3.25016 2.44212 3.76491 2.16698 4.3253 2.05551C4.88569 1.94404 5.46654 2.00125 5.99442 2.2199C6.5223 2.43856 6.97348 2.80883 7.29091 3.28391C7.60835 3.75898 7.77778 4.31752 7.77778 4.88889M7.77778 25.1111H22.2222M7.77778 4.88889H22.2222M22.2222 4.88889C22.2222 5.65507 22.5266 6.38987 23.0684 6.93164C23.6101 7.47341 24.3449 7.77778 25.1111 7.77778M22.2222 4.88889C22.2222 4.31752 22.3917 3.75898 22.7091 3.28391C23.0265 2.80883 23.4777 2.43856 24.0056 2.2199C24.5335 2.00125 25.1143 1.94404 25.6747 2.05551C26.2351 2.16698 26.7498 2.44212 27.1539 2.84614C27.5579 3.25016 27.833 3.76491 27.9445 4.3253C28.056 4.88569 27.9987 5.46654 27.7801 5.99442C27.5614 6.5223 27.1912 6.97348 26.7161 7.29091C26.241 7.60835 25.6825 7.77778 25.1111 7.77778M25.1111 7.77778V22.2222M25.1111 22.2222C24.3449 22.2222 23.6101 22.5266 23.0684 23.0684C22.5266 23.6101 22.2222 24.3449 22.2222 25.1111M25.1111 22.2222C25.6825 22.2222 26.241 22.3917 26.7161 22.7091C27.1912 23.0265 27.5614 23.4777 27.7801 24.0056C27.9987 24.5335 28.056 25.1143 27.9445 25.6747C27.833 26.2351 27.5579 26.7498 27.1539 27.1539C26.7498 27.5579 26.2351 27.833 25.6747 27.9445C25.1143 28.056 24.5335 27.9987 24.0056 27.7801C23.4777 27.5614 23.0265 27.1912 22.7091 26.7161C22.3917 26.241 22.2222 25.6825 22.2222 25.1111"
|
||||
d="M4.88889 22.2222V7.77778M4.88889 22.2222C4.31752 22.2222 3.75898 22.3917 3.28391 22.7091C2.80883 23.0265 2.43856 23.4777 2.2199 24.0056C2.00125 24.5335 1.94404 25.1143 2.05551 25.6747C2.16698 26.2351 2.44212 26.7498 2.84614 27.1539C3.25016 27.5579 3.76491 27.833 4.3253 27.9445C4.88569 28.056 5.46654 27.9987 5.99442 27.7801C6.5223 27.5614 6.97348 27.1912 7.29091 26.7161C7.60835 26.241 7.77778 25.6825 7.77778 25.1111M4.88889 22.2222C5.65507 22.2222 6.38987 22.5266 6.93164 23.0684C7.47341 23.6101 7.77778 24.3449 7.77778 25.1111M4.88889 7.77778C5.65507 7.77778 6.38987 7.47341 6.93164 6.93164C7.47341 6.38987 7.77778 5.65507 7.77778 4.88889M4.88889 7.77778C4.31752 7.77778 3.75898 7.60835 3.28391 7.29091C2.80883 6.97348 2.43856 6.5223 2.2199 5.99442C2.00125 5.46654 1.94404 4.88569 2.05551 4.3253C2.16698 3.76491 2.44212 3.25016 2.84614 2.84614C3.25016 2.44212 3.76491 2.16698 4.3253 2.05551C4.88569 1.94404 5.46654 2.00125 5.99442 2.2199C6.5223 2.43856 6.97348 2.80883 7.29091 3.28391C7.60835 3.75898 7.77778 4.31752 7.77778 4.88889M7.77778 25.1111H22.2222M7.77778 4.88889H22.2222M22.2222 4.88889C22.2222 5.65507 22.5266 6.38987 23.0684 6.93164C23.6101 7.47341 24.3449 7.77778 25.1111 7.77778M22.2222 4.88889C22.2222 4.31752 22.3917 3.75898 22.7091 3.28391C23.0265 2.80883 23.4777 2.43856 24.0056 2.2199C24.5335 2.00125 25.1143 1.94404 25.6747 2.05551C26.2351 2.16698 26.7498 2.44212 27.1539 2.84614C27.5579 3.25016 27.833 3.76491 27.9445 4.3253C28.056 4.88569 27.9987 5.46654 27.7801 5.99442C27.5614 6.5223 27.1912 6.97348 26.7161 7.29091C26.241 7.60835 25.6825 7.77778 25.1111 7.77778M25.1111 7.77778V22.2222M25.1111 22.2222C24.3449 22.2222 23.6101 22.5266 23.0684 23.0684C22.5266 23.6101 22.2222 24.3449 22.2222 25.1111M25.1111 22.2222C25.6825 22.2222 26.241 22.3917 26.7161 22.7091C27.1912 23.0265 27.5614 23.4777 27.7801 24.0056C27.9987 24.5335 28 25.1143 27.9445 25.6747C27.833 26.2351 27.5579 26.7498 27.1539 27.1539C26.7498 27.5579 26.2351 27.833 25.6747 27.9445C25.1143 28.056 24.5335 27.9987 24.0056 27.7801C23.4777 27.5614 23.0265 27.1912 22.7091 26.7161C22.3917 26.241 22.2222 25.6825 22.2222 25.1111"
|
||||
stroke="currentColor"
|
||||
strokeWidth="2.5"
|
||||
strokeLinecap="round"
|
||||
@@ -850,3 +850,17 @@ export function BrightIcon(props: SVGProps<SVGSVGElement>) {
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
export function CrewAIIcon(props: SVGProps<SVGSVGElement>) {
|
||||
return (
|
||||
<svg
|
||||
{...props}
|
||||
role="img"
|
||||
viewBox="0 0 24 24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
fill="currentColor"
|
||||
>
|
||||
<path d="M12.5.2C7.2 1.3 1.5 9 1.5 15.4c-.1 5.5 3 8.6 8.6 8.6 6.7 0 14.3-6.9 12.1-10.9-.7-1.3-1.4-1.4-2.7-.2-1.6 1.4-1.6.3-.2-2.9 1.8-4 1.7-5.3-.3-7.5C17 .4 15-.4 12.5.2zm5.3 2c2.3 2 2.4 4.3.5 8.5-1.4 3-2.2 3.5-3.9 1.8-1.2-1.2-1.3-3.4-.2-6 1.1-2.7 1-3.1-.6-1.7-3.7 3.4-6.4 9.8-5.4 12.5.5 1.2.8 1.4 2.7 1.4a11 11 0 0 0 8-3.9c1.8-2.3 2.8-2.3 2.8 0 0 3.8-6.5 8.6-11.7 8.6-6.2 0-9.3-4.8-7.4-11.5.8-3 4.4-7.9 7-9.7 3.3-2.1 5.7-2.1 8.2 0z" />
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
75
tools/crewai/vision.ts
Normal file
75
tools/crewai/vision.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import { ToolConfig, ToolResponse } from '../types'
|
||||
|
||||
interface CrewAIVisionParams {
|
||||
apiKey: string
|
||||
imageUrl?: string
|
||||
base64Image?: string
|
||||
model?: string
|
||||
}
|
||||
|
||||
interface CrewAIVisionResponse extends ToolResponse {
|
||||
tokens?: number
|
||||
model?: string
|
||||
}
|
||||
|
||||
export const visionTool: ToolConfig<CrewAIVisionParams, CrewAIVisionResponse> = {
|
||||
id: 'crewai.vision',
|
||||
name: 'CrewAI Vision',
|
||||
description: 'Analyze images using CrewAI\'s Vision model',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'Your CrewAI API key'
|
||||
},
|
||||
imageUrl: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'Publicly accessible image URL'
|
||||
},
|
||||
base64Image: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'Base64-encoded image data'
|
||||
},
|
||||
model: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
default: 'vision-latest',
|
||||
description: 'Model to use for image analysis'
|
||||
}
|
||||
},
|
||||
|
||||
request: {
|
||||
url: 'https://api.crewai.com/v1/vision/analyze',
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${params.apiKey}`
|
||||
}),
|
||||
body: (params) => {
|
||||
return {
|
||||
model: params.model,
|
||||
imageUrl: params.imageUrl,
|
||||
base64: params.base64Image
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const data = await response.json()
|
||||
return {
|
||||
output: data.result,
|
||||
tokens: data.usage?.total_tokens,
|
||||
model: data.model
|
||||
}
|
||||
},
|
||||
|
||||
transformError: (error) => {
|
||||
const message = error.error?.message || error.message
|
||||
const code = error.error?.type || error.code
|
||||
return `${message} (${code})`
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import { requestTool as httpRequest } from './http/request'
|
||||
import { contactsTool as hubspotContacts } from './hubspot/contacts'
|
||||
import { opportunitiesTool as salesforceOpportunities } from './salesforce/opportunities'
|
||||
import { functionExecuteTool as functionExecute } from './function/execute'
|
||||
import { visionTool as crewAIVision } from './crewai/vision'
|
||||
|
||||
// Registry of all available tools
|
||||
export const tools: Record<string, ToolConfig> = {
|
||||
@@ -25,7 +26,9 @@ export const tools: Record<string, ToolConfig> = {
|
||||
'hubspot.contacts': hubspotContacts,
|
||||
'salesforce.opportunities': salesforceOpportunities,
|
||||
// Function Tools
|
||||
'function.execute': functionExecute
|
||||
'function.execute': functionExecute,
|
||||
// CrewAI Tools
|
||||
'crewai.vision': crewAIVision
|
||||
}
|
||||
|
||||
// Get a tool by its ID
|
||||
|
||||
Reference in New Issue
Block a user