ruby_llm 1.0.0 → 1.1.0rc1

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 (64) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +58 -19
  3. data/lib/ruby_llm/active_record/acts_as.rb +46 -7
  4. data/lib/ruby_llm/aliases.json +65 -0
  5. data/lib/ruby_llm/aliases.rb +56 -0
  6. data/lib/ruby_llm/chat.rb +11 -10
  7. data/lib/ruby_llm/configuration.rb +4 -0
  8. data/lib/ruby_llm/error.rb +15 -4
  9. data/lib/ruby_llm/models.json +1489 -283
  10. data/lib/ruby_llm/models.rb +57 -22
  11. data/lib/ruby_llm/provider.rb +44 -41
  12. data/lib/ruby_llm/providers/anthropic/capabilities.rb +8 -9
  13. data/lib/ruby_llm/providers/anthropic/chat.rb +31 -4
  14. data/lib/ruby_llm/providers/anthropic/streaming.rb +12 -6
  15. data/lib/ruby_llm/providers/anthropic.rb +4 -0
  16. data/lib/ruby_llm/providers/bedrock/capabilities.rb +168 -0
  17. data/lib/ruby_llm/providers/bedrock/chat.rb +108 -0
  18. data/lib/ruby_llm/providers/bedrock/models.rb +84 -0
  19. data/lib/ruby_llm/providers/bedrock/signing.rb +831 -0
  20. data/lib/ruby_llm/providers/bedrock/streaming/base.rb +46 -0
  21. data/lib/ruby_llm/providers/bedrock/streaming/content_extraction.rb +63 -0
  22. data/lib/ruby_llm/providers/bedrock/streaming/message_processing.rb +79 -0
  23. data/lib/ruby_llm/providers/bedrock/streaming/payload_processing.rb +90 -0
  24. data/lib/ruby_llm/providers/bedrock/streaming/prelude_handling.rb +91 -0
  25. data/lib/ruby_llm/providers/bedrock/streaming.rb +36 -0
  26. data/lib/ruby_llm/providers/bedrock.rb +83 -0
  27. data/lib/ruby_llm/providers/deepseek/chat.rb +17 -0
  28. data/lib/ruby_llm/providers/deepseek.rb +5 -0
  29. data/lib/ruby_llm/providers/gemini/capabilities.rb +50 -34
  30. data/lib/ruby_llm/providers/gemini/chat.rb +8 -15
  31. data/lib/ruby_llm/providers/gemini/images.rb +5 -10
  32. data/lib/ruby_llm/providers/gemini/models.rb +0 -8
  33. data/lib/ruby_llm/providers/gemini/streaming.rb +35 -76
  34. data/lib/ruby_llm/providers/gemini/tools.rb +12 -12
  35. data/lib/ruby_llm/providers/gemini.rb +4 -0
  36. data/lib/ruby_llm/providers/openai/capabilities.rb +154 -177
  37. data/lib/ruby_llm/providers/openai/streaming.rb +9 -13
  38. data/lib/ruby_llm/providers/openai.rb +4 -0
  39. data/lib/ruby_llm/streaming.rb +96 -0
  40. data/lib/ruby_llm/tool.rb +15 -7
  41. data/lib/ruby_llm/version.rb +1 -1
  42. data/lib/ruby_llm.rb +8 -3
  43. data/lib/tasks/browser_helper.rb +97 -0
  44. data/lib/tasks/capability_generator.rb +123 -0
  45. data/lib/tasks/capability_scraper.rb +224 -0
  46. data/lib/tasks/cli_helper.rb +22 -0
  47. data/lib/tasks/code_validator.rb +29 -0
  48. data/lib/tasks/model_updater.rb +66 -0
  49. data/lib/tasks/models.rake +28 -197
  50. data/lib/tasks/vcr.rake +97 -0
  51. metadata +42 -19
  52. data/.github/workflows/cicd.yml +0 -109
  53. data/.github/workflows/docs.yml +0 -53
  54. data/.gitignore +0 -58
  55. data/.overcommit.yml +0 -26
  56. data/.rspec +0 -3
  57. data/.rspec_status +0 -50
  58. data/.rubocop.yml +0 -10
  59. data/.yardopts +0 -12
  60. data/Gemfile +0 -32
  61. data/Rakefile +0 -9
  62. data/bin/console +0 -17
  63. data/bin/setup +0 -6
  64. data/ruby_llm.gemspec +0 -43
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyLLM
4
+ module Providers
5
+ module Bedrock
6
+ # Models methods for the AWS Bedrock API implementation
7
+ module Models
8
+ def list_models
9
+ @connection = nil # reset connection since base url is different
10
+ @api_base = "https://bedrock.#{RubyLLM.config.bedrock_region}.amazonaws.com"
11
+ full_models_url = "#{@api_base}/#{models_url}"
12
+ signature = sign_request(full_models_url, method: :get)
13
+ response = connection.get(models_url) do |req|
14
+ req.headers.merge! signature.headers
15
+ end
16
+ @connection = nil # reset connection since base url is different
17
+
18
+ parse_list_models_response(response, slug, capabilities)
19
+ end
20
+
21
+ module_function
22
+
23
+ def models_url
24
+ 'foundation-models'
25
+ end
26
+
27
+ def parse_list_models_response(response, slug, capabilities)
28
+ data = response.body['modelSummaries'] || []
29
+ data.filter { |model| model['modelId'].include?('claude') }
30
+ .map { |model| create_model_info(model, slug, capabilities) }
31
+ end
32
+
33
+ def create_model_info(model, slug, capabilities)
34
+ model_id = model['modelId']
35
+ ModelInfo.new(
36
+ **base_model_attributes(model_id, model, slug),
37
+ **capability_attributes(model_id, capabilities),
38
+ **pricing_attributes(model_id, capabilities),
39
+ metadata: build_metadata(model)
40
+ )
41
+ end
42
+
43
+ def base_model_attributes(model_id, model, slug)
44
+ {
45
+ id: model_id,
46
+ created_at: nil,
47
+ display_name: model['modelName'] || capabilities.format_display_name(model_id),
48
+ provider: slug
49
+ }
50
+ end
51
+
52
+ def capability_attributes(model_id, capabilities)
53
+ {
54
+ context_window: capabilities.context_window_for(model_id),
55
+ max_tokens: capabilities.max_tokens_for(model_id),
56
+ type: capabilities.model_type(model_id),
57
+ family: capabilities.model_family(model_id).to_s,
58
+ supports_vision: capabilities.supports_vision?(model_id),
59
+ supports_functions: capabilities.supports_functions?(model_id),
60
+ supports_json_mode: capabilities.supports_json_mode?(model_id)
61
+ }
62
+ end
63
+
64
+ def pricing_attributes(model_id, capabilities)
65
+ {
66
+ input_price_per_million: capabilities.input_price_for(model_id),
67
+ output_price_per_million: capabilities.output_price_for(model_id)
68
+ }
69
+ end
70
+
71
+ def build_metadata(model)
72
+ {
73
+ provider_name: model['providerName'],
74
+ customizations_supported: model['customizationsSupported'] || [],
75
+ inference_configurations: model['inferenceTypesSupported'] || [],
76
+ response_streaming_supported: model['responseStreamingSupported'] || false,
77
+ input_modalities: model['inputModalities'] || [],
78
+ output_modalities: model['outputModalities'] || []
79
+ }
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end