You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(local-llm): Add support for local LLM engine integration - #762
- Added support for local llama.cpp engine integration
- Updated internationalization files with new strings for local LLM settings
- Modified Main.kt to handle application exit logic
- Created new settings section for local LLM in SettingsView.kt
- Enhanced FooterBar.kt to display local LLM engine status
- Configured AppConfig.kt for local LLM engine persistence
- Updated TokenAwareSummarizingMemory.kt to handle duplicate retry messages
- Modified ChatRequestTransformers.kt to trim request body
- Added several new files for local LLM management
- Updated OpenAiCompatibleModelFactory.kt to support local LLM
- Enhanced OpenAiCompatibleTemplate.kt with local LLM template
- Improved RAGIntentClassifier.kt to handle parsing errors
- Expanded AskimoHome.kt with directories for local LLM
- Refactored HttpUtils.kt for better request configuration
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Process lifecycle races, unsafe extraction behavior, platform detection, and model-discovery defects can leave orphan processes or make downloaded models unusable.
Hugging Face commonly exposes sharded GGUFs such as model-00001-of-00004.gguf. Each shard is currently presented as an independent model and the downloader fetches only that one file, so llama-server cannot load it because the remaining shards are absent. Either group/download all shards or exclude shard filenames from these standalone results.
Deleting a model directly can target the file currently opened by a llama-server child. On Windows this commonly throws due to the file lock (the click handler does not catch it); on Unix the process keeps serving an unlinked model while the UI reports it deleted. Unload the matching resident slot and await process termination before deleting, and surface deletion errors.
Retry deduplication drops legitimate duplicate user messages
This cannot distinguish an automatic retry from a legitimate second add of the same user message. After any failed/cancelled request leaves its user message last in memory, manually sending the same text again is silently dropped from memory and persistence. Retry deduplication needs an explicit retry signal or rollback in sendStreamingMessageWithCallback, rather than changing the semantics of every ChatMemory.add.
ATOMIC_MOVE is optional and throws AtomicMoveNotSupportedException on unsupported filesystems, turning an otherwise successful multi-GB download into a failure. The existing Whisper downloader already falls back to a normal replace move; apply the same fallback here.
CLI shutdown does not clean up the shared server manager
Starting this shared HttpServer creates a long-lived server thread, but cleanup was wired only into the desktop Main. The CLI can also use the shared local-LLM model factory; after doing so it has no call to LlamaServerProcessManager.shutdown(), so the CLI can hang on exit and any child process may remain alive. Register manager-owned JVM shutdown cleanup or add lifecycle integration for every application entry point.
This issue also appears on line 293 of the same file.
For catalog models this ignores the persisted lastSelectedModelIsEmbedding and restores the catalog's default role instead. Because the same page says role is determined by the provider field, a catalog chat model previously used for embeddings is incorrectly warmed in the chat slot without --embedding (and vice versa), wasting memory and starting the wrong mode. Preserve catalog metadata but override isEmbedding with the persisted actual slot.
Downloaded search models disappear from management UI
After a search result disappears from searchResults (including after an app restart), its downloaded GGUF is no longer shown anywhere on this management page because displayedEntries only combines the static catalog and current search. Users then cannot see or delete dynamically downloaded models without manually editing the folder. Include valid on-disk non-catalog files, or persist downloaded search metadata and merge it here.
CLI shutdown leaves proxy and child processes running
The manager is in shared JVM code and local OpenAI-compatible instances are usable by the CLI, but only desktop Main.kt calls shutdown(). A CLI request starts this proxy and potentially a child process, while ChatCli's shutdown hook only closes analytics, so non-interactive commands can hang on server threads or leave llama-server orphaned. Register manager cleanup in every application entry point.
ubatchSize is passed through unchanged even though the new configuration contract says it must be <= batchSize. The UI permits lowering batch size below the current micro-batch size, and hand-edited config can do the same, causing llama-server startup to reject the arguments. Enforce the invariant at launch as a final validation boundary.
The response body is an InputStream, but the non-2xx branch throws without closing it. Failed downloads can therefore retain the HTTP connection and its resources until GC. Close the body before raising the status error.
Local LLM callers pass values read directly from AppConfig, which is not Compose-observable. After this callback persists a new option, closing the menu only recomposes this component with its old value parameter, so the field continues displaying the previous selection until a broader recomposition/navigation. Keep a local displayed value (as settingsBooleanField does) and update it before invoking the callback.
Downloaded model files are not validated after moving
The download is marked successful immediately after the move without running the existing validationError(entry) check. A complete HTTP 200 error body or otherwise wrong-sized response therefore becomes the final .gguf, and the UI reports it as downloaded until the first inference fails. Validate after the move and delete the final file before surfacing a download error.
A well-formed gzip stream whose tar payload ends before the next full header is accepted as successful here. If the executable was already extracted, the later existence check passes and the truncated archive is marked installed. Treat any short header as corruption; valid tarballs reach the zero-block branch instead.
Cancellation is incorrectly converted to download failure
ensureActive() throws CancellationException, but this broad catch wraps it in DownloadException. That converts normal coroutine cancellation into an operational failure and can trigger error UI/logging instead of cancellation propagation. Delete the partial file, then rethrow cancellation unchanged.
This string is formatted with a port argument, but MessageFormat treats the apostrophes in d'exécution and l'instant as quoting delimiters, so {0} is emitted literally and the apostrophes disappear. Escape both apostrophes by doubling them.
When Content-Length is absent, totalBytes is -1, but this renders an empty 0% determinate bar and reports downloaded / 0 MB. That incorrectly looks stalled even while bytes are arriving. Use an indeterminate indicator and an unknown-total progress message for this branch.
Hugging Face permits spaces and reserved URI characters in repository file paths. Concatenating rfilename verbatim makes URI(url) fail for names containing spaces and changes the target for characters such as #, so valid search results cannot be downloaded. Percent-encode each path segment before constructing the resolve URL.
Partial download files survive early failure paths
These failure paths occur before the cleanup try, so an existing multi-GB .part/.download file from a prior interrupted run survives a connection error or non-2xx retry, contrary to this method's cleanup contract. Delete destPath on both paths without allowing cleanup failure to mask the download error.
This restoration effect only executes when the Local LLM settings section is composed. After an application restart, the persisted model is therefore not reloaded until the user opens this page, contrary to the startup/warm-up behavior described here and in LocalLlmConfig. Move restoration into application startup/lifecycle code so it runs independently of navigation.
searchResults is transient Compose state, so after leaving this page or restarting, downloaded models discovered through Hugging Face disappear from this management list. They remain on disk and in /models, but the app no longer offers their delete control unless the user happens to reproduce the search. Merge persisted/on-disk non-catalog GGUF files into this list or persist the discovered model metadata.
Use safe unique local names for remote model files
The remote leaf name is used verbatim as a local path component. Hugging Face paths may contain reserved characters (the code below explicitly handles ?, #, etc. in the URL), but characters such as ?, *, or : make this destination invalid on Windows. Using only the leaf also collides for two files in different repo subdirectories with the same name. Derive a bounded, filesystem-safe name from the full repo ID and remote path instead.
Clear installation directory before extracting releases
Extraction writes a new release over the existing platform directory. This is especially problematic on Windows, where all releases share the same directory and executable path: files removed or renamed by the new release remain behind and can be loaded alongside the new executable. Clear and recreate the destination after checksum verification so each installation contains only the verified archive's files.
This completion handler cannot unblock cancellation: a normal invokeOnCompletion handler runs only when the coroutine completes, but completion is waiting for this blocking read to return. A cancelled multi-GB download can therefore remain stuck until the 1–4 hour inactivity timeout, and the resulting IOException is then wrapped as DownloadException. Use a cancellation-time hook/bridge that closes the stream as soon as the job enters cancellation, and re-check cancellation before wrapping read failures.
Show indeterminate progress for unknown download sizes
The downloader explicitly supports unknown content length (totalBytes == -1), but this renders a determinate 0% bar and “downloaded / 0 MB” for the entire transfer. Use an indeterminate progress indicator and an unknown-total status string in that branch so users can tell the download is active.
finally interrupts this thread during Thread.sleep, but the lambda does not catch InterruptedException. Consequently every normal download teardown can emit an uncaught watchdog stack trace. Treat interruption as the expected shutdown path.
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
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.
Summary
Related Issue(s)
Type of Change
What Changed & Why
How to Test
./gradlew testScreenshots / Recordings (if applicable)
Checklist
main./gradlew spotlessApplyand./gradlew detektlocally./gradlew testand all tests passgit commit -sAdditional Notes