kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
24 wiersze
594 B
TypeScript
24 wiersze
594 B
TypeScript
import { tool } from 'ai'
|
|
|
|
import type { AIFunctionLike } from '../types'
|
|
import { AIFunctionSet } from '../ai-function-set'
|
|
|
|
/**
|
|
* Converts a set of Agentic stdlib AI functions to an object compatible with
|
|
* the Vercel AI SDK's `tools` parameter.
|
|
*/
|
|
export function createAISDKTools(...aiFunctionLikeTools: AIFunctionLike[]) {
|
|
const fns = new AIFunctionSet(aiFunctionLikeTools)
|
|
|
|
return Object.fromEntries(
|
|
fns.map((fn) => [
|
|
fn.spec.name,
|
|
tool({
|
|
description: fn.spec.description,
|
|
parameters: fn.inputSchema,
|
|
execute: fn.impl
|
|
})
|
|
])
|
|
)
|
|
}
|