RailsOrchestrator
A framework to build AI agents in Rails applications. Send conversations to a local LLM (Ollama, etc.) and get responses.
Installation
Add to your Gemfile:
gem "rails_orchestrator"
Then run bundle install.
Usage
Configuration
RailsOrchestrator.configure do |config|
config.base_url = "http://localhost:11434" # default
config.model = "llama3" # default
config.request_timeout = 120 # default, in seconds
end
Sending a conversation
conversation = RailsOrchestrator::Conversation.new
conversation.system("You are a helpful assistant.")
conversation.user("Hello!")
client = RailsOrchestrator::Client.new
response = client.chat(conversation)
response.content # => "Hi there!"
You can also pass plain arrays:
response = client.chat([{ role: "user", content: "Hello" }])
Error handling
begin
response = client.chat(conversation)
rescue RailsOrchestrator::ConnectionError => e
# Network failure (connection refused, timeout, etc.)
rescue RailsOrchestrator::ApiError => e
e.status # HTTP status code
e.body # Raw response body
end
Development
bundle install
bundle exec rspec
bundle exec rubocop
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/jpmsantana/rails_orchestrator.
License
The gem is available as open source under the terms of the MIT License.