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.
- checksums.yaml +4 -4
- data/lib/generators/ruby_llm/generator_helpers.rb +31 -10
- data/lib/generators/ruby_llm/install/templates/create_models_migration.rb.tt +5 -0
- data/lib/generators/ruby_llm/install/templates/create_tool_calls_migration.rb.tt +7 -1
- data/lib/ruby_llm/active_record/acts_as.rb +16 -18
- data/lib/ruby_llm/aliases.json +0 -13
- data/lib/ruby_llm/attachment.rb +34 -11
- data/lib/ruby_llm/models.json +1405 -1584
- data/lib/ruby_llm/providers/anthropic/media.rb +1 -1
- data/lib/ruby_llm/providers/vertexai.rb +10 -13
- data/lib/ruby_llm/railtie.rb +24 -22
- data/lib/ruby_llm/version.rb +1 -1
- data/lib/ruby_llm.rb +1 -0
- metadata +1 -1
|
@@ -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' =>
|
|
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,
|
|
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
|
data/lib/ruby_llm/railtie.rb
CHANGED
|
@@ -1,33 +1,35 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
30
|
-
|
|
30
|
+
rake_tasks do
|
|
31
|
+
load 'tasks/ruby_llm.rake'
|
|
32
|
+
end
|
|
31
33
|
end
|
|
32
34
|
end
|
|
33
35
|
end
|
data/lib/ruby_llm/version.rb
CHANGED
data/lib/ruby_llm.rb
CHANGED