-
Notifications
You must be signed in to change notification settings - Fork 78
Add support for text generation via language models #223
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
Draft
WhyPenguins
wants to merge
19
commits into
splashkit:develop
Choose a base branch
from
WhyPenguins:genai
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- better for large files/handles resuming
- also add various overloads
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This draft PR adds support for downloading and running language models via SplashKit, using the llama.cpp library. Usage is as simple as:
I'd be interested to know if this is on the right track, or if there are any changes that would make it more likely to be merged in. Thanks!
Details
Llama.cpp is used to perform inference for the language models - it has been added as a submodule to
splashkit-external, and added toCMakeLists.txtas an External Project rather than a subdirectory. This was done so that it could have settings configured independently to the main project (in particular being set to Release mode, which is much quicker).On the API side there is an enum that contains a list of supported models (
language_model), and an accompanying array that contain URLs, names, and default inference settings (models, ingenai.cpp). At least for now I've built llama.cpp so that only CPU inferencing is supported, so the models are chosen such that they still run at acceptable speeds, and also download within a reasonable amount of time (500mb ~ 1.7gb).When first used, a model is auto-downloaded if it doesn't already exist in
~/.splashkit/models/...- this download can be resumed if interrupted (seesk_http_get_file).The model is then loaded, the user's prompt formatted (if in "reply" mode) and tokenized, and then the output text is recorded and returned to the user. The backend (
genai_backend.cpp/.h) abstracts this out so that tokens can be fetched one at a time (used in__generate_commoningenai.cpp).It's also possible to stream the text back, by using

conversationobjects. These can be created withcreate_conversation(...), and have functions for adding new messages, and receiving individual tokens + information about them.test_genai.cppshows the current usage - there are some rough edges still to be fixed up but here's how it can look now:The supported models list also contains base, instruct, and thinking variants for each model (where released).
Basic usage looks like:
These use the default Qwen3 0.6B Instruct model. Overloads allow for changing settings - there is an overload to simply set the model via an enum, and also an overload that allows for changing all settings. For example:
In the finished PR each option will be exposed, similar to
drawing_options.Hopefully that's generally on the right track, let me know if there's anything that needs adjustment!
Type of change
How Has This Been Tested?
So far testing has been a bit limited:
generate_textandgenerate_replyto ensure the model versions are usablegenai_testinsktest, though I plan to expand it a bit furtherI would like to test the PR on Windows as well, and ensure all the models download and run.
Testing Checklist
Checklist