Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
5e8c1bb
Initial red-candle provider implementation
cpetersen Sep 8, 2025
5c770dd
Starting to work
cpetersen Sep 8, 2025
fe199a8
Swap qwen for mistral
cpetersen Sep 8, 2025
b8bf331
Trying to add red-candle to the models_to_test.rb
cpetersen Sep 8, 2025
d98834c
Adding red-candle to the models_to_test file
cpetersen Sep 8, 2025
b207f69
Trying to fix the way tool calling support is checked in the specs
cpetersen Sep 8, 2025
ab46320
Deconvoluting local model checks and tool calling support
cpetersen Sep 8, 2025
97d58d2
I think we finally got the local tool calling check correct
cpetersen Sep 8, 2025
9c7f9dc
Enable context length validation for the RedCandle Provider
cpetersen Sep 8, 2025
d5c9129
Working on rubocop fixes
cpetersen Sep 8, 2025
70e1b24
Fixing the rubocop errors
cpetersen Sep 9, 2025
6956724
stubbing the red-candle inference stuff to speed up specs
cpetersen Sep 9, 2025
0aad7d7
Adding an ENV variable so you toggle real red-candle inference on
cpetersen Sep 9, 2025
52a13ca
Adding red-candle to the list of providers in the README
cpetersen Sep 9, 2025
b883989
Adding a new bundle group so developer can choose to include red-cand…
cpetersen Sep 9, 2025
685230c
Adding a comment about possibly supporting more red-candle models in …
cpetersen Sep 9, 2025
a928bb1
Remove red-candle from the gemfiles
cpetersen Sep 9, 2025
ee5b762
Properly register red-candle models
cpetersen Sep 9, 2025
43cc0b8
Removed some unused config options
cpetersen Sep 9, 2025
4b67818
Updating the gemfiles again
cpetersen Sep 9, 2025
c1ac17d
Make the capabilities file match the actual capabilities
cpetersen Sep 9, 2025
54b9834
Deep merge chat options
cpetersen Sep 9, 2025
c78ce40
make red-candle off by default
orangewolf Sep 10, 2025
6816be9
improve error messages
orangewolf Sep 10, 2025
a258a39
improved error message
orangewolf Sep 10, 2025
004563e
add additional models
orangewolf Sep 11, 2025
c4895d6
seperate out tokenizers from gguf
orangewolf Sep 11, 2025
0dc8e9a
more complete error message
orangewolf Sep 11, 2025
8c87b59
Working on documentation
cpetersen Sep 11, 2025
252f97f
Merge branch 'main' into red-candle
cpetersen Sep 11, 2025
d437f73
red-candle is optional
cpetersen Sep 11, 2025
9bdb434
require 'candle' is standard
cpetersen Sep 11, 2025
215e201
Merge branch 'cpetersen/red-candle' into 'red-candle-community'
tpaulshippy Sep 12, 2025
d52e26e
rubocop
orangewolf Sep 12, 2025
8ec93e8
use a spec helper
orangewolf Sep 12, 2025
d1696ff
Remove the too cute pricing method
cpetersen Sep 12, 2025
62a0389
Fix the comment for RubyLLM::Providers::RedCandle::Capabilities
cpetersen Sep 12, 2025
90128bb
Make the require_relative actually relative
cpetersen Sep 12, 2025
9ab992d
Updatae to red-candle 1.3.0 to support ruby 3.1
cpetersen Sep 13, 2025
922e0e9
Update the comment
cpetersen Sep 13, 2025
82dd619
Merge upstream red-candle into red-candle-community: update red-candl…
cursoragent Sep 13, 2025
1d404b3
red_candle: add cache_prompts param to Chat.complete; fix RuboCop spa…
cursoragent Sep 13, 2025
5c5fe55
rubocop: remove trailing whitespace in red_candle chat
cursoragent Sep 13, 2025
6edc393
tests: restore image_saving helper require for image generation specs
cursoragent Sep 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,39 @@ rake vcr:record[all] # Everything

Always check cassettes for leaked API keys before committing.

## Optional Dependencies

### Red Candle Provider

The Red Candle provider enables local LLM execution using quantized GGUF models. It requires a Rust toolchain, so it's optional for contributors.

**To work WITHOUT Red Candle (default):**
```bash
bundle install
bundle exec rspec # Red Candle tests will be skipped
```

**To work WITH Red Candle:**
```bash
# Enable the Red Candle gem group
bundle config set --local with red_candle
bundle install

# Run tests with stubbed Red Candle (fast, default)
bundle exec rspec

# Run tests with real inference (slow, downloads models)
RED_CANDLE_REAL_INFERENCE=true bundle exec rspec
```

**To switch back to working without Red Candle:**
```bash
bundle config unset with
bundle install
```

The `bundle config` settings are stored in `.bundle/config` (gitignored), so each developer can choose their own setup without affecting others.

## Important Notes

* **Never edit `models.json`, `aliases.json`, or `available-models.md`** - they're auto-generated by `rake models`
Expand Down
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,9 @@ group :development do # rubocop:disable Metrics/BlockLength
# Optional dependency for Vertex AI
gem 'googleauth'
end

# Optional group for Red Candle provider (requires Rust toolchain)
# To include: bundle config set --local with red-candle
group :red_candle, optional: true do
gem 'red-candle', '~> 1.3'
end
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ response = chat.with_schema(ProductSchema).ask "Analyze this product", with: "pr
* **Rails:** ActiveRecord integration with `acts_as_chat`
* **Async:** Fiber-based concurrency
* **Model registry:** 500+ models with capability detection and pricing
* **Providers:** OpenAI, Anthropic, Gemini, VertexAI, Bedrock, DeepSeek, Mistral, Ollama, OpenRouter, Perplexity, GPUStack, and any OpenAI-compatible API
* **Providers:** OpenAI, Anthropic, Gemini, VertexAI, Bedrock, DeepSeek, Mistral, Ollama, OpenRouter, Perplexity, GPUStack, [RedCandle](https://github.com/scientist-labs/red-candle), and any OpenAI-compatible API

## Installation

Expand Down
27 changes: 27 additions & 0 deletions docs/_advanced/models.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,33 @@ RubyLLM.models.refresh!(remote_only: true)

This is useful when you want to refresh only cloud-based models without querying local model servers.

### Dynamic Model Registration (Red Candle)

Some providers register their models dynamically at runtime rather than through the models.json file. Red Candle is one such provider - it registers its GGUF models when the gem is loaded.

**How Red Candle Models Work:**

1. **Not in models.json**: Red Candle models don't appear in the static models.json file since they're only available when the gem is installed.

2. **Dynamic Registration**: When ruby_llm.rb loads and Red Candle is available, it adds models to the in-memory registry:
```ruby
# This happens automatically in lib/ruby_llm.rb
RubyLLM::Providers::RedCandle.models.each do |model|
RubyLLM.models.instance_variable_get(:@models) << model
end
```

3. **Excluded from refresh!**: The `refresh!(remote_only: true)` flag excludes Red Candle and other local providers.

4. **Currently Supported Models**:
- `google/gemma-3-4b-it-qat-q4_0-gguf`
- `TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF`
- `TheBloke/Mistral-7B-Instruct-v0.2-GGUF`
- `Qwen/Qwen2.5-1.5B-Instruct-GGUF`
- `microsoft/Phi-3-mini-4k-instruct`

Red Candle models are only available when the gem is installed with the red_candle group enabled. See the [Configuration Guide]({% link _getting_started/configuration.md %}) for installation instructions.

**For Gem Development:**

The `rake models:update` task is designed for gem maintainers and updates the `models.json` file shipped with the gem:
Expand Down
32 changes: 32 additions & 0 deletions docs/_getting_started/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ RubyLLM.configure do |config|
config.ollama_api_base = 'http://localhost:11434/v1'
config.gpustack_api_base = ENV['GPUSTACK_API_BASE']
config.gpustack_api_key = ENV['GPUSTACK_API_KEY']
# Red Candle (optional - see below)

# AWS Bedrock (uses standard AWS credential chain if not set)
config.bedrock_api_key = ENV['AWS_ACCESS_KEY_ID']
Expand All @@ -91,6 +92,37 @@ end

These headers are optional and only needed for organization-specific billing or project tracking.

### Red Candle (Local GGUF Models)

Red Candle is an optional provider that enables local execution of quantized GGUF models. To use it, add the red-candle gem to your Gemfile:

```ruby
# Gemfile
gem 'ruby_llm'
gem 'red-candle' # Optional: for local GGUF model execution
```

Then install:

```bash
bundle install
```

Red Candle requires no API keys since it runs models locally. Some models may require HuggingFace authentication:

```bash
huggingface-cli login # Required for some gated models
```

See [Red Candle's HuggingFace guide](https://github.com/scientist-labs/red-candle/blob/main/docs/HUGGINGFACE.md) for details on authentication.

Once configured, you can use it like any other provider:

```ruby
chat = RubyLLM.chat(model: 'TheBloke/Mistral-7B-Instruct-v0.2-GGUF', provider: :red_candle)
response = chat.ask("Hello!")
```

## Custom Endpoints

### OpenAI-Compatible APIs
Expand Down
18 changes: 18 additions & 0 deletions docs/_reference/available-models.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ redirect_from:
- **OpenRouter**: Direct API
- **Others**: Local capabilities files


## Last Updated
{: .d-inline-block }

Expand Down Expand Up @@ -2491,3 +2492,20 @@ Models that generate embeddings:
| text-embedding-3-small | openai | - | - | In: $0.02, Out: $0.02 |
| text-embedding-ada-002 | openai | - | - | In: $0.10, Out: $0.10 |


## Local Providers

### Red Candle (5)

Red Candle enables local execution of quantized GGUF models. These models run on your machine with no API costs.

| Model | Provider | Context | Max Output | Standard Pricing (per 1M tokens) |
| :-- | :-- | --: | --: | :-- |
| google/gemma-3-4b-it-qat-q4_0-gguf | red_candle | 8192 | 512 | Free (local execution) |
| TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF | red_candle | 2048 | 512 | Free (local execution) |
| TheBloke/Mistral-7B-Instruct-v0.2-GGUF | red_candle | 32768 | 512 | Free (local execution) |
| Qwen/Qwen2.5-1.5B-Instruct-GGUF | red_candle | 32768 | 512 | Free (local execution) |
| microsoft/Phi-3-mini-4k-instruct | red_candle | 4096 | 512 | Free (local execution) |

> **Note:** Local providers (Ollama, GPUStack, Red Candle) register their models dynamically at runtime based on what's installed locally. Ollama and GPUStack models depend on what you've pulled or configured on your system. Red Candle requires the `red-candle` gem. See the [Configuration Guide]({% link _getting_started/configuration.md %}) for setup instructions.
{: .note }
5 changes: 4 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ permalink: /
<img src="https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/vertexai-color.svg" alt="VertexAI" class="logo-medium">
<img src="https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/vertexai-text.svg" alt="VertexAI" class="logo-small">
</div>
<div class="provider-logo">
<img src="https://raw.githubusercontent.com/scientist-labs/red-candle/refs/heads/main/docs/assets/red-candle-icon.svg" alt="red-candle" class="logo-medium">
<img src="https://raw.githubusercontent.com/scientist-labs/red-candle/refs/heads/main/docs/assets/red-candle-text.svg" alt="red-candle" class="logo-small">
</div>
</div>

<div class="badge-container">
Expand Down Expand Up @@ -204,4 +208,3 @@ end
chat = Chat.create! model_id: "claude-sonnet-4"
chat.ask "What's in this file?", with: "report.pdf"
```

4 changes: 4 additions & 0 deletions gemfiles/rails_7.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@ group :development do
gem "googleauth"
end

group :red_candle, optional: true do
gem "red-candle", "~> 1.2"
end

gemspec path: "../"
8 changes: 7 additions & 1 deletion gemfiles/rails_7.1.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,14 @@ GEM
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.3.0)
rake-compiler-dock (1.9.1)
rb_sys (0.9.117)
rake-compiler-dock (= 1.9.1)
rdoc (6.14.2)
erb
psych (>= 4.0.0)
red-candle (1.2.3)
rb_sys
regexp_parser (2.11.2)
reline (0.6.2)
io-console (~> 0.5)
Expand Down Expand Up @@ -384,7 +389,7 @@ GEM
zeitwerk (2.7.3)

PLATFORMS
arm64-darwin-22
arm64-darwin-24
x86_64-linux

DEPENDENCIES
Expand All @@ -406,6 +411,7 @@ DEPENDENCIES
pry (>= 0.14)
rails (~> 7.1.0)
rake (>= 13.0)
red-candle (~> 1.2)
reline
rspec (~> 3.12)
rubocop (>= 1.0)
Expand Down
4 changes: 4 additions & 0 deletions gemfiles/rails_7.2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@ group :development do
gem "googleauth"
end

group :red_candle, optional: true do
gem "red-candle", "~> 1.2"
end

gemspec path: "../"
8 changes: 7 additions & 1 deletion gemfiles/rails_7.2.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,14 @@ GEM
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.3.0)
rake-compiler-dock (1.9.1)
rb_sys (0.9.117)
rake-compiler-dock (= 1.9.1)
rdoc (6.14.2)
erb
psych (>= 4.0.0)
red-candle (1.2.3)
rb_sys
regexp_parser (2.11.2)
reline (0.6.2)
io-console (~> 0.5)
Expand Down Expand Up @@ -378,7 +383,7 @@ GEM
zeitwerk (2.7.3)

PLATFORMS
arm64-darwin-22
arm64-darwin-24
x86_64-linux

DEPENDENCIES
Expand All @@ -400,6 +405,7 @@ DEPENDENCIES
pry (>= 0.14)
rails (~> 7.2.0)
rake (>= 13.0)
red-candle (~> 1.2)
reline
rspec (~> 3.12)
rubocop (>= 1.0)
Expand Down
4 changes: 4 additions & 0 deletions gemfiles/rails_8.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@ group :development do
gem "googleauth"
end

group :red_candle, optional: true do
gem "red-candle", "~> 1.2"
end

gemspec path: "../"
8 changes: 7 additions & 1 deletion gemfiles/rails_8.0.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,14 @@ GEM
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.3.0)
rake-compiler-dock (1.9.1)
rb_sys (0.9.117)
rake-compiler-dock (= 1.9.1)
rdoc (6.14.2)
erb
psych (>= 4.0.0)
red-candle (1.2.3)
rb_sys
regexp_parser (2.11.2)
reline (0.6.2)
io-console (~> 0.5)
Expand Down Expand Up @@ -378,7 +383,7 @@ GEM
zeitwerk (2.7.3)

PLATFORMS
arm64-darwin-22
arm64-darwin-24
x86_64-linux

DEPENDENCIES
Expand All @@ -400,6 +405,7 @@ DEPENDENCIES
pry (>= 0.14)
rails (~> 8.0.0)
rake (>= 13.0)
red-candle (~> 1.2)
reline
rspec (~> 3.12)
rubocop (>= 1.0)
Expand Down
2 changes: 2 additions & 0 deletions lib/ruby_llm/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class Configuration
:gpustack_api_base,
:gpustack_api_key,
:mistral_api_key,
# Red Candle configuration
:red_candle_device,
# Default models
:default_model,
:default_embedding_model,
Expand Down
Loading