feat: Add LlamaCpp provider for local NIF-based LLM inference#27
Merged
feat: Add LlamaCpp provider for local NIF-based LLM inference#27
Conversation
Add llama_cpp_ex integration for running GGUF models directly in-process via NIF bindings. No HTTP server needed. - New provider at lib/nous/providers/llamacpp.ex with Code.ensure_loaded? guard - New stream normalizer for ChatCompletionChunk structs - Model parsing extracts :llamacpp_model into default_settings - Routes to OpenAI format for message conversion - Full example at examples/providers/llamacpp.exs - Bump version to 0.13.0
- Convert string-keyed maps to atom-keyed maps for LlamaCppEx API
- Use Map.get for safe access on ChatCompletion structs/maps
- Handle stream_chat_completion returning stream directly (not {:ok, stream})
- Fix stream normalizer to handle both atom and string-keyed chunks
- Fix fallback module to avoid dead code dialyzer errors
- Forward :llamacpp_model option in generate_text/stream_text
Tested with Qwen3-4B-Q4_K_M.gguf: agent run, generate_text, and
streaming all pass.
- Add settings mapping table to LlamaCpp provider moduledoc - Document enable_thinking: false for thinking models (Qwen3, DeepSeek) - Update example with thinking vs non-thinking comparison - Add enable_thinking to README config section - Pass enable_thinking through build_settings in LLM module
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
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.
Add llama_cpp_ex integration for running GGUF models directly in-process via NIF bindings. No HTTP server needed.