Skip to content

Commit 2d49de7

Browse files
committed
add back missed code
1 parent 1f682eb commit 2d49de7

File tree

1 file changed

+37
-3
lines changed

1 file changed

+37
-3
lines changed

apps/sim/providers/utils.ts

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { ChatCompletionChunk } from 'openai/resources/chat/completions'
33
import type { CompletionUsage } from 'openai/resources/completions'
44
import { env } from '@/lib/core/config/env'
55
import { isHosted } from '@/lib/core/config/feature-flags'
6+
import { enrichTableToolForLLM } from '@/lib/table/llm'
67
import { isCustomTool } from '@/executor/constants'
78
import {
89
getComputerUseModels,
@@ -432,9 +433,20 @@ export async function transformBlockTool(
432433
getAllBlocks: () => any[]
433434
getTool: (toolId: string) => any
434435
getToolAsync?: (toolId: string) => Promise<any>
436+
workspaceId?: string
437+
workflowId?: string
438+
executeTool?: (toolId: string, params: Record<string, any>) => Promise<any>
435439
}
436440
): Promise<ProviderToolConfig | null> {
437-
const { selectedOperation, getAllBlocks, getTool, getToolAsync } = options
441+
const {
442+
selectedOperation,
443+
getAllBlocks,
444+
getTool,
445+
getToolAsync,
446+
workspaceId,
447+
workflowId,
448+
executeTool,
449+
} = options
438450

439451
const blockDef = getAllBlocks().find((b: any) => b.type === block.type)
440452
if (!blockDef) {
@@ -511,12 +523,34 @@ export async function transformBlockTool(
511523
uniqueToolId = `${toolConfig.id}_${userProvidedParams.knowledgeBaseId}`
512524
}
513525

526+
// Apply table tool enrichment if applicable
527+
let finalDescription = toolDescription
528+
let finalSchema = llmSchema
529+
530+
if (toolId.startsWith('table_') && workspaceId && workflowId && executeTool) {
531+
const result = await enrichTableToolForLLM(
532+
toolId,
533+
toolDescription,
534+
llmSchema,
535+
userProvidedParams,
536+
{
537+
workspaceId,
538+
workflowId,
539+
executeTool,
540+
}
541+
)
542+
if (result) {
543+
finalDescription = result.description
544+
finalSchema = { ...llmSchema, ...result.parameters }
545+
}
546+
}
547+
514548
return {
515549
id: uniqueToolId,
516550
name: toolName,
517-
description: toolDescription,
551+
description: finalDescription,
518552
params: userProvidedParams,
519-
parameters: llmSchema,
553+
parameters: finalSchema,
520554
}
521555
}
522556

0 commit comments

Comments
 (0)