openai-node icon indicating copy to clipboard operation
openai-node copied to clipboard

Incorrect type for callback function

Open ori-shalom opened this issue 10 months ago • 0 comments

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

  1. Define a tool with the import { zodFunction } from 'openai/helpers/zod'; helper.
  2. Check the inferred type of $callback property 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

ori-shalom avatar Dec 28 '24 19:12 ori-shalom