@draftor/tools
Version:
A simple TypeScript/Javascript functions to openai tool call format
33 lines (27 loc) • 907 B
text/typescript
import { Tools } from '.';
import { IToolCall } from './types';
export function foo(bar: string) {
/**
* @description Converts a number to its string representation.
* @param {boolean} bar - The number to convert.
* @param {number} abc - The number to convert.
* @param {string} xyz - The number to convert.
* @param {undefined} mpn - The number to convert.
* @returns {object} The string representation of the input number.
*/
return bar.toString();
}
const tool = new Tools([foo]);
console.log(tool.toOpenAI('string'));
const y = {
index: 0,
id: 'call_F0tCbPIDQyzxGxYaFvuSGPQN',
type: 'function',
function: {
name: 'foo',
arguments: '{"bar":"Waba laba dub dub!"}',
},
} as IToolCall;
console.log('>>>>>>>>>>>>', tool.exec(y));
const funResp = tool.exec('foo', { bar: 'Waba laba dub dub!' });
console.log('>>>>>>>', funResp);