ruby_llm 2.0.0.rc3 → 2.0.0.rc4
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 +4 -4
- data/.rdoc_options +2 -2
- data/README.md +32 -21
- data/lib/generators/ruby_llm/upgrade/online_copy_migration/data.rb +9 -0
- data/lib/generators/ruby_llm/upgrade/online_copy_migration.rb +5 -1
- data/lib/generators/ruby_llm/upgrade/templates/backfill_v2_data.rb.tt +6 -2
- data/lib/generators/ruby_llm/upgrade/templates/finish_v2_upgrade.rb.tt +8 -2
- data/lib/generators/ruby_llm/upgrade/templates/ruby_llm_upgrade.rb.tt +1 -1
- data/lib/generators/ruby_llm/upgrade/templates/upgrade_initializer.rb.tt +1 -1
- data/lib/generators/ruby_llm/upgrade/upgrade_generator.rb +11 -0
- data/lib/generators/ruby_llm/upgrade/upgrade_migration.rb +2 -1
- data/lib/ruby_llm/batch.rb +2 -2
- data/lib/ruby_llm/chat.rb +2 -2
- data/lib/ruby_llm/embedding.rb +1 -1
- data/lib/ruby_llm/image.rb +1 -1
- data/lib/ruby_llm/models.json +1654 -1791
- data/lib/ruby_llm/moderation.rb +1 -1
- data/lib/ruby_llm/ocr.rb +1 -1
- data/lib/ruby_llm/protocols/anthropic/chat.rb +1 -6
- data/lib/ruby_llm/protocols/chat_completions/chat.rb +2 -11
- data/lib/ruby_llm/protocols/converse/chat.rb +0 -1
- data/lib/ruby_llm/protocols/responses/chat.rb +0 -10
- data/lib/ruby_llm/providers/openrouter/chat.rb +1 -5
- data/lib/ruby_llm/rerank.rb +1 -1
- data/lib/ruby_llm/speech.rb +1 -1
- data/lib/ruby_llm/transcription.rb +1 -1
- data/lib/ruby_llm/version.rb +1 -1
- data/lib/ruby_llm/video_job.rb +1 -1
- data/lib/ruby_llm.rb +1 -1
- metadata +6 -6
data/lib/ruby_llm/moderation.rb
CHANGED
|
@@ -104,7 +104,7 @@ module RubyLLM
|
|
|
104
104
|
empty_tokens = Tokens.new
|
|
105
105
|
payload = {
|
|
106
106
|
provider: provider_instance.slug,
|
|
107
|
-
provider_class: provider_instance.
|
|
107
|
+
provider_class: provider_instance.name,
|
|
108
108
|
model: model&.id,
|
|
109
109
|
model_info: model,
|
|
110
110
|
input: input,
|
data/lib/ruby_llm/ocr.rb
CHANGED
|
@@ -39,13 +39,12 @@ module RubyLLM
|
|
|
39
39
|
warn_unsupported_citations(model) if citations && !model.supports?(:citations)
|
|
40
40
|
tool_prefs ||= {}
|
|
41
41
|
system_messages, chat_messages = separate_messages(messages)
|
|
42
|
-
explicit_boundaries = cache_boundaries?(messages, caching:)
|
|
43
42
|
system_content = build_system_content(system_messages, caching:)
|
|
44
43
|
|
|
45
44
|
build_base_payload(chat_messages, model, stream, thinking, citations: citations, caching:,
|
|
46
45
|
max_output_tokens:).tap do |payload|
|
|
47
46
|
add_optional_fields(payload, system_content:, tools:, tool_prefs:, temperature:, schema:)
|
|
48
|
-
payload[:cache_control] = prompt_cache_control(caching) if caching
|
|
47
|
+
payload[:cache_control] = prompt_cache_control(caching) if caching
|
|
49
48
|
end
|
|
50
49
|
end
|
|
51
50
|
|
|
@@ -429,10 +428,6 @@ module RubyLLM
|
|
|
429
428
|
content_blocks.concat(Media.format_content(msg.content, msg.attachments, citations: citations))
|
|
430
429
|
end
|
|
431
430
|
|
|
432
|
-
def cache_boundaries?(messages, caching: nil)
|
|
433
|
-
caching != false && messages.any?(&:cache_until_here?)
|
|
434
|
-
end
|
|
435
|
-
|
|
436
431
|
def cache_boundary?(message, caching: nil)
|
|
437
432
|
caching != false && message.cache_until_here?
|
|
438
433
|
end
|
|
@@ -87,7 +87,7 @@ module RubyLLM
|
|
|
87
87
|
payload[:reasoning_effort] = effort if effort
|
|
88
88
|
|
|
89
89
|
payload[:stream_options] = { include_usage: true } if stream
|
|
90
|
-
apply_prompt_cache_params(payload,
|
|
90
|
+
apply_prompt_cache_params(payload, caching)
|
|
91
91
|
payload
|
|
92
92
|
end
|
|
93
93
|
|
|
@@ -250,11 +250,10 @@ module RubyLLM
|
|
|
250
250
|
end
|
|
251
251
|
end
|
|
252
252
|
|
|
253
|
-
def apply_prompt_cache_params(payload,
|
|
253
|
+
def apply_prompt_cache_params(payload, caching)
|
|
254
254
|
return unless openai_prompt_caching?
|
|
255
255
|
|
|
256
256
|
payload.merge!(prompt_cache_params(caching)) if caching
|
|
257
|
-
force_explicit_cache_mode(payload) if caching != false && cache_boundaries?(messages)
|
|
258
257
|
end
|
|
259
258
|
|
|
260
259
|
def openai_prompt_caching?
|
|
@@ -290,14 +289,6 @@ module RubyLLM
|
|
|
290
289
|
retention
|
|
291
290
|
end
|
|
292
291
|
|
|
293
|
-
def force_explicit_cache_mode(payload)
|
|
294
|
-
payload[:prompt_cache_options] = { mode: 'explicit' }.merge(payload[:prompt_cache_options] || {})
|
|
295
|
-
end
|
|
296
|
-
|
|
297
|
-
def cache_boundaries?(messages)
|
|
298
|
-
messages.any?(&:cache_until_here?)
|
|
299
|
-
end
|
|
300
|
-
|
|
301
292
|
def prompt_cache_options(caching)
|
|
302
293
|
options = caching.to_h.transform_keys(&:to_sym)
|
|
303
294
|
unsupported = options.keys - PROMPT_CACHE_OPTIONS
|
|
@@ -266,7 +266,6 @@ module RubyLLM
|
|
|
266
266
|
|
|
267
267
|
def automatic_cache_target(system_messages, chat_messages, caching)
|
|
268
268
|
return unless caching
|
|
269
|
-
return if (system_messages + chat_messages).any?(&:cache_until_here?)
|
|
270
269
|
|
|
271
270
|
(chat_messages.reverse + system_messages.reverse).find { |msg| cacheable_message?(msg) }
|
|
272
271
|
end
|
|
@@ -12,7 +12,6 @@ module RubyLLM
|
|
|
12
12
|
OPENAI_INLINE_FILE_LIMIT = 50 * 1024 * 1024
|
|
13
13
|
OPENAI_FILE_UPLOAD_LIMIT = 512 * 1024 * 1024
|
|
14
14
|
PROMPT_CACHE_OPTIONS = %i[key ttl mode retention].freeze
|
|
15
|
-
CACHE_BREAKPOINT_ROLES = %i[user system].freeze
|
|
16
15
|
|
|
17
16
|
module_function
|
|
18
17
|
|
|
@@ -47,7 +46,6 @@ module RubyLLM
|
|
|
47
46
|
payload[:reasoning] = { effort: effort } if effort
|
|
48
47
|
payload[:reasoning] = (payload[:reasoning] || {}).merge(summary: 'auto') if thinking&.display == :summarized
|
|
49
48
|
payload.merge!(prompt_cache_params(caching)) if caching
|
|
50
|
-
force_explicit_cache_mode(payload) if caching != false && cache_boundaries?(messages)
|
|
51
49
|
|
|
52
50
|
payload
|
|
53
51
|
end
|
|
@@ -225,14 +223,6 @@ module RubyLLM
|
|
|
225
223
|
retention
|
|
226
224
|
end
|
|
227
225
|
|
|
228
|
-
def force_explicit_cache_mode(payload)
|
|
229
|
-
payload[:prompt_cache_options] = { mode: 'explicit' }.merge(payload[:prompt_cache_options] || {})
|
|
230
|
-
end
|
|
231
|
-
|
|
232
|
-
def cache_boundaries?(messages)
|
|
233
|
-
messages.any? { |msg| msg.cache_until_here? && CACHE_BREAKPOINT_ROLES.include?(msg.role) }
|
|
234
|
-
end
|
|
235
|
-
|
|
236
226
|
def prompt_cache_options(caching)
|
|
237
227
|
options = caching.to_h.transform_keys(&:to_sym)
|
|
238
228
|
unsupported = options.keys - PROMPT_CACHE_OPTIONS
|
|
@@ -47,7 +47,7 @@ module RubyLLM
|
|
|
47
47
|
|
|
48
48
|
reasoning = build_reasoning(thinking)
|
|
49
49
|
payload[:reasoning] = reasoning if reasoning
|
|
50
|
-
payload[:cache_control] = prompt_cache_control(caching) if caching
|
|
50
|
+
payload[:cache_control] = prompt_cache_control(caching) if caching
|
|
51
51
|
payload
|
|
52
52
|
end
|
|
53
53
|
|
|
@@ -142,10 +142,6 @@ module RubyLLM
|
|
|
142
142
|
keys.map { |key| ":#{key}" }.join(', ')
|
|
143
143
|
end
|
|
144
144
|
|
|
145
|
-
def cache_boundaries?(messages)
|
|
146
|
-
messages.any?(&:cache_until_here?)
|
|
147
|
-
end
|
|
148
|
-
|
|
149
145
|
def openai_prompt_caching?
|
|
150
146
|
false
|
|
151
147
|
end
|
data/lib/ruby_llm/rerank.rb
CHANGED
data/lib/ruby_llm/speech.rb
CHANGED
|
@@ -132,7 +132,7 @@ module RubyLLM
|
|
|
132
132
|
empty_tokens = Tokens.new
|
|
133
133
|
payload = {
|
|
134
134
|
provider: provider_instance.slug,
|
|
135
|
-
provider_class: provider_instance.
|
|
135
|
+
provider_class: provider_instance.name,
|
|
136
136
|
model: model.id,
|
|
137
137
|
model_info: model,
|
|
138
138
|
language: language,
|
data/lib/ruby_llm/version.rb
CHANGED
data/lib/ruby_llm/video_job.rb
CHANGED
data/lib/ruby_llm.rb
CHANGED
|
@@ -44,7 +44,7 @@ loader.setup
|
|
|
44
44
|
|
|
45
45
|
# RubyLLM is an AI framework for Ruby and Rails. Build conversations and
|
|
46
46
|
# agents, generate media, process documents, and work with model providers
|
|
47
|
-
# through one Ruby API. The guides at https://rubyllm.com/
|
|
47
|
+
# through one Ruby API. The guides at https://rubyllm.com/ introduce
|
|
48
48
|
# each feature; this reference documents its classes, arguments, and results.
|
|
49
49
|
#
|
|
50
50
|
# RubyLLM.configure do |config|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby_llm
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.0.
|
|
4
|
+
version: 2.0.0.rc4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Carmine Paolino
|
|
@@ -612,24 +612,24 @@ metadata:
|
|
|
612
612
|
homepage_uri: https://rubyllm.com
|
|
613
613
|
source_code_uri: https://github.com/crmne/ruby_llm
|
|
614
614
|
changelog_uri: https://github.com/crmne/ruby_llm/releases
|
|
615
|
-
documentation_uri: https://rubyllm.com/
|
|
615
|
+
documentation_uri: https://rubyllm.com/
|
|
616
616
|
bug_tracker_uri: https://github.com/crmne/ruby_llm/issues
|
|
617
617
|
funding_uri: https://github.com/sponsors/crmne
|
|
618
618
|
rubygems_mfa_required: 'true'
|
|
619
619
|
post_install_message: |
|
|
620
|
-
RubyLLM 2.0.0.
|
|
620
|
+
RubyLLM 2.0.0.rc4
|
|
621
621
|
|
|
622
622
|
2.0 renames several APIs and changes what message content returns. Coming
|
|
623
623
|
from 1.x? Read the upgrade guide before you boot:
|
|
624
624
|
|
|
625
|
-
https://rubyllm.com/
|
|
625
|
+
https://rubyllm.com/upgrading/
|
|
626
626
|
|
|
627
627
|
The Rails upgrade uses forward-only preparation, backfill, and finish
|
|
628
628
|
phases, with cleanup later. Rename mode is the default; optional copy
|
|
629
629
|
mode supports a controlled return to 1.16. Read its requirements in the
|
|
630
630
|
upgrade guide and rehearse on a recent production snapshot.
|
|
631
631
|
|
|
632
|
-
Agent skill: https://rubyllm.com/
|
|
632
|
+
Agent skill: https://rubyllm.com/ai-coding-assistants/
|
|
633
633
|
rdoc_options: []
|
|
634
634
|
require_paths:
|
|
635
635
|
- lib
|
|
@@ -644,7 +644,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
644
644
|
- !ruby/object:Gem::Version
|
|
645
645
|
version: '0'
|
|
646
646
|
requirements: []
|
|
647
|
-
rubygems_version: 4.0.
|
|
647
|
+
rubygems_version: 4.0.20
|
|
648
648
|
specification_version: 4
|
|
649
649
|
summary: 'Build AI features the Ruby way: a delightful Ruby AI framework for every
|
|
650
650
|
major AI provider.'
|