Skip to content

feat: Add LlamaCpp provider for local NIF-based LLM inference#27

Merged
nyo16 merged 3 commits intomasterfrom
feat/llamacpp-provider
Mar 5, 2026
Merged

feat: Add LlamaCpp provider for local NIF-based LLM inference#27
nyo16 merged 3 commits intomasterfrom
feat/llamacpp-provider

Conversation

@nyo16
Copy link
Copy Markdown
Owner

@nyo16 nyo16 commented Mar 5, 2026

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

nyo16 added 3 commits March 5, 2026 14:42
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
@nyo16 nyo16 merged commit 1a24bc6 into master Mar 5, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant