使用 Boxcars 与 LLM 实现可组合性的应用程序构建
Boxcars
Website | Blog | Documentation
Boxcars is a Ruby framework for building LLM-powered systems with less cognitive load, especially for Ruby and Rails teams. If you want one gem that can search, calculate, query data, call external APIs, run retrieval, and coordinate all of that in one runtime, Boxcars is built for that workflow.
Inspired by LangChain, Boxcars brings a Ruby-first design that favors practical composition over framework lock-in.
Boxcar objects and reuse them across assistants, jobs, and services.Boxcar, Train, Engine) for controllers, jobs, and service objects instead of one-off wrappers per provider.Boxcars::ZeroShot) or use native provider tool calling (Boxcars::ToolTrain).JSONEngineBoxcar.All of these concepts are in a module named Boxcars:
Boxcars::ZeroShot (legacy ReAct) and Boxcars::ToolTrain (native tool calling).Boxcars requires Ruby 3.3 or newer.
Add this line to your application's Gemfile:
gem 'boxcars'And then execute:
$ bundle installOr install it yourself as:
$ gem install boxcarsboxcars keeps provider/tooling dependencies optional so base installs stay lean.
Add only the gems you use:
…If a feature is used without its optional gem installed, Boxcars raises a setup error with the gem name to add.
calc = Boxcars::Calculator.new
puts calc.run("What is pi to the fourth power divided by 22.1?")
# => 4.407651178009159boxcars = [Boxcars::Calculator.new, Boxcars::GoogleSearch.new]
train = Boxcars.train.new(boxcars: boxcars)
puts train.run("What is pi times the square root of the average temperature in Austin TX in January?")agent = Boxcars::StationAgent.new(
instructions: "You are a helpful math tutor.",
tools: [Boxcars::Calculator.new],
model: "sonnet"
)
puts agent.run("What is the square root of 144?")| Guide | Covers |
|---|---|
| Boxcars Guide | Engines, Boxcars, Trains, MCP, Observability, JSON Schema, configuration |
| Agents Guide | StationAgent, AgentRunner, handoffs, event streaming, lifecycle callbacks |
| UPGRADING.md | Migration guidance for v1.0 (tool-calling, alias deprecations, OpenAI client) |
Both ActiveRecord and the SQL boxcars default to read-only mode, rejecting write operations with a Boxcars::SecurityError. To allow writes, disable read-only mode or provide an approval callback. See the Boxcars Guide for details and examples.
Boxcars::Openai now defaults to gpt-5-mini and uses the official OpenAI client path.Boxcars::Cohere now defaults to command-a-03-2025 (legacy command-r* model IDs were retired by Cohere).~> 8.1.rest-client is no longer a Boxcars runtime dependency.intelligence and gpt4all are now optional dependencies:Boxcars::IntelligenceBase requires gem "intelligence" in your app.Boxcars::Gpt4allEng requires gem "gpt4all" in your app.If your app uses IntelligenceBase or Gpt4allEng, add optional gems explicitly:
# Gemfile (only if you use these paths)
gem "intelligence"
gem "gpt4all"Note, some folks that we talked to didn't know that you could run Ruby Jupyter notebooks. You can.
Configure logging with Boxcars.configuration.logger = your_logger and enable prompt debugging with Boxcars.configuration.log_prompts = true. See the Boxcars Guide for details.
After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/BoxcarsAI/boxcars. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the Boxcars project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
暂无开放 Issues,或尚未同步最近议题。