jehna / humanify

Deobfuscate Javascript code using ChatGPT
MIT License
1.58k stars 63 forks source link

Update node openai lib from 3.3.0 to latest (4.52.3+) #19

Closed 0xdevalias closed 2 months ago

0xdevalias commented 3 months ago

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://github.com/jehna/humanify/blob/002fd68d10f7ff13b80b7c305ad09c9c7f63bc47/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:

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:

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

Acters commented 3 months ago

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

0xdevalias commented 2 months ago

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:

https://github.com/jehna/humanify/blob/a6b09993dd93843a4a76556e4ed91b073f6a50b1/package.json#L52

See also: