ruby_llm 2.0.0.rc1 → 2.0.0.rc2
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/README.md +2 -2
- data/lib/generators/ruby_llm/install/templates/create_messages_migration.rb.tt +0 -2
- data/lib/generators/ruby_llm/provider/templates/gem/gemfile.erb +1 -3
- data/lib/generators/ruby_llm/provider/templates/gem/gemspec.erb +1 -1
- data/lib/generators/ruby_llm/upgrade/templates/cleanup_v2_upgrade.rb.tt +1 -0
- data/lib/ruby_llm/active_record/attachment_helpers.rb +7 -1
- data/lib/ruby_llm/active_record/chat_methods.rb +5 -0
- data/lib/ruby_llm/models.json +2004 -395
- data/lib/ruby_llm/protocols/anthropic/chat.rb +18 -10
- data/lib/ruby_llm/protocols/anthropic/streaming.rb +4 -3
- data/lib/ruby_llm/protocols/anthropic.rb +3 -2
- data/lib/ruby_llm/protocols/converse/chat.rb +14 -4
- data/lib/ruby_llm/protocols/converse/streaming.rb +8 -0
- data/lib/ruby_llm/protocols/converse/thinking_stream.rb +56 -0
- data/lib/ruby_llm/providers/openrouter/chat.rb +1 -1
- data/lib/ruby_llm/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ef3c927159add14551e31ce03609ce42e150f9f161af9b68602f9c0e080fc31d
|
|
4
|
+
data.tar.gz: b894b99f6d6e541c643d76810b9542364f9d0beef4d00efd7b87b80d36c071af
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7dacd51baf534c7b226e1db52f09421b72d9939ec17af6cfd4b18db8bd7d9fbe2a22b488a8571d64f2194d46ed82ba045a726a309465b448f3a31a077a1f98c1
|
|
7
|
+
data.tar.gz: 90f866305245b759ae821cd8932d518c8648f5a3afce588028b820ced1f8aa7b05ac5de7c55a6b0f89e5aac80052d348fbc3fec8cf3b9efc83dec5effa32b260
|
data/README.md
CHANGED
|
@@ -38,7 +38,7 @@ In Rails, the API works on your own Chat and Message records, with Active Storag
|
|
|
38
38
|
|
|
39
39
|
## Show me the code
|
|
40
40
|
|
|
41
|
-
These examples use **2.0.0.
|
|
41
|
+
These examples use **2.0.0.rc2**. Follow [Getting Started](https://rubyllm.com/next/getting-started/) to install it and configure the providers you want to try.
|
|
42
42
|
|
|
43
43
|
```ruby
|
|
44
44
|
# Just ask questions
|
|
@@ -195,7 +195,7 @@ response.parsed
|
|
|
195
195
|
Install the 2.0 release candidate:
|
|
196
196
|
|
|
197
197
|
```bash
|
|
198
|
-
bundle add ruby_llm --version 2.0.0.
|
|
198
|
+
bundle add ruby_llm --version 2.0.0.rc2
|
|
199
199
|
```
|
|
200
200
|
|
|
201
201
|
Configure a provider in your script, or in `config/initializers/ruby_llm.rb` in Rails:
|
|
@@ -5,9 +5,7 @@ source 'https://rubygems.org'
|
|
|
5
5
|
gemspec
|
|
6
6
|
|
|
7
7
|
group :development do
|
|
8
|
-
if RUBY_ENGINE == 'ruby' && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.2')
|
|
9
|
-
gem 'archspec', github: 'crmne/archspec', tag: 'v1.1.0.rc1'
|
|
10
|
-
end
|
|
8
|
+
gem 'archspec' if RUBY_ENGINE == 'ruby' && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.2')
|
|
11
9
|
gem 'bundler', '>= 2.0'
|
|
12
10
|
gem 'dotenv'
|
|
13
11
|
gem 'flay'
|
|
@@ -46,6 +46,7 @@ class <%= cleanup_migration_class_name %> < ActiveRecord::Migration<%= migration
|
|
|
46
46
|
|
|
47
47
|
def remove_legacy_message_columns
|
|
48
48
|
table = :<%= message_table_name %>
|
|
49
|
+
remove_matching_indexes(table, :role)
|
|
49
50
|
reference_columns = %i[<%= v1_model_foreign_key %> <%= v1_tool_call_foreign_key %>]
|
|
50
51
|
reference_columns.each do |column|
|
|
51
52
|
remove_column_foreign_keys(table, column)
|
|
@@ -96,11 +96,17 @@ module RubyLLM
|
|
|
96
96
|
|
|
97
97
|
def attachment_sources
|
|
98
98
|
change = pending_attachment_change
|
|
99
|
-
return
|
|
99
|
+
return attachments_with_blobs.map { |attachment| [attachment, nil] } unless pending_attachment_change?(change)
|
|
100
100
|
|
|
101
101
|
change.attachments.zip(change.attachables)
|
|
102
102
|
end
|
|
103
103
|
|
|
104
|
+
def attachments_with_blobs
|
|
105
|
+
records = attachments.to_a
|
|
106
|
+
::ActiveRecord::Associations::Preloader.new(records: records, associations: :blob).call
|
|
107
|
+
records
|
|
108
|
+
end
|
|
109
|
+
|
|
104
110
|
def pending_attachment_change
|
|
105
111
|
attachment_changes['attachments'] if respond_to?(:attachment_changes)
|
|
106
112
|
end
|
|
@@ -777,11 +777,16 @@ module RubyLLM
|
|
|
777
777
|
return messages unless assoc.respond_to?(:klass)
|
|
778
778
|
|
|
779
779
|
associations = %i[ruby_llm_tool_calls ruby_llm_parent_tool_call ruby_llm_usages]
|
|
780
|
+
associations << { attachments_attachments: :blob } if attachment_association?(assoc.klass)
|
|
780
781
|
|
|
781
782
|
::ActiveRecord::Associations::Preloader.new(records: messages, associations: associations).call
|
|
782
783
|
messages
|
|
783
784
|
end
|
|
784
785
|
|
|
786
|
+
def attachment_association?(message_class)
|
|
787
|
+
message_class.reflect_on_association(:attachments_attachments).present?
|
|
788
|
+
end
|
|
789
|
+
|
|
785
790
|
def build_llm_chat
|
|
786
791
|
chat = (context || RubyLLM).chat(
|
|
787
792
|
model: model_id,
|