ruby_llm 2.0.0.rc2 → 2.0.0.rc3
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/upgrade/legacy_content_sql.rb +34 -0
- data/lib/generators/ruby_llm/upgrade/online_copy_migration/data.rb +332 -0
- data/lib/generators/ruby_llm/upgrade/online_copy_migration/journal.rb +171 -0
- data/lib/generators/ruby_llm/upgrade/online_copy_migration/verification.rb +197 -0
- data/lib/generators/ruby_llm/upgrade/online_copy_migration.rb +170 -0
- data/lib/generators/ruby_llm/upgrade/templates/backfill_v2_data.rb.tt +14 -11
- data/lib/generators/ruby_llm/upgrade/templates/cleanup_v2_upgrade.rb.tt +6 -6
- data/lib/generators/ruby_llm/upgrade/templates/finish_v2_upgrade.rb.tt +31 -5
- data/lib/generators/ruby_llm/upgrade/templates/prepare_v2_upgrade.rb.tt +16 -14
- data/lib/generators/ruby_llm/upgrade/templates/ruby_llm_upgrade.rb.tt +36 -7
- data/lib/generators/ruby_llm/upgrade/upgrade_generator.rb +15 -5
- data/lib/generators/ruby_llm/upgrade/upgrade_migration.rb +14 -0
- data/lib/ruby_llm/accounting/usage.rb +9 -0
- data/lib/ruby_llm/agent.rb +10 -9
- data/lib/ruby_llm/aliases.json +26 -4
- data/lib/ruby_llm/attachment.rb +5 -0
- data/lib/ruby_llm/chat.rb +4 -0
- data/lib/ruby_llm/message.rb +14 -5
- data/lib/ruby_llm/models.json +3820 -1346
- data/lib/ruby_llm/protocols/bedrock/async_videos.rb +2 -1
- data/lib/ruby_llm/protocols/chat_completions/rerank.rb +8 -1
- data/lib/ruby_llm/protocols/cohere/rerank.rb +8 -1
- data/lib/ruby_llm/protocols/gemini/embedding_batches.rb +5 -0
- data/lib/ruby_llm/protocols/interactions/tools.rb +3 -1
- data/lib/ruby_llm/providers/deepseek/responses.rb +0 -1
- data/lib/ruby_llm/providers/mistral/ocr.rb +5 -1
- data/lib/ruby_llm/version.rb +1 -1
- data/lib/tasks/ruby_llm.rake +1 -1
- metadata +7 -2
|
@@ -64,7 +64,8 @@ module RubyLLM
|
|
|
64
64
|
prefix = job.raw.dig('outputDataConfig', 's3OutputDataConfig', 's3Uri')
|
|
65
65
|
raise Error, 'Bedrock video job has no output S3 URI' unless prefix
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
prefix_length = (prefix.rindex(%r{[^/]}) || -1) + 1
|
|
68
|
+
uris = @provider.list_file_uris("#{prefix[0, prefix_length]}/")
|
|
68
69
|
videos = uris.select { |uri| uri.downcase.end_with?('.mp4') }
|
|
69
70
|
raise Error, 'Expected exactly one MP4 in the Bedrock video output' unless videos.one?
|
|
70
71
|
|
|
@@ -38,10 +38,13 @@ module RubyLLM
|
|
|
38
38
|
def parse_rerank_results(data, documents = [])
|
|
39
39
|
Array(data['results']).map do |result|
|
|
40
40
|
index = result['index']
|
|
41
|
+
unless valid_rerank_index?(index, documents)
|
|
42
|
+
raise Error, 'Rerank endpoint returned an invalid document index'
|
|
43
|
+
end
|
|
41
44
|
|
|
42
45
|
RubyLLM::Rerank::Result.new(
|
|
43
46
|
index: index,
|
|
44
|
-
document: rerank_document(result['document']) ||
|
|
47
|
+
document: rerank_document(result['document']) || documents[index],
|
|
45
48
|
score: result['relevance_score']
|
|
46
49
|
)
|
|
47
50
|
end
|
|
@@ -50,6 +53,10 @@ module RubyLLM
|
|
|
50
53
|
def rerank_document(document)
|
|
51
54
|
document.is_a?(Hash) ? document['text'] : document
|
|
52
55
|
end
|
|
56
|
+
|
|
57
|
+
def valid_rerank_index?(index, documents)
|
|
58
|
+
index.is_a?(Integer) && index.between?(0, documents.length - 1)
|
|
59
|
+
end
|
|
53
60
|
end
|
|
54
61
|
end
|
|
55
62
|
end
|
|
@@ -38,14 +38,21 @@ module RubyLLM
|
|
|
38
38
|
def parse_rerank_results(data, documents)
|
|
39
39
|
Array(data['results']).map do |result|
|
|
40
40
|
index = result['index']
|
|
41
|
+
unless valid_rerank_index?(index, documents)
|
|
42
|
+
raise Error, 'Cohere reranking returned an invalid document index'
|
|
43
|
+
end
|
|
41
44
|
|
|
42
45
|
RubyLLM::Rerank::Result.new(
|
|
43
46
|
index: index,
|
|
44
|
-
document: result.dig('document', 'text') ||
|
|
47
|
+
document: result.dig('document', 'text') || documents[index],
|
|
45
48
|
score: result['relevance_score']
|
|
46
49
|
)
|
|
47
50
|
end
|
|
48
51
|
end
|
|
52
|
+
|
|
53
|
+
def valid_rerank_index?(index, documents)
|
|
54
|
+
index.is_a?(Integer) && index.between?(0, documents.length - 1)
|
|
55
|
+
end
|
|
49
56
|
end
|
|
50
57
|
end
|
|
51
58
|
end
|
|
@@ -60,6 +60,11 @@ module RubyLLM
|
|
|
60
60
|
metadata = responses.first.fetch('metadata')
|
|
61
61
|
return if responses.size < metadata.fetch('embedding_count')
|
|
62
62
|
|
|
63
|
+
positions = responses.map { |inline| inline.dig('metadata', 'embedding_index') }
|
|
64
|
+
unless positions.sort == (0...responses.size).to_a
|
|
65
|
+
return [index, nil, batch_failure(key, 'Invalid or duplicate embedding record positions')]
|
|
66
|
+
end
|
|
67
|
+
|
|
63
68
|
vectors = embedding_batch_vectors(responses)
|
|
64
69
|
return [index, nil, batch_failure(key, 'Gemini returned no embedding')] unless vectors
|
|
65
70
|
|
|
@@ -31,7 +31,9 @@ module RubyLLM
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def parse_interaction_arguments(arguments)
|
|
34
|
-
arguments.is_a?(String)
|
|
34
|
+
return {} if arguments.nil? || (arguments.is_a?(String) && arguments.empty?)
|
|
35
|
+
|
|
36
|
+
arguments.is_a?(String) ? JSON.parse(arguments) : arguments
|
|
35
37
|
rescue JSON::ParserError => e
|
|
36
38
|
raise ToolCallParseError.new(finish_reason: :tool_calls), cause: e
|
|
37
39
|
end
|
|
@@ -8,7 +8,6 @@ module RubyLLM
|
|
|
8
8
|
# instead of summaries, both in responses and in the stream.
|
|
9
9
|
class Responses < Protocols::Responses
|
|
10
10
|
SERVER_TOOL_ALIASES = {
|
|
11
|
-
web_search: { tool: { type: 'web_search' } },
|
|
12
11
|
apply_patch: { tool: { type: 'custom', name: 'apply_patch' } }
|
|
13
12
|
}.freeze
|
|
14
13
|
|
|
@@ -22,7 +22,7 @@ module RubyLLM
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def ocr_document_part(attachment)
|
|
25
|
-
reference = attachment.url? ? attachment.source.to_s : attachment
|
|
25
|
+
reference = attachment.url? ? attachment.source.to_s : ocr_data_uri(attachment)
|
|
26
26
|
|
|
27
27
|
if attachment.image?
|
|
28
28
|
{ type: 'image_url', image_url: reference }
|
|
@@ -31,6 +31,10 @@ module RubyLLM
|
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
+
def ocr_data_uri(attachment)
|
|
35
|
+
"data:#{attachment.mime_type};base64,#{attachment.encoded}"
|
|
36
|
+
end
|
|
37
|
+
|
|
34
38
|
def parse_ocr_response(response, model:)
|
|
35
39
|
data = response.body
|
|
36
40
|
|
data/lib/ruby_llm/version.rb
CHANGED
data/lib/tasks/ruby_llm.rake
CHANGED
|
@@ -7,7 +7,7 @@ namespace :ruby_llm do
|
|
|
7
7
|
task action => :environment do
|
|
8
8
|
require 'generators/ruby_llm/upgrade/upgrade_migration'
|
|
9
9
|
|
|
10
|
-
RubyLLM::Generators::UpgradeMigration.
|
|
10
|
+
RubyLLM::Generators::UpgradeMigration.for.public_send(action)
|
|
11
11
|
puts "RubyLLM copy upgrade: #{action} completed"
|
|
12
12
|
end
|
|
13
13
|
end
|
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.rc3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Carmine Paolino
|
|
@@ -275,6 +275,11 @@ files:
|
|
|
275
275
|
- lib/generators/ruby_llm/tool/templates/tool_call.html.erb.tt
|
|
276
276
|
- lib/generators/ruby_llm/tool/templates/tool_result.html.erb.tt
|
|
277
277
|
- lib/generators/ruby_llm/tool/tool_generator.rb
|
|
278
|
+
- lib/generators/ruby_llm/upgrade/legacy_content_sql.rb
|
|
279
|
+
- lib/generators/ruby_llm/upgrade/online_copy_migration.rb
|
|
280
|
+
- lib/generators/ruby_llm/upgrade/online_copy_migration/data.rb
|
|
281
|
+
- lib/generators/ruby_llm/upgrade/online_copy_migration/journal.rb
|
|
282
|
+
- lib/generators/ruby_llm/upgrade/online_copy_migration/verification.rb
|
|
278
283
|
- lib/generators/ruby_llm/upgrade/templates/backfill_v2_data.rb.tt
|
|
279
284
|
- lib/generators/ruby_llm/upgrade/templates/cleanup_v2_upgrade.rb.tt
|
|
280
285
|
- lib/generators/ruby_llm/upgrade/templates/finish_v2_upgrade.rb.tt
|
|
@@ -612,7 +617,7 @@ metadata:
|
|
|
612
617
|
funding_uri: https://github.com/sponsors/crmne
|
|
613
618
|
rubygems_mfa_required: 'true'
|
|
614
619
|
post_install_message: |
|
|
615
|
-
RubyLLM 2.0.0.
|
|
620
|
+
RubyLLM 2.0.0.rc3
|
|
616
621
|
|
|
617
622
|
2.0 renames several APIs and changes what message content returns. Coming
|
|
618
623
|
from 1.x? Read the upgrade guide before you boot:
|