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

Add abortSignal for createCompletion #26

Merged
merged 2 commits into from
May 12, 2024
Merged

Add abortSignal for createCompletion #26

merged 2 commits into from
May 12, 2024

Conversation

ngxson
Copy link
Owner

@ngxson ngxson commented May 12, 2024

Resolves #19

Usage:

let wantToStop = false; // for example, it will change to true after a while

const outputText = await wllama.createCompletion(elemInput.value, {
  nPredict: 50,
  sampling: {
    temp: 0.5,
    top_k: 40,
    top_p: 0.9,
  },
  (token, piece, currentText, { abortSignal }) => {
    if (wantToStop) {
      abortSignal();
    }
  },
});

@ngxson ngxson merged commit 41566e3 into master May 12, 2024
2 checks passed
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.

Feature request: add a built-in way to interrupt inference
1 participant