Share
Embed
Transcript
24 slides
-
Company Overview giftee operates an e-gift platform that covers the
entire journey from issuance to distribution. Our platform is primarily built with Rails. 3 -
Automating an Internal Workflow BEFORE Article ↓ Human Review AFTER
Article ↓ ✦ AI Review 4 -
Today's Theme We implemented AI in a Rails application. Based
on that experience, I’ll talk about what was hard — and how we might implement AI in Rails going forward. 5 -
Today's Journey 1. Implementation How we first implemented AI 2.
Design Challenges What became difficult 3. The Rails Way What we discovered along the way 6 -
Our First Approach We put AI under the Model layer
— in three parts. Model Layer Request app/models/.../request ↓ Review app/models/.../review → External LLM API ↓ API client app/models/.../api_client 7 -
It Started Simple One Provider. One Use Case. class Review
def execute(request) response = GeminiClient.generate_content( prompt: request.prompt, response_format: response_format ) end private def response_format # JSON Schema end end It Worked. 8 -
Then AI Usage Expanded More Providers. More Use Cases. Providers
Gemini → Gemini + OpenAI Use Cases Review → Review + New Task More Prompts. More Schemas. More Settings. 9 -
Growing Inside Models BEFORE AFTER app/models/ app/models/ ├── review_request.rb ├──
review_request.rb ├── ai_review.rb ├── ai_review.rb └── gemini_client.rb ├── gemini_client.rb ├── xxx_request.rb ├── ai_xxx.rb └── openai_client.rb More AI Features, More Models. 10 -
Where Does AI Belong? PROMPT STRUCTURED OUTPUT In the Model
layer Inside Review Is this a Model's job? Is this Review's job? Where should AI-specific responsibilities live in Rails? 11 -
Looking for a Rails-like Way We considered Services, Concerns, and
LLM libraries. But we still had to decide where AI-specific code belonged. Could we implement AI the Rails way? 12 -
The Approach We Chose Active Agent Active Agent provides that
missing AI layer in the Rails framework, offering a structured approach to building AI-powered applications through Agent Oriented Programming. https://github.com/activeagents/activeagent https://docs.activeagents.ai/framework#core-architecture 13 -
Where the parts live config/ └── active_agent.yml app/ ├── agents/
│ └── review_agent.rb └── views/ └── agents/ └── review/ Provider and model live in config. default: &default openai: service: 'OpenAI' api_key: <%= ENV['OPENAI_API_KEY'] %> model: 'gpt-5.2' temperature: 0.1 gemini: # can be defined the same way development: <<: *default test: <<: *default 14 -
Where the parts live The Agent is what the AI
does. config/ └── active_agent.yml app/ ├── agents/ │ └── review_agent.rb └── views/ └── agents/ └── review/ class ReviewAgent < ApplicationAgent generate_with :gemini def review prompt( prompt_text:, response_format: :review_schema ) end end 15 -
Where the parts live Prompt and schema live under views.
config/ └── active_agent.yml app/ ├── agents/ │ └── review_agent.rb └── views/ └── agents/ └── review/ # app/views/agents/review/review.html.erb Please review the following content. ... Creative asset: <% if @article.text? %> <%= @article.text %> <% else %> Attached image <% end %> ... # app/views/agents/review/review_schema.json { "comment": { "type": "string" } } 16 -
What Active Agent changed The next AI task is another
Agent, another view. A summary? SummaryAgent . views/agents/summary/ . We didn’t have to invent a new place. 17 -
What Active Agent changed The next AI task is another
Agent, another view. A summary? SummaryAgent . views/agents/summary/ . We didn’t have to invent a new place. Not an LLM API service class — AI as a concern, contained in something that feels like MVC. 18 -
Why It Got Better The bigger change wasn’t a new
place. It was an extension of the Rails we already write. Fewer decisions to make. 19 -
That’s Why Rails provides conventions for common responsibilities. Action Mailer
Active Storage Action Cable Sending emails Handling files WebSockets Mailers, views, delivery configuration Attachments, blobs, storage services Channels, connections, broadcasting Each responsibility has its own structure and conventions. 21 -
But AI Had No Place Mailer. Storage. Cable. AI had
nothing like that. So we had to invent each decision, one by one. 22 -
Active Agent Is One Answer It became one answer —
for our product. The Rails ecosystem doesn’t have one yet. 23 -
The Rails Way for AI, Too AI in apps will
only become more common. So I’d like us to keep asking: How should Rails embrace AI as a responsibility? 24