openai-node
openai-node copied to clipboard
Incorrect type for callback function
Confirm this is a Node library issue and not an underlying OpenAI API issue
- [X] This is an issue with the Node library
Describe the bug
The type of AutoParseableTool is incorrectly describing $callback as receiving the arguments zod schema as input while it should have the inferred zod type of the arguments zod schema.
To Reproduce
- Define a tool with the
import { zodFunction } from 'openai/helpers/zod';helper. - Check the inferred type of
$callbackproperty on the tool.
Code snippets
Can be fixed by adding zodInfer<...> here:
https://github.com/openai/openai-node/blob/3fdc7d4f67a6ceea51723684dcc0bc1895088259/src/lib/parser.ts#L66-L77
So $callback will become:
$callback: ((args: zodInfer<OptionsT['arguments']>) => any) | undefined;
OS
macOS
Node version
Node v20.15.1
Library version
openai v4.76.3