@draftor/tools
Version:
A simple TypeScript/Javascript functions to openai tool call format
39 lines (33 loc) • 832 B
text/typescript
export interface IParam {
type: 'object';
properties: Record<string, { type: string; description: string }>;
}
export interface ITools {
toOpenAI: (type?: string) => string | ITool[];
exec(input: IToolCall): any;
exec(func: string, params: object): any;
}
// https://openrouter.ai/docs/requests#:~:text=object%0A%7D%3B-,type%20Tool%20%3D%20%7B,-type%3A%20%22function
// Request
export interface ITool {
type: 'function';
function: IFunctionDescription;
}
// Response
export interface IToolCall {
index: number,
id: string;
type: 'function';
function: IFunctionCall;
}
// Request
export interface IFunctionDescription {
description?: string;
name: string;
parameters: object;
}
// Response
export interface IFunctionCall {
name: string;
arguments: string;
}