RubyLLM 1.7: Rails Revolution & Vertex AI 🚀
Major Rails integration overhaul bringing database-backed models, UI generators, and a more intuitive acts_as API. Plus Google Cloud Vertex AI support, regional AWS Bedrock, and streamlined installation!
🌟 Google Cloud Vertex AI Support
Full Vertex AI provider integration with dynamic model discovery:
# Add to your Gemfile:
gem "googleauth" # Required for Vertex AI authentication
# Configure Vertex AI:
RubyLLM.configure do |config|
config.vertexai_project_id = "your-project"
config.vertexai_location = "us-central1"
end
# Access Gemini and other Google models through Vertex AI
chat = RubyLLM.chat(model: "gemini-2.5-pro", provider: :vertexai)
response = chat.ask("What can you do?")
Features:
- Dynamic model fetching from Vertex AI API with pagination
- Automatic discovery of Gemini foundation models
- Metadata enrichment from Parsera API
- Full chat and embeddings support
- Seamless integration with existing Gemini provider
- Uses Application Default Credentials (ADC) for authentication
🎉 New Rails-Like acts_as API
The Rails integration gets a massive upgrade with a more intuitive, Rails-like API:
# OLD way (still works, deprecated in v2.0)
class Chat < ApplicationRecord
acts_as_chat message_class: 'Message', tool_call_class: 'ToolCall'
end
# NEW way - use association names as primary parameters!
class Chat < ApplicationRecord
acts_as_chat messages: :messages, model: :model
end
class Message < ApplicationRecord
acts_as_message chat: :chat, tool_calls: :tool_calls, model: :model
end
Two-Command Upgrade
Existing apps can upgrade seamlessly:
# Step 1: Run the upgrade generator
rails generate ruby_llm:upgrade_to_v1_7
# Step 2: Run migrations
rails db:migrate
That's it! The upgrade generator:
- Creates the models table if needed
- Automatically adds
config.use_new_acts_as = true
to your initializer - Migrates your existing data to use foreign keys
- Preserves all your data (old string columns renamed to
model_id_string
)
🖥️ Complete Chat UI Generator
Build a full chat interface with one command:
# Generate complete chat UI with Turbo streaming
rails generate ruby_llm:chat_ui
This creates:
- Controllers: Chat and message controllers with Rails best practices
- Views: Clean HTML views for chat list, creation, and messaging
- Models page: Browse available AI models
- Turbo Streams: Real-time message updates
- Background job: Streaming AI responses
- Model selector: Choose models in chat creation
The UI is intentionally simple and clean - perfect for customization!
💾 Database-Backed Model Registry
Models are now first-class ActiveRecord objects with rich metadata:
# Chat.create! has the same interface as RubyLLM.chat (PORO)
chat = Chat.create! # Uses default model from config
chat = Chat.create!(model: "gpt-4o-mini") # Specify model
chat = Chat.create!(model: "claude-3-5-haiku", provider: "bedrock") # Cross-provider
chat = Chat.create!(
model: "experimental-llm-v2",
provider: "openrouter",
assume_model_exists: true # Creates Model record if not found
)
# Access rich model metadata through associations
chat.model.context_window # => 128000
chat.model.capabilities # => ["streaming", "function_calling", "structured_output"]
chat.model.pricing["text_tokens"]["standard"]["input_per_million"] # => 2.5
# Works with Model objects too
model = Model.find_by(model_id: "gpt-4o")
chat = Chat.create!(model: model)
# Refresh models from provider APIs
Model.refresh! # Populates/updates models table from all configured providers
The install generator creates a Model model by default:
# Custom model names supported
rails g ruby_llm:install chat:Discussion message:Comment model:LLModel
🌍 AWS Bedrock Regional Support
Cross-region inference now works correctly in all AWS regions:
# EU regions now work!
RubyLLM.configure do |config|
config.bedrock_region = "eu-west-3"
end
# Automatically uses correct region prefix:
# - EU: eu.anthropic.claude-3-sonnet...
# - US: us.anthropic.claude-3-sonnet...
# - AP: ap.anthropic.claude-3-sonnet...
# - CA: ca.anthropic.claude-3-sonnet...
Thanks to @elthariel for the contribution! (#338)
🎵 MP3 Audio Support Fixed
OpenAI's Whisper API now correctly handles MP3 files:
# Previously failed with MIME type errors
chat.add_attachment("audio.mp3")
response = chat.ask("Transcribe this audio") # Now works!
The fix properly converts audio/mpeg
MIME type to the mp3
format string OpenAI expects. (#390)
🚀 Performance & Developer Experience
Simplified Installation
The post-install message is now concise and helpful, pointing to docs instead of overwhelming with text.
Better Generator Experience
All generators now support consistent interfaces:
# All use the same pattern
rails g ruby_llm:install chat:Chat message:Message
rails g ruby_llm:upgrade_to_v1_7 chat:Chat message:Message
rails g ruby_llm:chat_ui
ActiveStorage Integration
The install generator now automatically:
- Installs ActiveStorage if not present
- Configures RubyLLM for attachment support
- Ensures smooth multimodal experiences out of the box
🔧 Fixes & Improvements
Provider Enhancements
- Local provider models:
Models.refresh!
now supports Ollama and GPUStack with proper capability mapping - Provider architecture: Providers no longer call
RubyLLM.models.find
internally (#366) - Tool calling: Fixed OpenAI tool calls with missing function.arguments (#385, thanks @elthariel!)
- Streaming callbacks:
on_new_message
now fires before API request, not after first chunk (#367)
Documentation & Testing
- Documentation variables: Model names now use variables for easier updates
- IRB compatibility:
#instance_variables
method now public forls
command (#374, thanks @matijs!) - Test improvements: Fixed CI issues with acts_as modules and database initialization
- VCR enhancements: Better VertexAI recording and cassette management
Breaking Changes
with_params Behavior
with_params
now takes precedence over internal defaults, allowing full control:
# You can now override ANY parameter
chat.with_params(max_tokens: 100) # This now works!
chat.with_params(tools: [web_search_tool]) # Provider-specific features
Set RUBYLLM_DEBUG=true
to see exactly what's being sent to the API.
Installation
gem 'ruby_llm', '1.7.0'
Upgrading from 1.6.x
- Update your Gemfile
- Run
bundle update ruby_llm
- Run
rails generate ruby_llm:upgrade_to_v1_7
- Run
rails db:migrate
- Enjoy the new features! 🎉
Full backward compatibility maintained - the old acts_as API continues working with a deprecation warning.
Merged PRs.
- Add missing code block ending in the docs by @AlexVPopov in #368
- Make overrides of #instance_variables method public by @mvz in #374
- Handle missing function.arguments in OpenAI tool_calls by @elthariel in #385
- Inference regions by @ESegundoRolon in #338
New Contributors
- @AlexVPopov made their first contribution in #368
- @mvz made their first contribution in #374
- @elthariel made their first contribution in #385
- @ESegundoRolon made their first contribution in #338
Full Changelog: 1.6.4...1.7.0