ruby_llm 1.6.1 → 1.6.3

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.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +73 -91
  3. data/lib/ruby_llm/active_record/acts_as.rb +3 -11
  4. data/lib/ruby_llm/aliases.json +4 -0
  5. data/lib/ruby_llm/aliases.rb +7 -25
  6. data/lib/ruby_llm/chat.rb +3 -19
  7. data/lib/ruby_llm/configuration.rb +1 -14
  8. data/lib/ruby_llm/content.rb +1 -3
  9. data/lib/ruby_llm/embedding.rb +1 -2
  10. data/lib/ruby_llm/error.rb +0 -10
  11. data/lib/ruby_llm/image.rb +0 -4
  12. data/lib/ruby_llm/message.rb +2 -4
  13. data/lib/ruby_llm/model/info.rb +0 -10
  14. data/lib/ruby_llm/model/pricing.rb +0 -3
  15. data/lib/ruby_llm/model/pricing_category.rb +0 -2
  16. data/lib/ruby_llm/model/pricing_tier.rb +0 -1
  17. data/lib/ruby_llm/models.json +668 -434
  18. data/lib/ruby_llm/models.rb +6 -18
  19. data/lib/ruby_llm/provider.rb +1 -5
  20. data/lib/ruby_llm/providers/anthropic/capabilities.rb +1 -46
  21. data/lib/ruby_llm/providers/anthropic/media.rb +0 -1
  22. data/lib/ruby_llm/providers/anthropic/tools.rb +0 -1
  23. data/lib/ruby_llm/providers/anthropic.rb +1 -2
  24. data/lib/ruby_llm/providers/bedrock/chat.rb +0 -2
  25. data/lib/ruby_llm/providers/bedrock/media.rb +0 -1
  26. data/lib/ruby_llm/providers/bedrock/models.rb +0 -2
  27. data/lib/ruby_llm/providers/bedrock/streaming/base.rb +1 -13
  28. data/lib/ruby_llm/providers/bedrock/streaming/content_extraction.rb +0 -7
  29. data/lib/ruby_llm/providers/bedrock/streaming/message_processing.rb +0 -12
  30. data/lib/ruby_llm/providers/bedrock/streaming/payload_processing.rb +0 -12
  31. data/lib/ruby_llm/providers/bedrock/streaming/prelude_handling.rb +0 -13
  32. data/lib/ruby_llm/providers/bedrock/streaming.rb +0 -18
  33. data/lib/ruby_llm/providers/bedrock.rb +1 -2
  34. data/lib/ruby_llm/providers/deepseek/capabilities.rb +1 -2
  35. data/lib/ruby_llm/providers/deepseek/chat.rb +0 -1
  36. data/lib/ruby_llm/providers/gemini/capabilities.rb +26 -101
  37. data/lib/ruby_llm/providers/gemini/chat.rb +12 -8
  38. data/lib/ruby_llm/providers/gemini/embeddings.rb +0 -2
  39. data/lib/ruby_llm/providers/gemini/images.rb +0 -1
  40. data/lib/ruby_llm/providers/gemini/media.rb +0 -1
  41. data/lib/ruby_llm/providers/gemini/models.rb +1 -2
  42. data/lib/ruby_llm/providers/gemini/streaming.rb +4 -1
  43. data/lib/ruby_llm/providers/gemini/tools.rb +0 -5
  44. data/lib/ruby_llm/providers/gpustack/chat.rb +0 -1
  45. data/lib/ruby_llm/providers/gpustack/models.rb +3 -4
  46. data/lib/ruby_llm/providers/mistral/capabilities.rb +2 -10
  47. data/lib/ruby_llm/providers/mistral/chat.rb +0 -2
  48. data/lib/ruby_llm/providers/mistral/embeddings.rb +0 -3
  49. data/lib/ruby_llm/providers/mistral/models.rb +0 -1
  50. data/lib/ruby_llm/providers/ollama/chat.rb +0 -1
  51. data/lib/ruby_llm/providers/ollama/media.rb +0 -1
  52. data/lib/ruby_llm/providers/openai/capabilities.rb +2 -17
  53. data/lib/ruby_llm/providers/openai/chat.rb +0 -3
  54. data/lib/ruby_llm/providers/openai/embeddings.rb +0 -3
  55. data/lib/ruby_llm/providers/openai/media.rb +0 -1
  56. data/lib/ruby_llm/providers/openai.rb +1 -3
  57. data/lib/ruby_llm/providers/openrouter/models.rb +1 -16
  58. data/lib/ruby_llm/providers/perplexity/capabilities.rb +0 -1
  59. data/lib/ruby_llm/providers/perplexity/chat.rb +0 -1
  60. data/lib/ruby_llm/providers/perplexity.rb +1 -5
  61. data/lib/ruby_llm/railtie.rb +0 -1
  62. data/lib/ruby_llm/stream_accumulator.rb +3 -5
  63. data/lib/ruby_llm/streaming.rb +16 -25
  64. data/lib/ruby_llm/tool.rb +2 -19
  65. data/lib/ruby_llm/tool_call.rb +0 -9
  66. data/lib/ruby_llm/version.rb +1 -1
  67. data/lib/ruby_llm.rb +0 -2
  68. data/lib/tasks/aliases.rake +7 -37
  69. data/lib/tasks/models_docs.rake +5 -15
  70. data/lib/tasks/models_update.rake +1 -1
  71. data/lib/tasks/vcr.rake +0 -7
  72. metadata +1 -1
@@ -6,12 +6,8 @@ require 'fileutils'
6
6
  namespace :models do
7
7
  desc 'Generate available models documentation'
8
8
  task :docs do
9
- FileUtils.mkdir_p('docs') # ensure output directory exists
10
-
11
- # Generate markdown content
9
+ FileUtils.mkdir_p('docs')
12
10
  output = generate_models_markdown
13
-
14
- # Write the output
15
11
  File.write('docs/_reference/available-models.md', output)
16
12
  puts 'Generated docs/_reference/available-models.md'
17
13
  end
@@ -86,7 +82,7 @@ def generate_models_markdown
86
82
  end
87
83
 
88
84
  def generate_provider_sections
89
- RubyLLM::Provider.providers.map do |provider, provider_class|
85
+ RubyLLM::Provider.providers.filter_map do |provider, provider_class|
90
86
  models = RubyLLM.models.by_provider(provider)
91
87
  next if models.none?
92
88
 
@@ -95,7 +91,7 @@ def generate_provider_sections
95
91
 
96
92
  #{models_table(models)}
97
93
  PROVIDER
98
- end.compact.join("\n\n")
94
+ end.join("\n\n")
99
95
  end
100
96
 
101
97
  def generate_capability_sections
@@ -107,7 +103,7 @@ def generate_capability_sections
107
103
  'Batch Processing' => RubyLLM.models.select { |m| m.capabilities.include?('batch') }
108
104
  }
109
105
 
110
- capabilities.map do |capability, models|
106
+ capabilities.filter_map do |capability, models|
111
107
  next if models.none?
112
108
 
113
109
  <<~CAPABILITY
@@ -115,13 +111,12 @@ def generate_capability_sections
115
111
 
116
112
  #{models_table(models)}
117
113
  CAPABILITY
118
- end.compact.join("\n\n")
114
+ end.join("\n\n")
119
115
  end
120
116
 
121
117
  def generate_modality_sections # rubocop:disable Metrics/PerceivedComplexity
122
118
  sections = []
123
119
 
124
- # Models that support vision/images
125
120
  vision_models = RubyLLM.models.select { |m| (m.modalities.input || []).include?('image') }
126
121
  if vision_models.any?
127
122
  sections << <<~SECTION
@@ -133,7 +128,6 @@ def generate_modality_sections # rubocop:disable Metrics/PerceivedComplexity
133
128
  SECTION
134
129
  end
135
130
 
136
- # Models that support audio
137
131
  audio_models = RubyLLM.models.select { |m| (m.modalities.input || []).include?('audio') }
138
132
  if audio_models.any?
139
133
  sections << <<~SECTION
@@ -145,7 +139,6 @@ def generate_modality_sections # rubocop:disable Metrics/PerceivedComplexity
145
139
  SECTION
146
140
  end
147
141
 
148
- # Models that support PDFs
149
142
  pdf_models = RubyLLM.models.select { |m| (m.modalities.input || []).include?('pdf') }
150
143
  if pdf_models.any?
151
144
  sections << <<~SECTION
@@ -157,7 +150,6 @@ def generate_modality_sections # rubocop:disable Metrics/PerceivedComplexity
157
150
  SECTION
158
151
  end
159
152
 
160
- # Models for embeddings
161
153
  embedding_models = RubyLLM.models.select { |m| (m.modalities.output || []).include?('embeddings') }
162
154
  if embedding_models.any?
163
155
  sections << <<~SECTION
@@ -179,7 +171,6 @@ def models_table(models)
179
171
  alignment = [':--', ':--', '--:', '--:', ':--']
180
172
 
181
173
  rows = models.sort_by { |m| [m.provider, m.name] }.map do |model|
182
- # Format pricing information
183
174
  pricing = standard_pricing_display(model)
184
175
 
185
176
  [
@@ -203,7 +194,6 @@ def models_table(models)
203
194
  end
204
195
 
205
196
  def standard_pricing_display(model)
206
- # Access pricing data using to_h to get the raw hash
207
197
  pricing_data = model.pricing.to_h[:text_tokens]&.dig(:standard) || {}
208
198
 
209
199
  if pricing_data.any?
@@ -61,7 +61,7 @@ def refresh_models
61
61
  end
62
62
 
63
63
  def validate_models!(models)
64
- schema_path = File.expand_path('../ruby_llm/models_schema.json', __dir__)
64
+ schema_path = RubyLLM::Models.schema_file
65
65
  models_data = models.all.map(&:to_h)
66
66
 
67
67
  validation_errors = JSON::Validator.fully_validate(schema_path, models_data)
data/lib/tasks/vcr.rake CHANGED
@@ -2,9 +2,7 @@
2
2
 
3
3
  require 'dotenv/load'
4
4
 
5
- # Helper functions at the top level
6
5
  def record_all_cassettes(cassette_dir)
7
- # Re-record all cassettes
8
6
  FileUtils.rm_rf(cassette_dir)
9
7
  FileUtils.mkdir_p(cassette_dir)
10
8
 
@@ -14,10 +12,8 @@ def record_all_cassettes(cassette_dir)
14
12
  end
15
13
 
16
14
  def record_for_providers(providers, cassette_dir)
17
- # Get the list of available providers from RubyLLM itself
18
15
  all_providers = RubyLLM::Provider.providers.keys.map(&:to_s)
19
16
 
20
- # Check for valid providers
21
17
  if providers.empty?
22
18
  puts "Please specify providers or 'all'. Example: rake vcr:record[openai,anthropic]"
23
19
  puts "Available providers: #{all_providers.join(', ')}"
@@ -31,7 +27,6 @@ def record_for_providers(providers, cassette_dir)
31
27
  return
32
28
  end
33
29
 
34
- # Find and delete matching cassettes
35
30
  cassettes_to_delete = find_matching_cassettes(cassette_dir, providers)
36
31
 
37
32
  if cassettes_to_delete.empty?
@@ -54,9 +49,7 @@ def find_matching_cassettes(dir, providers)
54
49
  Dir.glob("#{dir}/**/*.yml").each do |file|
55
50
  basename = File.basename(file)
56
51
 
57
- # Precise matching to avoid cross-provider confusion
58
52
  providers.each do |provider|
59
- # Match only exact provider prefixes
60
53
  next unless basename =~ /^[^_]*_#{provider}_/ || # For first section like "chat_openai_"
61
54
  basename =~ /_#{provider}_[^_]+_/ # For middle sections like "_openai_gpt4_"
62
55
 
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: 1.6.1
4
+ version: 1.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carmine Paolino