File tree Expand file tree Collapse file tree 2 files changed +72
-0
lines changed
lib/generators/ruby_llm/install/templates
spec/lib/generators/ruby_llm Expand file tree Collapse file tree 2 files changed +72
-0
lines changed Original file line number Diff line number Diff line change
1
+ # RubyLLM Rails Setup Complete!
2
+
3
+ Thanks for installing RubyLLM in your Rails application. Here's what was created:
4
+
5
+ ## Models
6
+
7
+ - ` Chat ` - Stores chat sessions and their associated model ID
8
+ - ` Message ` - Stores individual messages in a chat
9
+ - ` ToolCall ` - Stores tool calls made by language models
10
+
11
+ ## Next Steps
12
+
13
+ 1 . ** Run migrations:**
14
+ ``` bash
15
+ rails db:migrate
16
+ ```
17
+
18
+ 2 . ** Set your API keys** in ` config/initializers/ruby_llm.rb ` or using environment variables:
19
+ ``` ruby
20
+ # config/initializers/ruby_llm.rb
21
+ RubyLLM .configure do |config |
22
+ config.openai_api_key = ENV [" OPENAI_API_KEY" ]
23
+ config.anthropic_api_key = ENV [" ANTHROPIC_API_KEY" ]
24
+ # etc.
25
+ end
26
+ ```
27
+
28
+ 3 . ** Start using RubyLLM in your code:**
29
+ ``` ruby
30
+ # Create a new chat
31
+ chat = Chat .create!(model_id: " gpt-4o-mini" )
32
+
33
+ # Ask a question
34
+ response = chat.ask(" What's the best Ruby web framework?" )
35
+
36
+ # Get chat history
37
+ chat.messages
38
+ ```
39
+
40
+ 4 . ** For streaming responses** with ActionCable or Turbo:
41
+ ``` ruby
42
+ chat.ask(" Tell me about Ruby on Rails" ) do |chunk |
43
+ Turbo ::StreamsChannel .broadcast_append_to(
44
+ chat, target: " response" , partial: " messages/chunk" , locals: { chunk: chunk }
45
+ )
46
+ end
47
+ ```
48
+
49
+ ## Advanced Usage
50
+
51
+ - Add more fields to your models as needed
52
+ - Customize the views to match your application design
53
+ - Create a controller for chat interactions
54
+
55
+ For more information, visit the [ RubyLLM Documentation] ( https://github.com/crmne/ruby_llm )
Original file line number Diff line number Diff line change 86
86
end
87
87
end
88
88
89
+ describe "README template" do
90
+ it "has a README template file" do
91
+ expect ( File . exist? ( File . join ( template_dir , "README.md" ) ) ) . to be ( true )
92
+ end
93
+
94
+ it "has helpful post-installation instructions" do
95
+ readme_content = File . read ( File . join ( template_dir , "README.md" ) )
96
+ expect ( readme_content ) . to include ( "RubyLLM Rails Setup Complete" )
97
+ expect ( readme_content ) . to include ( "Run migrations" )
98
+ expect ( readme_content ) . to include ( "rails db:migrate" )
99
+ expect ( readme_content ) . to include ( "Set your API keys" )
100
+ expect ( readme_content ) . to include ( "Start using RubyLLM in your code" )
101
+ expect ( readme_content ) . to include ( "For streaming responses" )
102
+ end
103
+ end
104
+
89
105
describe "generator file structure" do
90
106
it "has proper directory structure" do
91
107
generator_file = "/Users/kieranklaassen/rails/ruby_llm/lib/generators/ruby_llm/install_generator.rb"
97
113
expect ( generator_content ) . to include ( "def create_migration_files" )
98
114
expect ( generator_content ) . to include ( "def create_model_files" )
99
115
expect ( generator_content ) . to include ( "def create_initializer" )
116
+ expect ( generator_content ) . to include ( "def show_readme" )
100
117
end
101
118
102
119
it "creates migrations in the correct order" do
You can’t perform that action at this time.
0 commit comments