withcatai / node-llama-cpp

Run AI models locally on your machine with node.js bindings for llama.cpp. Force a JSON schema on the model output on the generation level
https://node-llama-cpp.withcat.ai
MIT License
829 stars 80 forks source link

node-llama-cpp doesn`t work with typescript #113

Closed eugene-kirnasuk closed 9 months ago

eugene-kirnasuk commented 9 months ago

Issue description

node-llama-cpp doesn`t with typescript

Expected Behavior

work with typescript

Actual Behavior

when I install node-llama-cpp package and run it I have errors

node_modules/node-llama-cpp/dist/llamaEvaluator/LlamaJsonSchemaGrammar.d.ts:3:45 - error TS1139: Type parameter declaration expected.

3 export declare class LlamaJsonSchemaGrammar<const T extends Readonly> extends LlamaGrammar {


node_modules/node-llama-cpp/dist/llamaEvaluator/LlamaJsonSchemaGrammar.d.ts:3:53 - error TS1005: ',' expected.

3 export declare class LlamaJsonSchemaGrammar<const T extends Readonly<GbnfJsonSchema>> extends LlamaGrammar {

node_modules/node-llama-cpp/dist/llamaEvaluator/LlamaJsonSchemaGrammar.d.ts:3:69 - error TS1005: ',' expected.

3 export declare class LlamaJsonSchemaGrammar<const T extends Readonly> extends LlamaGrammar { ~

node_modules/node-llama-cpp/dist/llamaEvaluator/LlamaJsonSchemaGrammar.d.ts:3:85 - error TS1109: Expression expected.

3 export declare class LlamaJsonSchemaGrammar<const T extends Readonly> extends LlamaGrammar { ~

node_modules/node-llama-cpp/dist/llamaEvaluator/LlamaJsonSchemaGrammar.d.ts:3:87 - error TS1109: Expression expected.

3 export declare class LlamaJsonSchemaGrammar<const T extends Readonly> extends LlamaGrammar {


node_modules/node-llama-cpp/dist/llamaEvaluator/LlamaJsonSchemaGrammar.d.ts:3:95 - error TS1434: Unexpected keyword or identifier.

3 export declare class LlamaJsonSchemaGrammar<const T extends Readonly<GbnfJsonSchema>> extends LlamaGrammar {

node_modules/node-llama-cpp/dist/llamaEvaluator/LlamaJsonSchemaGrammar.d.ts:4:5 - error TS1128: Declaration or statement expected.

4 private readonly _schema;


node_modules/node-llama-cpp/dist/llamaEvaluator/LlamaJsonSchemaGrammar.d.ts:4:13 - error TS1128: Declaration or statement expected.

4     private readonly _schema;

node_modules/node-llama-cpp/dist/llamaEvaluator/LlamaJsonSchemaGrammar.d.ts:5:23 - error TS1005: ',' expected.

5 constructor(schema: T); ~

node_modules/node-llama-cpp/dist/llamaEvaluator/LlamaJsonSchemaGrammar.d.ts:6:15 - error TS1005: ',' expected.

6 parse(json: string): GbnfJsonSchemaToType; ~

node_modules/node-llama-cpp/dist/llamaEvaluator/LlamaJsonSchemaGrammar.d.ts:6:24 - error TS1005: ';' expected.

6 parse(json: string): GbnfJsonSchemaToType; ~

node_modules/node-llama-cpp/dist/llamaEvaluator/LlamaJsonSchemaGrammar.d.ts:6:49 - error TS1005: '(' expected.

6 parse(json: string): GbnfJsonSchemaToType; ~

Found 12 errors in the same file, starting at: node_modules/node-llama-cpp/dist/llamaEvaluator/LlamaJsonSchemaGrammar.d.ts:3

Steps to reproduce

install it to the typescript project with none the typescript it works

My Environment

"node-llama-cpp": "^2.8.1" "typescript": "~4.6.3" "ts-node": "~10.7.0", my tsconfig

{ "compileOnSave": false, "compilerOptions": { "baseUrl": "./", "outDir": "./dist", "sourceMap": true, "declaration": false, "module": "commonjs", "moduleResolution": "node", "experimentalDecorators": true, "skipLibCheck": true, "target": "es5", "skipLibCheck": true, "typeRoots": ["node_modules/@types"], "lib": ["es2018", "dom"] } }

Additional Context

No response

Relevant Features Used

Are you willing to resolve this issue by submitting a Pull Request?

Yes, I have the time, but I don't know how to start. I would need guidance.

giladgd commented 9 months ago

@eugene-kirnasuk Your typescript version is too old; update typescript to at least version 5.0.0 to use node-llama-cpp. I'll add an optional peer dependency for typescript that requires this to make this clearer.

github-actions[bot] commented 8 months ago

:tada: This issue has been resolved in version 2.8.3 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] commented 7 months ago

:tada: This issue has been resolved in version 3.0.0-beta.4 :tada:

The release is available on:

Your semantic-release bot :package::rocket: