Skip to content

Commit 1486a53

Browse files
authored
Merge pull request #15 from tpaulshippy/red-candle-community
2 parents 447a093 + 6edc393 commit 1486a53

34 files changed

+1615
-42
lines changed

CONTRIBUTING.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,39 @@ rake vcr:record[all] # Everything
5555

5656
Always check cassettes for leaked API keys before committing.
5757

58+
## Optional Dependencies
59+
60+
### Red Candle Provider
61+
62+
The Red Candle provider enables local LLM execution using quantized GGUF models. It requires a Rust toolchain, so it's optional for contributors.
63+
64+
**To work WITHOUT Red Candle (default):**
65+
```bash
66+
bundle install
67+
bundle exec rspec # Red Candle tests will be skipped
68+
```
69+
70+
**To work WITH Red Candle:**
71+
```bash
72+
# Enable the Red Candle gem group
73+
bundle config set --local with red_candle
74+
bundle install
75+
76+
# Run tests with stubbed Red Candle (fast, default)
77+
bundle exec rspec
78+
79+
# Run tests with real inference (slow, downloads models)
80+
RED_CANDLE_REAL_INFERENCE=true bundle exec rspec
81+
```
82+
83+
**To switch back to working without Red Candle:**
84+
```bash
85+
bundle config unset with
86+
bundle install
87+
```
88+
89+
The `bundle config` settings are stored in `.bundle/config` (gitignored), so each developer can choose their own setup without affecting others.
90+
5891
## Important Notes
5992

6093
* **Never edit `models.json`, `aliases.json`, or `available-models.md`** - they're auto-generated by `rake models`

Gemfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,9 @@ group :development do # rubocop:disable Metrics/BlockLength
4141
# Optional dependency for Vertex AI
4242
gem 'googleauth'
4343
end
44+
45+
# Optional group for Red Candle provider (requires Rust toolchain)
46+
# To include: bundle config set --local with red-candle
47+
group :red_candle, optional: true do
48+
gem 'red-candle', '~> 1.3'
49+
end

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ response = chat.with_schema(ProductSchema).ask "Analyze this product", with: "pr
127127
* **Rails:** ActiveRecord integration with `acts_as_chat`
128128
* **Async:** Fiber-based concurrency
129129
* **Model registry:** 500+ models with capability detection and pricing
130-
* **Providers:** OpenAI, Anthropic, Gemini, VertexAI, Bedrock, DeepSeek, Mistral, Ollama, OpenRouter, Perplexity, GPUStack, and any OpenAI-compatible API
130+
* **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
131131

132132
## Installation
133133

docs/_advanced/models.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,33 @@ RubyLLM.models.refresh!(remote_only: true)
9595

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

98+
### Dynamic Model Registration (Red Candle)
99+
100+
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.
101+
102+
**How Red Candle Models Work:**
103+
104+
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.
105+
106+
2. **Dynamic Registration**: When ruby_llm.rb loads and Red Candle is available, it adds models to the in-memory registry:
107+
```ruby
108+
# This happens automatically in lib/ruby_llm.rb
109+
RubyLLM::Providers::RedCandle.models.each do |model|
110+
RubyLLM.models.instance_variable_get(:@models) << model
111+
end
112+
```
113+
114+
3. **Excluded from refresh!**: The `refresh!(remote_only: true)` flag excludes Red Candle and other local providers.
115+
116+
4. **Currently Supported Models**:
117+
- `google/gemma-3-4b-it-qat-q4_0-gguf`
118+
- `TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF`
119+
- `TheBloke/Mistral-7B-Instruct-v0.2-GGUF`
120+
- `Qwen/Qwen2.5-1.5B-Instruct-GGUF`
121+
- `microsoft/Phi-3-mini-4k-instruct`
122+
123+
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.
124+
98125
**For Gem Development:**
99126

100127
The `rake models:update` task is designed for gem maintainers and updates the `models.json` file shipped with the gem:

docs/_getting_started/configuration.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ RubyLLM.configure do |config|
6565
config.ollama_api_base = 'http://localhost:11434/v1'
6666
config.gpustack_api_base = ENV['GPUSTACK_API_BASE']
6767
config.gpustack_api_key = ENV['GPUSTACK_API_KEY']
68+
# Red Candle (optional - see below)
6869

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

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

