UNPKG

@draftor/tools

Version:

A simple TypeScript/Javascript functions to openai tool call format

44 lines (35 loc) 1.97 kB
prompt: { "messages": [ { "role": "user", "content": "<context>\n```typescript|file:///c%3A/Users/PRAVEEN%20NAIK/Codespace/tool/src/types.ts\nexport interface IParam {\r\n type: 'object';\r\n properties: Record<string, { type: string; description: string }>;\r\n}\r\n\r\nexport interface ITools {\r\n toOpenAI: (type?: string) => string | ITool[];\r\n}\r\n\r\n\r\n\r\n// https://openrouter.ai/docs/requests#:~:text=object%0A%7D%3B-,type%20Tool%20%3D%20%7B,-type%3A%20%22function\r\nexport interface ITool {\r\n type: 'function';\r\n function: IFunctionDescription;\r\n}\r\n\r\nexport interface IFunctionDescription {\r\n description?: string;\r\n name: string;\r\n parameters: object; // JSON Schema object\r\n}\r\n```\n</context>\n\n\n QUERY: -> Add a fucntion to ITools called exec which executes the function\n-> Allow overloading of fucntion or options in params, iter ttake the tool call respose completely ie IToolCall or take func: string, params: object" } ] } context: file:///c%3A/Users/PRAVEEN%20NAIK/Codespace/tool/.cache/draftor/2025-01-16/1737041321-draftor-openai-gpt-4o-2024-11-20.md ================================= **Draft changes**: ```bash root/ ├── src/ └── types.ts | +18 -0 ``` **Gist** : Key changes 1. Added `exec` function in `ITools` interface with specified overloading capabilities. 2. Enabled function or options in parameters (`IToolCall` or `func: string, params: object`). ```typescript|file:///c%3A/Users/PRAVEEN%20NAIK/Codespace/tool/src/types.ts // ... existing code ... export interface IToolCall { tool: string; parameters: object; // JSON Schema object } export interface ITools { toOpenAI: (type?: string) => string | ITool[]; /** * Executes a tool with given function and parameters or directly with a IToolCall. */ exec: (call: IToolCall) => any; exec: (func: string, params: object) => any; } // ... existing code ... ```