UNPKG

@nomyx/assistant

Version:

A powerful assistant library and cli for your AI projects. works with Vertex AI (Claude and Gemini)

38 lines (37 loc) 1.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.convertToolSchema = convertToolSchema; exports.convertToolCall = convertToolCall; exports.convertMessages = convertMessages; function convertToolSchema(schema) { return { name: schema.name, description: schema.description, parameters: { type: 'object', properties: Object.entries(schema.parameters.properties).reduce((acc, [key, value]) => { const paramDef = value; acc[key] = { type: paramDef.type }; return acc; }, {}), required: schema.parameters.required || [], }, }; } function convertToolCall(call) { return { name: call.name, arguments: JSON.parse(call.arguments || '{}'), }; } function convertMessages(messages) { return messages.map(msg => ({ role: msg.role, content: msg.content, name: msg.name, function_call: msg.function_call ? { name: msg.function_call.name, arguments: JSON.stringify(msg.function_call.arguments) } : undefined })); }