Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typescript bindings maintenance #2363

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open

typescript bindings maintenance #2363

wants to merge 18 commits into from

Conversation

iimez
Copy link
Contributor

@iimez iimez commented May 18, 2024

Describe your changes

  • Changed the build scripts and docs a bit so its easier to build the bindings from source.
  • Deleted some outdated comments from the gyp config, and removed the deprecated nCtx on completions.
  • Update the build_unix script to produce so files with the correct build type.
  • Changed CI to call cmake with Release build type.
  • Added support for streamed token decoding, following the python bindings implementation
  • Updated the bindings to expose additional LLModel:load and LLModel:initGpu methods so its easier to copy the loading and backend-picking logic of the CUDA Backend PR. I also renamed a few things for consistency.
  • Include nThreads in the LoadModelOptions, previously it had to be configured via setThreadCount.
  • Added nGpuLayers as alias for ngl to the LoadModelOptions.
  • Updated types and examples accordingly.
  • I added a test suite that does actual inference and loads a real model on both cpu and gpu with minimal resource usage. And moved the existing tests into a separate test:ci script. Can switch CI config back to yarn test if inference in CI is possible.
  • Updated deps and verified that the fallback node-addon build via node-gyp-build is still working. Changed the build setup a bit to include a assert-backend-sources.js script that facilitates easier testing of the fallback during development. This also allows us to get rid of the second bindings.gyp config.

Breaking changes

  • The CompletionOptions onReponseToken(tokenId, text) callback has been changed to onResponseTokens({ tokenIds, text }) (Note the plural.). This is related to the streamed emoji decoding / multi token character issue.

Issue ticket number and link

#2326

iimez added 3 commits May 18, 2024 05:36
Signed-off-by: limez <limez@protonmail.com>
Signed-off-by: limez <limez@protonmail.com>
Signed-off-by: limez <limez@protonmail.com>
@jacoobes jacoobes self-requested a review May 20, 2024 22:26
iimez added 3 commits May 21, 2024 00:57
Signed-off-by: limez <limez@protonmail.com>
Signed-off-by: limez <limez@protonmail.com>
Signed-off-by: limez <limez@protonmail.com>
@iimez iimez changed the title simpler typescript bindings build typescript bindings maintenance May 21, 2024
Signed-off-by: limez <limez@protonmail.com>
@iimez iimez marked this pull request as ready for review May 22, 2024 01:29
jacoobes and others added 2 commits May 23, 2024 16:43
Signed-off-by: jacob <jacoobes@sern.dev>

update typings

Signed-off-by: jacob <jacoobes@sern.dev>
Signed-off-by: jacob <jacoobes@sern.dev>
iimez and others added 4 commits May 25, 2024 20:49
…arts

Signed-off-by: limez <limez@protonmail.com>
… in ci

Signed-off-by: limez <limez@protonmail.com>
Signed-off-by: limez <limez@protonmail.com>
@iimez iimez marked this pull request as ready for review May 26, 2024 05:37
iimez and others added 4 commits May 27, 2024 02:26
…fallback easier testable

Signed-off-by: limez <limez@protonmail.com>
…the others

Signed-off-by: limez <limez@protonmail.com>
Signed-off-by: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com>
Signed-off-by: limez <limez@protonmail.com>

// Silently ignore if the backend sources are not available.
// When the package is installed as a dependency, gpt4all-backend will not be present.
if (fs.existsSync(sourcePath)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this be a usecase for fs.mkdir(sourcePath, { recursive: true })?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not what we want here I think, because when the script gets executed by the user during the install hook (ie user installs the package as a dependency) this would create a gpt4all-backend path under node_modules. And then error because there are no gpt4all-backend sources under that newly created dir. We really just want it to do nothing in that case.

@jacoobes jacoobes self-requested a review May 29, 2024 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants