ruby_llm_community 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 91657c36438fabeadbfa5bc881be1d9c0750916511e54624627c11478a7c8603
4
- data.tar.gz: 2cf908a30159a970a4a973356ae60ef3844ffb507fe0bf1a567c11d1ecfa1e46
3
+ metadata.gz: 867ea1c17955648ccfc017acdcce2ba4710d452cca065657a8a527cec7f36cb7
4
+ data.tar.gz: 57f6401b2a0892f36885d5c4806587f6ed6f17f5cc7572b6a484f63074167b4e
5
5
  SHA512:
6
- metadata.gz: 4c1cd8a73e001af382db8868d2c1037efe9e0bc411a559fdc36daa383897f2ba33aa42c6a4630e619c152f6879fd1e4a62a10e1c9c3a89a6745934db4c4b080d
7
- data.tar.gz: 9a4391b67d16d171c35e9def92c0fd42d059c072ad03f148c14d0238cb5c59e00775fd42133417f086203bad228fd7d7b4b149f4190e93d1afd9e2bf78179531
6
+ metadata.gz: e542c506cb9591aa561d062197a2cc3d013be6ec30e35c0b2279084b9f04fbd6451de9db33a58826a5440fd953d069b636a1d3ff7c5605961561af72de376dbe
7
+ data.tar.gz: b7155e89145f0be7f6305baefd4286dd7ee7b948bd66ca685d8787309a755fa93852fb32db2639d9af5200b86a33010ab717c1705faa7932a5a17b178d39597c
data/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  Battle tested at [<picture><source media="(prefers-color-scheme: dark)" srcset="https://chatwithwork.com/logotype-dark.svg"><img src="https://chatwithwork.com/logotype.svg" alt="Chat with Work" height="30" align="absmiddle"></picture>](https://chatwithwork.com) — *Claude Code for your documents*
11
11
 
12
- [![Gem Version](https://badge.fury.io/rb/ruby_llm.svg?a=9)](https://badge.fury.io/rb/ruby_llm)
12
+ [![Gem Version](https://badge.fury.io/rb/ruby_llm.svg?a=10)](https://badge.fury.io/rb/ruby_llm)
13
13
  [![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)
14
14
  [![Gem Downloads](https://img.shields.io/gem/dt/ruby_llm)](https://rubygems.org/gems/ruby_llm)
15
15
  [![codecov](https://codecov.io/gh/crmne/ruby_llm/branch/main/graph/badge.svg?a=2)](https://codecov.io/gh/crmne/ruby_llm)
@@ -40,6 +40,7 @@ Some examples --
40
40
  - Image editing for Gemini and OpenAI
41
41
  - Responses API for OpenAI
42
42
  - xAI provider that supports Grok 2, Grok 3, Grok 4, and Grok Code
43
+ - Red Candle provider
43
44
 
44
45
  This project is intended to be compatible with RubyLLM. I will attempt to keep it up to date as Carmine pushes commits often.
45
46
 
@@ -84,6 +85,11 @@ RubyLLM.paint "a sunset over mountains in watercolor style"
84
85
  RubyLLM.embed "Ruby is elegant and expressive"
85
86
  ```
86
87
 
88
+ ```ruby
89
+ # Moderate content for safety
90
+ RubyLLM.moderate("Check if this text is safe").flagged? # => false
91
+ ```
92
+
87
93
  ```ruby
88
94
  # Let AI use your code
89
95
  class Weather < RubyLLM::Tool
@@ -121,13 +127,14 @@ response = chat.with_schema(ProductSchema).ask "Analyze this product", with: "pr
121
127
  * **Documents:** Extract from PDFs, CSVs, JSON, any file type
122
128
  * **Image generation:** Create images with `RubyLLM.paint`
123
129
  * **Embeddings:** Vector search with `RubyLLM.embed`
130
+ * **Moderation:** Content safety with `RubyLLM.moderate`
124
131
  * **Tools:** Let AI call your Ruby methods
125
132
  * **Structured output:** JSON schemas that just work
126
133
  * **Streaming:** Real-time responses with blocks
127
134
  * **Rails:** ActiveRecord integration with `acts_as_chat`
128
135
  * **Async:** Fiber-based concurrency
129
136
  * **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
137
+ * **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
131
138
 
132
139
  ## Installation
133
140
 
@@ -148,7 +155,11 @@ end
148
155
  ## Rails
149
156
 
150
157
  ```bash
158
+ # Install database models
151
159
  rails generate ruby_llm:install
160
+
161
+ # Add chat UI (optional)
162
+ rails generate ruby_llm:chat_ui
152
163
  ```
153
164
 
154
165
  ```ruby
@@ -156,10 +167,12 @@ class Chat < ApplicationRecord
156
167
  acts_as_chat
157
168
  end
158
169
 
159
- chat = Chat.create! model_id: "claude-sonnet-4"
170
+ chat = Chat.create! model: "claude-sonnet-4"
160
171
  chat.ask "What's in this file?", with: "report.pdf"
161
172
  ```
162
173
 
174
+ Visit `http://localhost:3000/chats` for a ready-to-use chat interface!
175
+
163
176
  ## Documentation
164
177
 
165
178
  [rubyllm.com](https://rubyllm.com)
@@ -32,12 +32,12 @@ module RubyLLM
32
32
  migration_template 'create_chats_migration.rb.tt',
33
33
  "db/migrate/create_#{chat_table_name}.rb"
34
34
 
35
- # Then create messages table (must come before tool_calls due to foreign key)
35
+ # Then create messages table
36
36
  sleep 1 # Ensure different timestamp
37
37
  migration_template 'create_messages_migration.rb.tt',
38
38
  "db/migrate/create_#{message_table_name}.rb"
39
39
 
40
- # Then create tool_calls table (references messages)
40
+ # Then create tool_calls table
41
41
  sleep 1 # Ensure different timestamp
42
42
  migration_template 'create_tool_calls_migration.rb.tt',
43
43
  "db/migrate/create_#{tool_call_table_name}.rb"
@@ -46,6 +46,12 @@ module RubyLLM
46
46
  sleep 1 # Ensure different timestamp
47
47
  migration_template 'create_models_migration.rb.tt',
48
48
  "db/migrate/create_#{model_table_name}.rb"
49
+
50
+ # Add references to chats, tool_calls and messages.
51
+ sleep 1 # Ensure different timestamp
52
+ migration_template 'add_references_to_chats_tool_calls_and_messages_migration.rb.tt',
53
+ 'db/migrate/add_references_to_' \
54
+ "#{chat_table_name}_#{tool_call_table_name}_and_#{message_table_name}.rb"
49
55
  end
50
56
 
51
57
  def create_model_files
@@ -0,0 +1,9 @@
1
+ class AddReferencesTo<%= "#{chat_model_name.gsub('::', '').pluralize}#{tool_call_model_name.gsub('::', '').pluralize}And#{message_model_name.gsub('::', '').pluralize}" %> < ActiveRecord::Migration<%= migration_version %>
2
+ def change
3
+ add_reference :<%= chat_table_name %>, :<%= model_table_name.singularize %>, foreign_key: true
4
+ add_reference :<%= tool_call_table_name %>, :<%= message_table_name.singularize %>, null: false, foreign_key: true
5
+ add_reference :<%= message_table_name %>, :<%= chat_table_name.singularize %>, null: false, foreign_key: true
6
+ add_reference :<%= message_table_name %>, :<%= model_table_name.singularize %>, foreign_key: true
7
+ add_reference :<%= message_table_name %>, :<%= tool_call_table_name.singularize %>, foreign_key: true
8
+ end
9
+ end
@@ -1,7 +1,6 @@
1
1
  class Create<%= chat_model_name.gsub('::', '').pluralize %> < ActiveRecord::Migration<%= migration_version %>
2
2
  def change
3
3
  create_table :<%= chat_table_name %> do |t|
4
- t.references :<%= model_table_name.singularize %>, foreign_key: true
5
4
  t.timestamps
6
5
  end
7
6
  end
@@ -1,13 +1,10 @@
1
1
  class Create<%= message_model_name.gsub('::', '').pluralize %> < ActiveRecord::Migration<%= migration_version %>
2
2
  def change
3
3
  create_table :<%= message_table_name %> do |t|
4
- t.references :<%= chat_table_name.singularize %>, null: false, foreign_key: true
5
4
  t.string :role, null: false
6
5
  t.text :content
7
- t.references :<%= model_table_name.singularize %>, foreign_key: true
8
6
  t.integer :input_tokens
9
7
  t.integer :output_tokens
10
- t.references :<%= tool_call_table_name.singularize %>, foreign_key: true
11
8
  t.timestamps
12
9
  end
13
10
 
@@ -2,7 +2,6 @@
2
2
  class Create<%= tool_call_model_name.gsub('::', '').pluralize %> < ActiveRecord::Migration<%= migration_version %>
3
3
  def change
4
4
  create_table :<%= tool_call_table_name %> do |t|
5
- t.references :<%= message_table_name.singularize %>, null: false, foreign_key: true
6
5
  t.string :tool_call_id, null: false
7
6
  t.string :name, null: false
8
7
  t.<%= postgresql? ? 'jsonb' : 'json' %> :arguments, default: {}
@@ -24,9 +24,12 @@ module RubyLLM
24
24
  :gpustack_api_base,
25
25
  :gpustack_api_key,
26
26
  :mistral_api_key,
27
+ # Red Candle configuration
28
+ :red_candle_device,
27
29
  # Default models
28
30
  :default_model,
29
31
  :default_embedding_model,
32
+ :default_moderation_model,
30
33
  :default_image_model,
31
34
  # Model registry
32
35
  :model_registry_class,
@@ -55,6 +58,7 @@ module RubyLLM
55
58
 
56
59
  @default_model = 'gpt-4.1-nano'
57
60
  @default_embedding_model = 'text-embedding-3-small'
61
+ @default_moderation_model = 'omni-moderation-latest'
58
62
  @default_image_model = 'gpt-image-1'
59
63
 
60
64
  @model_registry_class = 'Model'