diff --git a/packages/ai-sdk/src/ai-sdk.ts b/packages/ai-sdk/src/ai-sdk.ts index a9436fc0..3feb9e05 100644 --- a/packages/ai-sdk/src/ai-sdk.ts +++ b/packages/ai-sdk/src/ai-sdk.ts @@ -14,7 +14,7 @@ export function createAISDKTools(...aiFunctionLikeTools: AIFunctionLike[]) { tool({ description: fn.spec.description, parameters: fn.inputSchema, - execute: fn.impl + execute: fn.execute }) ]) ) diff --git a/packages/core/src/create-ai-function.ts b/packages/core/src/create-ai-function.ts index 3d1b4e5e..405ab4e9 100644 --- a/packages/core/src/create-ai-function.ts +++ b/packages/core/src/create-ai-function.ts @@ -82,7 +82,7 @@ export function createAIFunction, Output>( type: 'function', strict } - aiFunction.impl = ( + aiFunction.execute = ( params: z.infer ): types.MaybePromise => { return implementation(params) diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index 2a788051..19153aa5 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -75,7 +75,7 @@ export interface AIFunction< Output = any > { /** - * Invokes the underlying AI function `impl` but first validates the input + * Invokes the underlying AI function `execute` but first validates the input * against this function's `inputSchema`. This method is callable and is * meant to be passed the raw LLM JSON string or an OpenAI-compatible Message. */ @@ -94,7 +94,7 @@ export interface AIFunction< * The underlying function implementation without any arg parsing or validation. */ // TODO: this `any` shouldn't be necessary, but it is for `createAIFunction` results to be assignable to `AIFunctionLike` - impl: (params: z.infer | any) => MaybePromise + execute: (params: z.infer | any) => MaybePromise } export type SafeParseResult = diff --git a/packages/core/src/utils.ts b/packages/core/src/utils.ts index 8b110f6f..280076d2 100644 --- a/packages/core/src/utils.ts +++ b/packages/core/src/utils.ts @@ -264,7 +264,7 @@ export function isAIFunction(obj: any): obj is types.AIFunction { if (!obj.inputSchema) return false if (!obj.parseInput) return false if (!obj.spec) return false - if (!obj.impl) return false + if (!obj.execute) return false if (!obj.spec.name || typeof obj.spec.name !== 'string') return false return true diff --git a/packages/dexter/src/dexter.ts b/packages/dexter/src/dexter.ts index 0429b49e..06acfbf4 100644 --- a/packages/dexter/src/dexter.ts +++ b/packages/dexter/src/dexter.ts @@ -17,7 +17,7 @@ export function createDexterFunctions( description: fn.spec.description, argsSchema: fn.inputSchema }, - fn.impl + fn.execute ) ) } diff --git a/packages/genkit/src/genkit.ts b/packages/genkit/src/genkit.ts index 31e144c3..5aa4c531 100644 --- a/packages/genkit/src/genkit.ts +++ b/packages/genkit/src/genkit.ts @@ -20,7 +20,7 @@ export function createGenkitTools( inputSchema: fn.inputSchema, outputSchema: z.any() }, - fn.impl + fn.execute ) ) } diff --git a/packages/langchain/src/langchain.ts b/packages/langchain/src/langchain.ts index 920ed762..e908bf32 100644 --- a/packages/langchain/src/langchain.ts +++ b/packages/langchain/src/langchain.ts @@ -19,7 +19,7 @@ export function createLangChainTools(...aiFunctionLikeTools: AIFunctionLike[]) { description: fn.spec.description, schema: fn.inputSchema, func: async (input) => { - const result = await Promise.resolve(fn.impl(input)) + const result = await Promise.resolve(fn.execute(input)) // LangChain tools require the output to be a string return stringifyForModel(result) } diff --git a/packages/llamaindex/src/llamaindex.ts b/packages/llamaindex/src/llamaindex.ts index d2929b21..bf3a7062 100644 --- a/packages/llamaindex/src/llamaindex.ts +++ b/packages/llamaindex/src/llamaindex.ts @@ -11,7 +11,7 @@ export function createLlamaIndexTools( const fns = new AIFunctionSet(aiFunctionLikeTools) return fns.map((fn) => - FunctionTool.from(fn.impl, { + FunctionTool.from(fn.execute, { name: fn.spec.name, description: fn.spec.description, parameters: fn.spec.parameters as any diff --git a/packages/mastra/src/mastra.ts b/packages/mastra/src/mastra.ts index adf88928..196d7570 100644 --- a/packages/mastra/src/mastra.ts +++ b/packages/mastra/src/mastra.ts @@ -15,7 +15,7 @@ export function createMastraTools(...aiFunctionLikeTools: AIFunctionLike[]) { id: fn.spec.name, description: fn.spec.description, inputSchema: fn.inputSchema, - execute: (ctx) => fn.impl(ctx.context) + execute: (ctx) => fn.execute(ctx.context) }) ]) ) diff --git a/packages/xsai/src/xsai.ts b/packages/xsai/src/xsai.ts index 99934ff3..5bc9456e 100644 --- a/packages/xsai/src/xsai.ts +++ b/packages/xsai/src/xsai.ts @@ -16,7 +16,7 @@ export function createXSAITools( name: fn.spec.name, description: fn.spec.description, parameters: fn.inputSchema, - execute: fn.impl + execute: fn.execute }) ) )