-
Notifications
You must be signed in to change notification settings - Fork 23
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 support #12
Comments
You should be able to enable JS module imports in a TypeScript project. Try adding this to your
|
Hi, @belladoreai Thanks for your response. I already had that enabled and unfortunately, the issue with that is, as mentioned in issue #10, REQUIRE_ESM
I am importing it like this:
Here is my
Thanks again for this awesome package. |
nvm. Got it to work by converting it into a .ts file and using it. here's the code that works:
with the fillowing tsconfig.json
Thanks a lot. |
I'm glad to hear you got it working! I'll leave this issue open so that other people can more easily find it and benefit from your solution. |
In my project I just use the npm package with the following type definition in a .d.ts file in my project: declare module 'llama-tokenizer-js' {
declare namespace LlamaTokenizer {
function encode(prompt: string, add_bos_token?: boolean, add_preceding_space?: boolean, log_performance?: boolean): number[] | undefined;
function decode(tokens: number[], add_bos_token?: boolean, add_preceding_space?: boolean): string;
}
export default LlamaTokenizer;
} And then: |
Thank you @ycros and @singwithaashish and @blaze2004 , we have added a types definition file to the project. |
Importing it in a typescript file gives
TSError: ⨯ Unable to compile TypeScript: server.ts:5:33 - error TS7016: Could not find a declaration file for module 'llama-tokenizer-js'. '.../node_modules/llama-tokenizer-js/llama-tokenizer.js' implicitly has an 'any' type. Try
npm i --save-dev @types/llama-tokenizer-jsif it exists or add a new declaration (.d.ts) file containing
declare module 'llama-tokenizer-js';``@types/llama-tokenizer-js
doesn't existThe text was updated successfully, but these errors were encountered: