ruby_llm 1.3.0rc1 → 1.3.1

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 (54) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -9
  3. data/lib/ruby_llm/active_record/acts_as.rb +67 -148
  4. data/lib/ruby_llm/aliases.json +178 -42
  5. data/lib/ruby_llm/attachment.rb +164 -0
  6. data/lib/ruby_llm/chat.rb +12 -4
  7. data/lib/ruby_llm/configuration.rb +6 -1
  8. data/lib/ruby_llm/connection.rb +28 -2
  9. data/lib/ruby_llm/content.rb +9 -40
  10. data/lib/ruby_llm/error.rb +1 -0
  11. data/lib/ruby_llm/image.rb +2 -3
  12. data/lib/ruby_llm/message.rb +2 -2
  13. data/lib/ruby_llm/mime_type.rb +67 -0
  14. data/lib/ruby_llm/model/info.rb +101 -0
  15. data/lib/ruby_llm/model/modalities.rb +22 -0
  16. data/lib/ruby_llm/model/pricing.rb +51 -0
  17. data/lib/ruby_llm/model/pricing_category.rb +48 -0
  18. data/lib/ruby_llm/model/pricing_tier.rb +34 -0
  19. data/lib/ruby_llm/model.rb +7 -0
  20. data/lib/ruby_llm/models.json +2646 -2201
  21. data/lib/ruby_llm/models.rb +20 -20
  22. data/lib/ruby_llm/provider.rb +1 -1
  23. data/lib/ruby_llm/providers/anthropic/media.rb +14 -3
  24. data/lib/ruby_llm/providers/anthropic/models.rb +1 -1
  25. data/lib/ruby_llm/providers/anthropic/tools.rb +5 -4
  26. data/lib/ruby_llm/providers/bedrock/media.rb +7 -4
  27. data/lib/ruby_llm/providers/bedrock/models.rb +2 -2
  28. data/lib/ruby_llm/providers/bedrock/streaming/prelude_handling.rb +3 -3
  29. data/lib/ruby_llm/providers/gemini/images.rb +3 -2
  30. data/lib/ruby_llm/providers/gemini/media.rb +12 -24
  31. data/lib/ruby_llm/providers/gemini/models.rb +1 -1
  32. data/lib/ruby_llm/providers/ollama/media.rb +8 -4
  33. data/lib/ruby_llm/providers/openai/capabilities.rb +5 -2
  34. data/lib/ruby_llm/providers/openai/chat.rb +12 -8
  35. data/lib/ruby_llm/providers/openai/images.rb +3 -2
  36. data/lib/ruby_llm/providers/openai/media.rb +18 -8
  37. data/lib/ruby_llm/providers/openai/models.rb +1 -1
  38. data/lib/ruby_llm/providers/openrouter/models.rb +1 -1
  39. data/lib/ruby_llm/streaming.rb +46 -11
  40. data/lib/ruby_llm/tool.rb +8 -8
  41. data/lib/ruby_llm/utils.rb +14 -9
  42. data/lib/ruby_llm/version.rb +1 -1
  43. data/lib/ruby_llm.rb +1 -1
  44. data/lib/tasks/aliases.rake +235 -0
  45. data/lib/tasks/models_docs.rake +13 -7
  46. data/lib/tasks/release.rake +32 -0
  47. metadata +40 -25
  48. data/lib/ruby_llm/attachments/audio.rb +0 -12
  49. data/lib/ruby_llm/attachments/image.rb +0 -9
  50. data/lib/ruby_llm/attachments/pdf.rb +0 -9
  51. data/lib/ruby_llm/attachments.rb +0 -78
  52. data/lib/ruby_llm/mime_types.rb +0 -713
  53. data/lib/ruby_llm/model_info.rb +0 -237
  54. data/lib/tasks/{models.rake → models_update.rake} +13 -13
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyLLM
4
+ module Model
5
+ # Represents pricing tiers for different usage categories (standard and batch)
6
+ class PricingCategory
7
+ attr_reader :standard, :batch
8
+
9
+ def initialize(data = {})
10
+ @standard = PricingTier.new(data[:standard] || {}) unless empty_tier?(data[:standard])
11
+ @batch = PricingTier.new(data[:batch] || {}) unless empty_tier?(data[:batch])
12
+ end
13
+
14
+ # Shorthand methods that default to standard tier
15
+ def input
16
+ standard&.input_per_million
17
+ end
18
+
19
+ def output
20
+ standard&.output_per_million
21
+ end
22
+
23
+ def cached_input
24
+ standard&.cached_input_per_million
25
+ end
26
+
27
+ # Get value for a specific tier
28
+ def [](key)
29
+ key == :batch ? batch : standard
30
+ end
31
+
32
+ def to_h
33
+ result = {}
34
+ result[:standard] = standard.to_h if standard
35
+ result[:batch] = batch.to_h if batch
36
+ result
37
+ end
38
+
39
+ private
40
+
41
+ def empty_tier?(tier_data)
42
+ return true unless tier_data
43
+
44
+ tier_data.values.all? { |v| v.nil? || v == 0.0 }
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyLLM
4
+ module Model
5
+ # A dynamic class for storing non-zero pricing values with flexible attribute access
6
+ class PricingTier
7
+ def initialize(data = {})
8
+ @values = {}
9
+
10
+ # Only store non-zero values
11
+ data.each do |key, value|
12
+ @values[key.to_sym] = value if value && value != 0.0
13
+ end
14
+ end
15
+
16
+ def method_missing(method, *args)
17
+ if method.to_s.end_with?('=')
18
+ key = method.to_s.chomp('=').to_sym
19
+ @values[key] = args.first if args.first && args.first != 0.0
20
+ elsif @values.key?(method)
21
+ @values[method]
22
+ end
23
+ end
24
+
25
+ def respond_to_missing?(method, include_private = false)
26
+ method.to_s.end_with?('=') || @values.key?(method.to_sym) || super
27
+ end
28
+
29
+ def to_h
30
+ @values
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyLLM
4
+ # Model-related classes for working with LLM models
5
+ module Model
6
+ end
7
+ end