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 TokenSet.numSet/toString and tokenRepr in jsctrl #76

Merged

Conversation

kevinmingtarja
Copy link
Contributor

This PR adds support for TokenSet.numSet/toString and tokenRepr in jsctrl.

Example:

// samples/hello.js

async function main() {
    await $`Ultimate answer is to the life, universe and everything is `
    await gen({ regex: /abc^/ })
}

start(main)

Output:

% ../../aici.sh run --build . samples/hello.js
...
[0]: FIXED "Ultimate answer is to the life, universe and everything is "
[0]: GEN-OPT {regex: /abc^/}
[0]: regex constraint: "abc^"
[0]: dfa: 244 bytes
[0]: ALLOW: TokenSet: 3/50295; "a", "ab", "abc"
[0]: GEN-STEP: "a"
[0]: ALLOW: TokenSet: 2/50295; "b", "bc"
[0]: GEN-STEP: "b"
[0]: ALLOW: TokenSet: 1/50295; "c"
[0]: GEN-STEP: "c"
[0]: ALLOW: TokenSet: 0/50295;
[0]: Constraint doesn't allow any tokens; adding EOS
[0]: GEN-STEP: EOS
[0]: GEN "abc"
[0]: JsCtrl: done
[DONE]
[Response] abc

Closes #64

@kevinmingtarja
Copy link
Contributor Author

@microsoft-github-policy-service agree

Copy link
Member

@mmoskal mmoskal left a comment

Choose a reason for hiding this comment

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

Looks great!

I added separate #77 for future PR

@mmoskal mmoskal merged commit c662637 into microsoft:main Mar 15, 2024
7 checks passed
@kevinmingtarja
Copy link
Contributor Author

Thanks for the review @mmoskal!

This project looks really interesting, I'll be closely following the development, and hope to contribute more in the future :)

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.

add TokenSet.num_set/repr in jsctrl
2 participants