ruby_llm 1.6.4 → 1.7.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/README.md +6 -3
- data/lib/generators/ruby_llm/chat_ui/chat_ui_generator.rb +127 -0
- data/lib/generators/ruby_llm/chat_ui/templates/controllers/chats_controller.rb.tt +39 -0
- data/lib/generators/ruby_llm/chat_ui/templates/controllers/messages_controller.rb.tt +24 -0
- data/lib/generators/ruby_llm/chat_ui/templates/controllers/models_controller.rb.tt +14 -0
- data/lib/generators/ruby_llm/chat_ui/templates/jobs/chat_response_job.rb.tt +12 -0
- data/lib/generators/ruby_llm/chat_ui/templates/views/chats/_chat.html.erb.tt +16 -0
- data/lib/generators/ruby_llm/chat_ui/templates/views/chats/_form.html.erb.tt +29 -0
- data/lib/generators/ruby_llm/chat_ui/templates/views/chats/index.html.erb.tt +16 -0
- data/lib/generators/ruby_llm/chat_ui/templates/views/chats/new.html.erb.tt +11 -0
- data/lib/generators/ruby_llm/chat_ui/templates/views/chats/show.html.erb.tt +23 -0
- data/lib/generators/ruby_llm/chat_ui/templates/views/messages/_form.html.erb.tt +21 -0
- data/lib/generators/ruby_llm/chat_ui/templates/views/messages/_message.html.erb.tt +10 -0
- data/lib/generators/ruby_llm/chat_ui/templates/views/messages/create.turbo_stream.erb.tt +9 -0
- data/lib/generators/ruby_llm/chat_ui/templates/views/models/_model.html.erb.tt +16 -0
- data/lib/generators/ruby_llm/chat_ui/templates/views/models/index.html.erb.tt +30 -0
- data/lib/generators/ruby_llm/chat_ui/templates/views/models/show.html.erb.tt +18 -0
- data/lib/generators/ruby_llm/generator_helpers.rb +129 -0
- data/lib/generators/ruby_llm/install/install_generator.rb +104 -0
- data/lib/generators/ruby_llm/install/templates/chat_model.rb.tt +2 -2
- data/lib/generators/ruby_llm/install/templates/create_chats_migration.rb.tt +4 -4
- data/lib/generators/ruby_llm/install/templates/create_messages_migration.rb.tt +8 -7
- data/lib/generators/ruby_llm/install/templates/create_models_migration.rb.tt +40 -0
- data/lib/generators/ruby_llm/install/templates/create_tool_calls_migration.rb.tt +6 -5
- data/lib/generators/ruby_llm/install/templates/initializer.rb.tt +10 -4
- data/lib/generators/ruby_llm/install/templates/message_model.rb.tt +4 -3
- data/lib/generators/ruby_llm/install/templates/model_model.rb.tt +3 -0
- data/lib/generators/ruby_llm/install/templates/tool_call_model.rb.tt +2 -2
- data/lib/generators/ruby_llm/upgrade_to_v1_7/templates/migration.rb.tt +145 -0
- data/lib/generators/ruby_llm/upgrade_to_v1_7/upgrade_to_v1_7_generator.rb +121 -0
- data/lib/ruby_llm/active_record/acts_as.rb +111 -327
- data/lib/ruby_llm/active_record/acts_as_legacy.rb +398 -0
- data/lib/ruby_llm/active_record/chat_methods.rb +336 -0
- data/lib/ruby_llm/active_record/message_methods.rb +72 -0
- data/lib/ruby_llm/active_record/model_methods.rb +84 -0
- data/lib/ruby_llm/aliases.json +54 -13
- data/lib/ruby_llm/attachment.rb +20 -0
- data/lib/ruby_llm/chat.rb +5 -5
- data/lib/ruby_llm/configuration.rb +9 -0
- data/lib/ruby_llm/connection.rb +4 -4
- data/lib/ruby_llm/model/info.rb +12 -0
- data/lib/ruby_llm/models.json +3579 -2029
- data/lib/ruby_llm/models.rb +51 -22
- data/lib/ruby_llm/provider.rb +3 -3
- data/lib/ruby_llm/providers/anthropic/chat.rb +2 -2
- data/lib/ruby_llm/providers/anthropic/media.rb +1 -1
- data/lib/ruby_llm/providers/bedrock/chat.rb +2 -2
- data/lib/ruby_llm/providers/bedrock/models.rb +19 -1
- data/lib/ruby_llm/providers/gemini/chat.rb +1 -1
- data/lib/ruby_llm/providers/gemini/media.rb +1 -1
- data/lib/ruby_llm/providers/gpustack/chat.rb +11 -0
- data/lib/ruby_llm/providers/gpustack/media.rb +45 -0
- data/lib/ruby_llm/providers/gpustack/models.rb +44 -8
- data/lib/ruby_llm/providers/gpustack.rb +1 -0
- data/lib/ruby_llm/providers/ollama/media.rb +2 -6
- data/lib/ruby_llm/providers/ollama/models.rb +36 -0
- data/lib/ruby_llm/providers/ollama.rb +1 -0
- data/lib/ruby_llm/providers/openai/chat.rb +1 -1
- data/lib/ruby_llm/providers/openai/media.rb +4 -4
- data/lib/ruby_llm/providers/openai/tools.rb +11 -6
- data/lib/ruby_llm/providers/openai.rb +2 -2
- data/lib/ruby_llm/providers/vertexai/chat.rb +14 -0
- data/lib/ruby_llm/providers/vertexai/embeddings.rb +32 -0
- data/lib/ruby_llm/providers/vertexai/models.rb +130 -0
- data/lib/ruby_llm/providers/vertexai/streaming.rb +14 -0
- data/lib/ruby_llm/providers/vertexai.rb +55 -0
- data/lib/ruby_llm/railtie.rb +20 -3
- data/lib/ruby_llm/streaming.rb +1 -1
- data/lib/ruby_llm/utils.rb +5 -9
- data/lib/ruby_llm/version.rb +1 -1
- data/lib/ruby_llm.rb +4 -3
- data/lib/tasks/models.rake +39 -28
- data/lib/tasks/ruby_llm.rake +15 -0
- data/lib/tasks/vcr.rake +2 -2
- metadata +38 -3
- data/lib/generators/ruby_llm/install/templates/INSTALL_INFO.md.tt +0 -108
- data/lib/generators/ruby_llm/install_generator.rb +0 -121
@@ -1,121 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'rails/generators'
|
4
|
-
require 'rails/generators/active_record'
|
5
|
-
|
6
|
-
module RubyLLM
|
7
|
-
# Generator for RubyLLM Rails models and migrations
|
8
|
-
class InstallGenerator < Rails::Generators::Base
|
9
|
-
include Rails::Generators::Migration
|
10
|
-
|
11
|
-
namespace 'ruby_llm:install'
|
12
|
-
|
13
|
-
source_root File.expand_path('install/templates', __dir__)
|
14
|
-
|
15
|
-
class_option :chat_model_name, type: :string, default: 'Chat',
|
16
|
-
desc: 'Name of the Chat model class'
|
17
|
-
class_option :message_model_name, type: :string, default: 'Message',
|
18
|
-
desc: 'Name of the Message model class'
|
19
|
-
class_option :tool_call_model_name, type: :string, default: 'ToolCall',
|
20
|
-
desc: 'Name of the ToolCall model class'
|
21
|
-
|
22
|
-
desc 'Creates model files for Chat, Message, and ToolCall, and creates migrations for RubyLLM Rails integration'
|
23
|
-
|
24
|
-
def self.next_migration_number(dirname)
|
25
|
-
::ActiveRecord::Generators::Base.next_migration_number(dirname)
|
26
|
-
end
|
27
|
-
|
28
|
-
def migration_version
|
29
|
-
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
|
30
|
-
end
|
31
|
-
|
32
|
-
def postgresql?
|
33
|
-
::ActiveRecord::Base.connection.adapter_name.downcase.include?('postgresql')
|
34
|
-
rescue StandardError
|
35
|
-
false
|
36
|
-
end
|
37
|
-
|
38
|
-
def acts_as_chat_declaration
|
39
|
-
acts_as_chat_params = []
|
40
|
-
if options[:message_model_name] != 'Message'
|
41
|
-
acts_as_chat_params << "message_class: \"#{options[:message_model_name]}\""
|
42
|
-
end
|
43
|
-
if options[:tool_call_model_name] != 'ToolCall'
|
44
|
-
acts_as_chat_params << "tool_call_class: \"#{options[:tool_call_model_name]}\""
|
45
|
-
end
|
46
|
-
if acts_as_chat_params.any?
|
47
|
-
"acts_as_chat #{acts_as_chat_params.join(', ')}"
|
48
|
-
else
|
49
|
-
'acts_as_chat'
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def acts_as_message_declaration
|
54
|
-
acts_as_message_params = []
|
55
|
-
acts_as_message_params << "chat_class: \"#{options[:chat_model_name]}\"" if options[:chat_model_name] != 'Chat'
|
56
|
-
if options[:tool_call_model_name] != 'ToolCall'
|
57
|
-
acts_as_message_params << "tool_call_class: \"#{options[:tool_call_model_name]}\""
|
58
|
-
end
|
59
|
-
if acts_as_message_params.any?
|
60
|
-
"acts_as_message #{acts_as_message_params.join(', ')}"
|
61
|
-
else
|
62
|
-
'acts_as_message'
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def acts_as_tool_call_declaration
|
67
|
-
acts_as_tool_call_params = []
|
68
|
-
if options[:message_model_name] != 'Message'
|
69
|
-
acts_as_tool_call_params << "message_class: \"#{options[:message_model_name]}\""
|
70
|
-
end
|
71
|
-
if acts_as_tool_call_params.any?
|
72
|
-
"acts_as_tool_call #{acts_as_tool_call_params.join(', ')}"
|
73
|
-
else
|
74
|
-
'acts_as_tool_call'
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def create_migration_files
|
79
|
-
# Create migrations with timestamps to ensure proper order
|
80
|
-
# First create chats table
|
81
|
-
migration_template 'create_chats_migration.rb.tt',
|
82
|
-
"db/migrate/create_#{options[:chat_model_name].tableize}.rb"
|
83
|
-
|
84
|
-
# Then create messages table (must come before tool_calls due to foreign key)
|
85
|
-
sleep 1 # Ensure different timestamp
|
86
|
-
migration_template 'create_messages_migration.rb.tt',
|
87
|
-
"db/migrate/create_#{options[:message_model_name].tableize}.rb"
|
88
|
-
|
89
|
-
# Finally create tool_calls table (references messages)
|
90
|
-
sleep 1 # Ensure different timestamp
|
91
|
-
migration_template 'create_tool_calls_migration.rb.tt',
|
92
|
-
"db/migrate/create_#{options[:tool_call_model_name].tableize}.rb"
|
93
|
-
end
|
94
|
-
|
95
|
-
def create_model_files
|
96
|
-
template 'chat_model.rb.tt', "app/models/#{options[:chat_model_name].underscore}.rb"
|
97
|
-
template 'message_model.rb.tt', "app/models/#{options[:message_model_name].underscore}.rb"
|
98
|
-
template 'tool_call_model.rb.tt', "app/models/#{options[:tool_call_model_name].underscore}.rb"
|
99
|
-
end
|
100
|
-
|
101
|
-
def create_initializer
|
102
|
-
template 'initializer.rb.tt', 'config/initializers/ruby_llm.rb'
|
103
|
-
end
|
104
|
-
|
105
|
-
def show_install_info
|
106
|
-
say "\n ✅ RubyLLM installed!", :green
|
107
|
-
|
108
|
-
say "\n Next steps:", :yellow
|
109
|
-
say ' 1. Run: rails db:migrate'
|
110
|
-
say ' 2. Set your API keys in config/initializers/ruby_llm.rb'
|
111
|
-
say " 3. Start chatting: #{options[:chat_model_name]}.create!(model_id: 'gpt-4.1-nano').ask('Hello!')"
|
112
|
-
|
113
|
-
say "\n 📚 Full docs: https://rubyllm.com", :cyan
|
114
|
-
|
115
|
-
say "\n ❤️ Love RubyLLM?", :magenta
|
116
|
-
say ' • ⭐ Star on GitHub: https://github.com/crmne/ruby_llm'
|
117
|
-
say ' • 💖 Sponsor: https://github.com/sponsors/crmne'
|
118
|
-
say "\n"
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|