[GH-ISSUE #19] Update node openai lib from 3.3.0 to latest (4.52.3+) #18

Closed
opened 2026-03-03 13:52:13 +03:00 by kerem · 2 comments
Owner

Originally created by @0xdevalias on GitHub (Jul 3, 2024).
Original GitHub issue: https://github.com/jehna/humanify/issues/19

Some notes I made in another issue, but felt like it deserved it's own more specific issue to track it.

I also noticed that this project is using the node openai 3.3.0 package, whereas it's up to 4.52.3 now (that might not make a difference at all, but you never know):

github.com/jehna/humanify@002fd68d10/package.json (L22)

The changelog entries only seem to start from 4.2.0:

There are a few bugfix entries related to handling errors while streaming.. I wonder if that might be helpful?

Also some related to tools/functions, eg.

And new model:


  • https://github.com/openai/openai-node#automated-function-calls
    • We provide the openai.beta.chat.completions.runTools({…}) convenience helper for using function tool calls with the /chat/completions endpoint which automatically call the JavaScript functions you provide and sends their results back to the /chat/completions endpoint, looping as long as the model requests tool calls.

    • If you pass a parse function, it will automatically parse the arguments for you and returns any parsing errors to the model to attempt auto-recovery. Otherwise, the args will be passed to the function you provide as a string.

    • If you pass tool_choice: {function: {name: …}} instead of auto, it returns immediately after calling that function (and only loops to auto-recover parsing errors).

    • Note that runFunctions was previously available as well, but has been deprecated in favor of runTools.


We can see that the openai stuff is initially called here, which generates a 'plugin' that is then applied to the code of each of the files extracted with webcrack:

github.com/jehna/humanify@002fd68d10/src/index.ts (L56-L71)

With the main logic being implemented here, and the actual SDK call within codeToVariableRenames:

github.com/jehna/humanify@002fd68d10/src/openai/openai.ts (L14-L82)

We can also see that it's using the functions config, which is deprecated now, and replaced by tools:

Originally posted by @0xdevalias in https://github.com/jehna/humanify/issues/18#issuecomment-2204857432

Originally created by @0xdevalias on GitHub (Jul 3, 2024). Original GitHub issue: https://github.com/jehna/humanify/issues/19 Some notes I made in another issue, but felt like it deserved it's own more specific issue to track it. > I also noticed that this project is using the node `openai` `3.3.0` package, whereas it's up to `4.52.3` now (that might not make a difference at all, but you never know): > > - https://www.npmjs.com/package/openai > - https://github.com/openai/openai-node/releases > > https://github.com/jehna/humanify/blob/002fd68d10f7ff13b80b7c305ad09c9c7f63bc47/package.json#L22 > > The changelog entries only seem to start from `4.2.0`: > > - https://github.com/openai/openai-node/blob/master/CHANGELOG.md#420-2023-08-23 > > There are a few bugfix entries related to handling errors while streaming.. I wonder if that might be helpful? > > - https://github.com/openai/openai-node/blob/master/CHANGELOG.md#4122-2023-10-16 > > Also some related to tools/functions, eg. > > - https://github.com/openai/openai-node/blob/master/CHANGELOG.md#4210-2023-12-11 > - https://github.com/openai/openai-node/pull/562 > - https://github.com/openai/openai-node/blob/master/CHANGELOG.md#4221-2023-12-15 > - https://github.com/openai/openai-node/issues/570 > > And new model: > > - https://github.com/openai/openai-node/blob/master/CHANGELOG.md#4460-2024-05-13 > - https://github.com/openai/openai-node/issues/841 > > --- > > - https://github.com/openai/openai-node#automated-function-calls > - > We provide the `openai.beta.chat.completions.runTools({…})` convenience helper for using function tool calls with the `/chat/completions` endpoint which automatically call the JavaScript functions you provide and sends their results back to the `/chat/completions` endpoint, looping as long as the model requests tool calls. > - > If you pass a `parse` function, it will automatically parse the `arguments` for you and returns any parsing errors to the model to attempt auto-recovery. Otherwise, the args will be passed to the function you provide as a string. > - > If you pass `tool_choice: {function: {name: …}}` instead of `auto`, it returns immediately after calling that function (and only loops to auto-recover parsing errors). > - > Note that `runFunctions` was previously available as well, but has been deprecated in favor of `runTools`. > > --- > > We can see that the openai stuff is initially called here, which generates a 'plugin' that is then applied to the code of each of the files extracted with `webcrack`: > > https://github.com/jehna/humanify/blob/002fd68d10f7ff13b80b7c305ad09c9c7f63bc47/src/index.ts#L56-L71 > > With the main logic being implemented here, and the actual SDK call within `codeToVariableRenames`: > > https://github.com/jehna/humanify/blob/002fd68d10f7ff13b80b7c305ad09c9c7f63bc47/src/openai/openai.ts#L14-L82 > > We can also see that it's using the `functions` config, which is deprecated now, and replaced by `tools`: > > - https://platform.openai.com/docs/api-reference/chat/create#chat-create-functions > - https://platform.openai.com/docs/api-reference/chat/create#chat-create-tools > > _Originally posted by @0xdevalias in https://github.com/jehna/humanify/issues/18#issuecomment-2204857432_
kerem closed this issue 2026-03-03 13:52:14 +03:00
Author
Owner

@Acters commented on GitHub (Jul 15, 2024):

Hello, I have updated the OpenAI package to 4.52.7 and switched the models to use GPT4o. On top of that I had also switched gpt3-encoder to the newer gpt-tokenizer package. I kept almost all the processes the same as to help this project to stay up to date on the available OpenAI models and its API changes. I didnt make a pull request as I didn't test my code extensively. I also see that the owner is quite busy and don't wish to bother him. So I will be keeping my own version for now.

If you wish to look at the changes I am making to the humanify project, then the link to it is here: https://github.com/Acters/humanify-ng/tree/GPT4o

<!-- gh-comment-id:2228507552 --> @Acters commented on GitHub (Jul 15, 2024): Hello, I have updated the OpenAI package to 4.52.7 and switched the models to use GPT4o. On top of that I had also switched gpt3-encoder to the newer gpt-tokenizer package. I kept almost all the processes the same as to help this project to stay up to date on the available OpenAI models and its API changes. I didnt make a pull request as I didn't test my code extensively. I also see that the owner is quite busy and don't wish to bother him. So I will be keeping my own version for now. If you wish to look at the changes I am making to the humanify project, then the link to it is here: https://github.com/Acters/humanify-ng/tree/GPT4o
Author
Owner

@0xdevalias commented on GitHub (Aug 12, 2024):

This should now be fixed in v2 since there's the long awaited JSON mode with the new structured outputs. Please take a look and repoen if anything comes up

Originally posted by @jehna in https://github.com/jehna/humanify/issues/22#issuecomment-2282876269

Since the v2 release is using the 4.55.1 version of the openai lib, I consider this issue implemented now:

github.com/jehna/humanify@a6b09993dd/package.json (L52)

See also:

<!-- gh-comment-id:2282991457 --> @0xdevalias commented on GitHub (Aug 12, 2024): > This should now be fixed in v2 since there's the long awaited JSON mode with the new [structured outputs](https://openai.com/index/introducing-structured-outputs-in-the-api/). Please take a look and repoen if anything comes up > > _Originally posted by @jehna in https://github.com/jehna/humanify/issues/22#issuecomment-2282876269_ Since the `v2` release is using the `4.55.1` version of the `openai` lib, I consider this issue implemented now: https://github.com/jehna/humanify/blob/a6b09993dd93843a4a76556e4ed91b073f6a50b1/package.json#L52 See also: - https://github.com/jehna/humanify/issues/31
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/humanify#18
No description provided.