Skip to content

Commit 6e68d36

Browse files
Add README template for generator output
This adds a helpful README template that's displayed after successful generator installation, providing users with clear next steps and examples of how to use the generated models. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 2d50909 commit 6e68d36

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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)

spec/lib/generators/ruby_llm/template_files_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,22 @@
8686
end
8787
end
8888

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+
89105
describe "generator file structure" do
90106
it "has proper directory structure" do
91107
generator_file = "/Users/kieranklaassen/rails/ruby_llm/lib/generators/ruby_llm/install_generator.rb"
@@ -97,6 +113,7 @@
97113
expect(generator_content).to include("def create_migration_files")
98114
expect(generator_content).to include("def create_model_files")
99115
expect(generator_content).to include("def create_initializer")
116+
expect(generator_content).to include("def show_readme")
100117
end
101118

102119
it "creates migrations in the correct order" do

0 commit comments

Comments
 (0)