-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
community[patch]: Add grammar support for node-llama-cpp LLM #5310
Conversation
…SON schema for node-llama-cpp
…SON schema for node-llama-cpp
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really good! I left one comment, and I believe you'll need to run yarn format && yarn lint:fix
to resolve any prettier/eslint issues.
Also, if you could add an integration test for this that would be much appreciated!
Please re-request my review once those changes have been pushed so I can get this merged
this.jsonSchema = inputs?.jsonSchema; | ||
this.gbnf = inputs?.gbnf; | ||
this._model = createLlamaModel(inputs); | ||
this._context = createLlamaContext(this._model, inputs); | ||
this._session = createLlamaSession(this._context); | ||
this._jsonSchema = createLlamaJsonSchemaGrammar(this.jsonSchema); | ||
this._gbnf = createCustomGrammar(this.gbnf); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we drop this.jsonSchema
and this.gbnf
since they appear to only be used inside this constructor?
this.jsonSchema = inputs?.jsonSchema; | |
this.gbnf = inputs?.gbnf; | |
this._model = createLlamaModel(inputs); | |
this._context = createLlamaContext(this._model, inputs); | |
this._session = createLlamaSession(this._context); | |
this._jsonSchema = createLlamaJsonSchemaGrammar(this.jsonSchema); | |
this._gbnf = createCustomGrammar(this.gbnf); | |
this._model = createLlamaModel(inputs); | |
this._context = createLlamaContext(this._model, inputs); | |
this._session = createLlamaSession(this._context); | |
this._jsonSchema = createLlamaJsonSchemaGrammar(inputs?.jsonSchema); | |
this._gbnf = createCustomGrammar(inputs?.gbnf); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I will do this! Thank you for responding. Sorry I didn't see your comments before my last update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! One more question, could this be applied to the chat model integration too? I'll merge this now, but it would be great to get it in for chat models too since those are more widely used.
Hello, I am attempting to add a configuration to langchainjs node-llama-cpp implementation that will make it respond in a specific format like JSON or a list. This is a functionality that the python langchain has for llama. The functionality for this is documented here: https://withcatai.github.io/node-llama-cpp/guide/grammar .