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

async generator and token stream #1897

Merged
merged 15 commits into from
Feb 24, 2024
Merged

async generator and token stream #1897

merged 15 commits into from
Feb 24, 2024

Conversation

TareHimself
Copy link
Contributor

Describe your changes

Added streaming and Async generator and also correct token count for response tokens

Issue ticket number and link

Checklist before requesting a review

  • I have performed a self-review of my code.
  • If it is a core feature, I have added thorough tests.
  • I have added thorough documentation for my code.
  • I have tagged PR with relevant project labels. I acknowledge that a PR without labels may be dismissed.
  • If this PR addresses a bug, I have provided both a screenshot/video of the original bug and the working solution.

Demo

The following was streamed token by token

Response:  I'm doing well, thank you for asking! How can I help you today?

Steps to Reproduce

import gpt from '../src/gpt4all.js'

const model = await gpt.loadModel("mistral-7b-openorca.Q4_0.gguf")  

process.stdout.write('Response: ')

for await (const token of gpt.generateTokens(model,[{
    role: 'user',
    content: "How are you ?"
  }],{nPredict: 2048 })){
    process.stdout.write(token);
  }

model.dispose();

Notes

Signed-off-by: Tare Ebelo <75279482+TareHimself@users.noreply.github.com>
Signed-off-by: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com>
jacoobes and others added 3 commits January 31, 2024 19:04
Signed-off-by: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com>
Signed-off-by: jacob <jacoobes@sern.dev>
Signed-off-by: jacob <jacoobes@sern.dev>
jacoobes and others added 6 commits February 12, 2024 14:22
Signed-off-by: jacob <jacoobes@sern.dev>
Signed-off-by: jacob <jacoobes@sern.dev>
Signed-off-by: jacob <jacoobes@sern.dev>
Signed-off-by: jacob <jacoobes@sern.dev>
Signed-off-by: jacob <jacoobes@sern.dev>
gpt4all-bindings/typescript/index.cc Outdated Show resolved Hide resolved
gpt4all-bindings/typescript/index.cc Outdated Show resolved Hide resolved
jacoobes and others added 2 commits February 15, 2024 10:04
Co-authored-by: Jared Van Bortel <cebtenzzre@gmail.com>
Signed-off-by: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com>
Signed-off-by: jacob <jacoobes@sern.dev>
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
We already fixed this for the Python bindings, but the C# and typescript
bindings use a different workflow.

Signed-off-by: Jared Van Bortel <jared@nomic.ai>
@cebtenzzre cebtenzzre merged commit a153cc5 into nomic-ai:main Feb 24, 2024
14 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants