kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
feaet: rename AIFunction.impl to AIFunction.execute
rodzic
a7301087b9
commit
2da5a84615
|
@ -14,7 +14,7 @@ export function createAISDKTools(...aiFunctionLikeTools: AIFunctionLike[]) {
|
|||
tool({
|
||||
description: fn.spec.description,
|
||||
parameters: fn.inputSchema,
|
||||
execute: fn.impl
|
||||
execute: fn.execute
|
||||
})
|
||||
])
|
||||
)
|
||||
|
|
|
@ -82,7 +82,7 @@ export function createAIFunction<InputSchema extends z.ZodObject<any>, Output>(
|
|||
type: 'function',
|
||||
strict
|
||||
}
|
||||
aiFunction.impl = (
|
||||
aiFunction.execute = (
|
||||
params: z.infer<InputSchema>
|
||||
): types.MaybePromise<Output> => {
|
||||
return implementation(params)
|
||||
|
|
|
@ -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<InputSchema> | any) => MaybePromise<Output>
|
||||
execute: (params: z.infer<InputSchema> | any) => MaybePromise<Output>
|
||||
}
|
||||
|
||||
export type SafeParseResult<TData> =
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -17,7 +17,7 @@ export function createDexterFunctions(
|
|||
description: fn.spec.description,
|
||||
argsSchema: fn.inputSchema
|
||||
},
|
||||
fn.impl
|
||||
fn.execute
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ export function createGenkitTools(
|
|||
inputSchema: fn.inputSchema,
|
||||
outputSchema: z.any()
|
||||
},
|
||||
fn.impl
|
||||
fn.execute
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
})
|
||||
])
|
||||
)
|
||||
|
|
|
@ -16,7 +16,7 @@ export function createXSAITools(
|
|||
name: fn.spec.name,
|
||||
description: fn.spec.description,
|
||||
parameters: fn.inputSchema,
|
||||
execute: fn.impl
|
||||
execute: fn.execute
|
||||
})
|
||||
)
|
||||
)
|
||||
|
|
Ładowanie…
Reference in New Issue