95+
### Red Candle (Local GGUF Models)
96+
97+
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:
98+
99+
```ruby
100+
# Gemfile
101+
gem 'ruby_llm'
102+
gem 'red-candle' # Optional: for local GGUF model execution
103+
```
104+
105+
Then install:
106+
107+
```bash
108+
bundle install
109+
```
110+
111+
Red Candle requires no API keys since it runs models locally. Some models may require HuggingFace authentication:
112+
113+
```bash
114+
huggingface-cli login # Required for some gated models
115+
```
116+
117+
See [Red Candle's HuggingFace guide](https://github.com/scientist-labs/red-candle/blob/main/docs/HUGGINGFACE.md) for details on authentication.
118+
119+
Once configured, you can use it like any other provider:
120+
121+
```ruby
122+
chat = RubyLLM.chat(model: 'TheBloke/Mistral-7B-Instruct-v0.2-GGUF', provider: :red_candle)
123+
response = chat.ask("Hello!")
124+
```
125+
94126
## Custom Endpoints
95127

96128
### OpenAI-Compatible APIs

docs/_reference/available-models.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ redirect_from:
2727
- **OpenRouter**: Direct API
2828
- **Others**: Local capabilities files
2929

30+
3031
## Last Updated
3132
{: .d-inline-block }
3233

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

2495+
2496+
## Local Providers
2497+
2498+
### Red Candle (5)
2499+
2500+
Red Candle enables local execution of quantized GGUF models. These models run on your machine with no API costs.
2501+
2502+
| Model | Provider | Context | Max Output | Standard Pricing (per 1M tokens) |
2503+
| :-- | :-- | --: | --: | :-- |
2504+
| google/gemma-3-4b-it-qat-q4_0-gguf | red_candle | 8192 | 512 | Free (local execution) |
2505+
| TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF | red_candle | 2048 | 512 | Free (local execution) |
2506+
| TheBloke/Mistral-7B-Instruct-v0.2-GGUF | red_candle | 32768 | 512 | Free (local execution) |
2507+
| Qwen/Qwen2.5-1.5B-Instruct-GGUF | red_candle | 32768 | 512 | Free (local execution) |
2508+
| microsoft/Phi-3-mini-4k-instruct | red_candle | 4096 | 512 | Free (local execution) |
2509+
2510+
> **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.
2511+
{: .note }

docs/index.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ permalink: /
6767
<img src="https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/vertexai-color.svg" alt="VertexAI" class="logo-medium">
6868
<img src="https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/vertexai-text.svg" alt="VertexAI" class="logo-small">
6969
</div>
70+
<div class="provider-logo">
71+
<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">
72+
<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">
73+
</div>
7074
</div>
7175

7276
<div class="badge-container">
@@ -205,4 +209,3 @@ end
205209
chat = Chat.create! model_id: "claude-sonnet-4"
206210
chat.ask "What's in this file?", with: "report.pdf"
207211
```
208-

gemfiles/rails_7.1.gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,8 @@ group :development do
3535
gem "googleauth"
3636
end
3737

38+
group :red_candle, optional: true do
39+
gem "red-candle", "~> 1.2"
40+
end
41+
3842
gemspec path: "../"

gemfiles/rails_7.1.gemfile.lock

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,14 @@ GEM
290290
zeitwerk (~> 2.6)
291291
rainbow (3.1.1)
292292
rake (13.3.0)
293+
rake-compiler-dock (1.9.1)
294+
rb_sys (0.9.117)
295+
rake-compiler-dock (= 1.9.1)
293296
rdoc (6.14.2)
294297
erb
295298
psych (>= 4.0.0)
299+
red-candle (1.2.3)
300+
rb_sys
296301
regexp_parser (2.11.2)
297302
reline (0.6.2)
298303
io-console (~> 0.5)
@@ -384,7 +389,7 @@ GEM
384389
zeitwerk (2.7.3)
385390

386391
PLATFORMS
387-
arm64-darwin-22
392+
arm64-darwin-24
388393
x86_64-linux
389394

390395
DEPENDENCIES
@@ -406,6 +411,7 @@ DEPENDENCIES
406411
pry (>= 0.14)
407412
rails (~> 7.1.0)
408413
rake (>= 13.0)
414+
red-candle (~> 1.2)
409415
reline
410416
rspec (~> 3.12)
411417
rubocop (>= 1.0)

gemfiles/rails_7.2.gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,8 @@ group :development do
3535
gem "googleauth"
3636
end
3737

38+
group :red_candle, optional: true do
39+
gem "red-candle", "~> 1.2"
40+
end
41+
3842
gemspec path: "../"

0 commit comments

Comments
 (0)