ruby_llm 1.9.0 → 1.9.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.
@@ -10,7 +10,7 @@ module RubyLLM
10
10
  def format_content(content) # rubocop:disable Metrics/PerceivedComplexity
11
11
  return content.value if content.is_a?(RubyLLM::Content::Raw)
12
12
  return [format_text(content.to_json)] if content.is_a?(Hash) || content.is_a?(Array)
13
- return [format_text(content)] unless content.is_a?(Content)
13
+ return [format_text(content)] unless content.is_a?(RubyLLM::Content)
14
14
 
15
15
  parts = []
16
16
  parts << format_text(content.text) if content.text
@@ -20,9 +20,14 @@ module RubyLLM
20
20
  end
21
21
 
22
22
  def headers
23
- {
24
- 'Authorization' => "Bearer #{access_token}"
25
- }
23
+ if defined?(VCR) && !VCR.current_cassette.recording?
24
+ { 'Authorization' => 'Bearer test-token' }
25
+ else
26
+ initialize_authorizer unless @authorizer
27
+ @authorizer.apply({})
28
+ end
29
+ rescue Google::Auth::AuthorizationError => e
30
+ raise UnauthorizedError.new(nil, "Invalid Google Cloud credentials for Vertex AI: #{e.message}")
26
31
  end
27
32
 
28
33
  class << self
@@ -33,15 +38,6 @@ module RubyLLM
33
38
 
34
39
  private
35
40
 
36
- def access_token
37
- return 'test-token' if defined?(VCR) && !VCR.current_cassette.recording?
38
-
39
- initialize_authorizer unless @authorizer
40
- @authorizer.fetch_access_token!['access_token']
41
- rescue Google::Auth::AuthorizationError => e
42
- raise UnauthorizedError.new(nil, "Invalid Google Cloud credentials for Vertex AI: #{e.message}")
43
- end
44
-
45
41
  def initialize_authorizer
46
42
  require 'googleauth'
47
43
  @authorizer = ::Google::Auth.get_application_default(
@@ -51,7 +47,8 @@ module RubyLLM
51
47
  ]
52
48
  )
53
49
  rescue LoadError
54
- raise Error, 'The googleauth gem is required for Vertex AI. Please add it to your Gemfile: gem "googleauth"'
50
+ raise Error,
51
+ 'The googleauth gem ~> 1.15 is required for Vertex AI. Please add it to your Gemfile: gem "googleauth"'
55
52
  end
56
53
  end
57
54
  end
@@ -1,33 +1,35 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RubyLLM
4
- # Rails integration for RubyLLM
5
- class Railtie < Rails::Railtie
6
- initializer 'ruby_llm.inflections' do
7
- ActiveSupport::Inflector.inflections(:en) do |inflect|
8
- inflect.acronym 'RubyLLM'
3
+ if defined?(Rails::Railtie)
4
+ module RubyLLM
5
+ # Rails integration for RubyLLM
6
+ class Railtie < Rails::Railtie
7
+ initializer 'ruby_llm.inflections' do
8
+ ActiveSupport::Inflector.inflections(:en) do |inflect|
9
+ inflect.acronym 'RubyLLM'
10
+ end
9
11
  end
10
- end
11
12
 
12
- initializer 'ruby_llm.active_record' do
13
- ActiveSupport.on_load :active_record do
14
- if RubyLLM.config.use_new_acts_as
15
- require 'ruby_llm/active_record/acts_as'
16
- ::ActiveRecord::Base.include RubyLLM::ActiveRecord::ActsAs
17
- else
18
- require 'ruby_llm/active_record/acts_as_legacy'
19
- ::ActiveRecord::Base.include RubyLLM::ActiveRecord::ActsAsLegacy
13
+ initializer 'ruby_llm.active_record' do
14
+ ActiveSupport.on_load :active_record do
15
+ if RubyLLM.config.use_new_acts_as
16
+ require 'ruby_llm/active_record/acts_as'
17
+ ::ActiveRecord::Base.include RubyLLM::ActiveRecord::ActsAs
18
+ else
19
+ require 'ruby_llm/active_record/acts_as_legacy'
20
+ ::ActiveRecord::Base.include RubyLLM::ActiveRecord::ActsAsLegacy
20
21
 
21
- Rails.logger.warn(
22
- "\n!!! RubyLLM's legacy acts_as API is deprecated and will be removed in RubyLLM 2.0.0. " \
23
- "Please consult the migration guide at https://rubyllm.com/upgrading-to-1-7/\n"
24
- )
22
+ Rails.logger.warn(
23
+ "\n!!! RubyLLM's legacy acts_as API is deprecated and will be removed in RubyLLM 2.0.0. " \
24
+ "Please consult the migration guide at https://rubyllm.com/upgrading-to-1-7/\n"
25
+ )
26
+ end
25
27
  end
26
28
  end
27
- end
28
29
 
29
- rake_tasks do
30
- load 'tasks/ruby_llm.rake'
30
+ rake_tasks do
31
+ load 'tasks/ruby_llm.rake'
32
+ end
31
33
  end
32
34
  end
33
35
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyLLM
4
- VERSION = '1.9.0'
4
+ VERSION = '1.9.1'
5
5
  end
data/lib/ruby_llm.rb CHANGED
@@ -29,6 +29,7 @@ loader.inflector.inflect(
29
29
  )
30
30
  loader.ignore("#{__dir__}/tasks")
31
31
  loader.ignore("#{__dir__}/generators")
32
+ loader.ignore("#{__dir__}/ruby_llm/railtie.rb")
32
33
  loader.setup
33
34
 
34
35
  # A delightful Ruby interface to modern AI language models.
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.9.0
4
+ version: 1.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carmine Paolino