00:00:13.639
Someone told me I'm giving a second-to-last keynote, which I'm not in the same category as Aaron, but I'm looking forward to it anyway. Let's talk about empowering the individual: Rails on AI. One of the amazing things about Rails over the years, I can say now, is how it has allowed me to indulge my desire to experiment and create cool stuff by myself.
00:00:26.400
Often, that's the only way you can do it. You have ideas, but you can't afford to hire a team or raise funds for certain things. I find that one of the most beautiful, amazing, and exciting aspects of AI development is that it amplifies that potential exponentially, and it does this particularly well within Rails.
00:01:08.799
As more people are coming in, let me just go to the next slide. For those of you who are not familiar with me, I’m most famous for my work on The Rails Way. However, I do have almost 30 years of experience as a professional software developer. I worked with full-stack Java from 1995 to 2004, and that was when I fell in love with Ruby.
00:01:44.559
I was probably one of the first people in the world consulting with Ruby and Rails at ThoughtWorks, which was a significant experience. That led me to write The Rails Way and found Hashrocket, and I see some of my old friends from Hashrocket in the audience, so hello to them.
00:02:06.200
I did a brief AI-related project in 2019, which piqued my interest. I want to make it clear that a lot of what I'm going to talk about today is drawn directly from my personal experience. I'm not a fan of vaporware or hand-wavy concepts that don't make sense in a practical context. Today, I aim to give you tangible ideas, inspiration, and practical tips that you can implement in your projects to empower yourselves as developers.
00:02:31.680
Everything I'm about to share started when I got excited about access to the OpenAI API before last year's Rails Conf. I wanted to make a contribution using that API, so I created an open-source library called Magma Chat. I announced it at Rails Conf and gave a lightning talk about it. As a result of creating Magma Chat, I was able to create a bot for my partner, Victoria, who was working as a media partner for a conference series.
00:03:13.280
When I saw that she was using it all the time, I suggested that we start a company together, and we launched a company called Olympia. The purpose of this talk is not to hype Olympia, but I did take a lot of the code I'm showcasing today from Olympia, just so you are aware of its origins.
00:03:35.280
At Olympia, we work on developing humanized bots that provide advice similar to how chatbots like ChatGPT do, but in particular roles. For example, I had a conversation with my programmer, Mike, about how to use an RSpec stub in my Rails console, and he helped me figure it out. I've been extremely excited about the work I'm doing in Olympia, and I also gave a talk called 'The Biggest Wave of All' at Sin City Ruby, discussing why I believe AI is disruptive and exciting. A friend of mine, Tom Rossi, asked me where to get started with AI, prompting me to think about how I could help educate others on what I have learned in Olympia.
00:04:28.479
So how can AI empower you as a Rails developer? There are really four steps to achieving that enlightenment. Most of you are likely already engaging in the first step: utilizing tools like ChatGPT and Claude as more effective alternatives to Google or Stack Overflow. By asking these tools questions, you often get good advice without much hassle.
00:05:14.560
The second step is using AI code completion tools in your integrated development environment (IDE) to code faster. I'm curious—how many of you use Copilot or similar code completion tools? (Audience shows hands.) As expected, almost everyone has their hand up, which is great.
00:05:32.639
The third step, which I suspect fewer of you are using, is to leverage AI to implement features. This means collaborating with the AI, asking it to create specific features or views in your Rails application, rather than just using it for basic code completion.
00:06:21.760
Finally, the fourth step, which is the focus of my talk today, is utilizing AI to replace entire components and subsystems in your code, allowing you to write less code overall. Writing less code is where you truly begin to see the transformational benefits that AI can offer, which I believe is the most revolutionary part of the ongoing AI evolution.
00:07:13.920
Let's discuss these two essential aspects briefly: using AI to assist you in writing code and implementing AI in your projects to reduce the amount of code you need to write. A colleague, Peter Ruska, highlighted the importance of using GitHub Copilot, which is currently my favorite choice for code completion, as it's very effective.
00:07:39.280
In contrast to previous tools, Copilot offers seamless chat-driven suggestions, refactoring capabilities, and more intuitive interactions while you code. For instance, you can extract variables or restructure your code effectively, which I initially found lacking in some Ruby IDEs. Recently, I discovered that Copilot can even create files on your behalf, showcasing its capability for agentic behavior in coding.
00:08:34.920
Now, I want to focus on the important aspects of adopting AI patterns in your code. Learning how to integrate AI components in your projects can significantly reduce the coding workload, allowing you to delegate business logic and workflow automation to AI.
00:09:12.560
By the way, if you don’t already have my book, I encourage you to check it out. It's a 500-page book packed with patterns outlining how to achieve what I'm discussing in this talk. It offers detailed explanations and examples derived from working code.
00:09:55.560
A key point is that the best patterns discussed in the book are drawn from our work at Olympia, which has a user base that uses our application regularly. I will demonstrate practical and applicable knowledge today.
00:10:43.440
Let’s explore some abstract patterns to understand how to incorporate AI into your code conceptually. When explaining your AI purpose—either to yourself or to others, such as your boss—you should frame it within the architecture of your system. By clarifying what you want AI to do and what context it will operate within, the interaction becomes more productive.
00:11:28.000
Some examples of abstract patterns include 'narrowing the path' to reduce uncertainty and directing the AI's focus toward a particular task. You can also implement 'retrieval-augmented generation' to provide grounded information to AI, which assists in better decision-making. Self-healing data refers to AI’s ability to diagnose and remedy anomalies within the data.
00:12:26.839
We can also discuss the generative user interface (UI), where designers create a framework guiding AI to generate personalized user experiences dynamically. Personalizing user interfaces can be influenced by user profiles and activity.
00:12:46.200
Today, I will delve into two abstract patterns in greater detail. The first is 'narrowing the path', which is fundamental to effective prompt engineering. The concept revolves around minimizing the AI's potential confusion by providing explicit contextual boundaries. Given an expansive knowledge base, specific requests yield more accurate results.
00:13:38.840
The second abstract pattern I will share is 'a multitude of workers'. This approach allows you to decompose workflows into discrete components that collaborate like human microservices within your code. Instead of relying solely on external services, you essentially integrate these discrete AI components inside your application.
00:14:43.920
So let’s explore some concrete examples. For instance, the 'role assignment' is a concrete pattern that emphasizes providing the AI with a specific context to ensure appropriate responses. Crafting your prompts around simplifying complex terminology helps effectively communicate objectives with the AI.
00:15:29.720
The second example is about communicating in natural language with these AI discrete components, allowing them to collaborate intuitively. For example, one AI component might check whether a user has logged in recently, and another can send an email about any new features based on that data.
00:16:37.759
In my experience, embracing behavior-driven development principles resonates well with this approach. It describes software behavior in simple language terms, so why not apply a similar philosophy when constructing AI interactions? This can lead to clearer collaborative requirements and more effective solutions.
00:17:32.280
Now, let's talk about some practical applications of these patterns. For example, in the case of account management, you might want to simplify user requests. If a user attempts actions that don’t match the current state—like trying to add a subscription when their account is inactive—you can utilize prompt engineering to prevent such scenarios.
00:18:57.080
In practice, an AI assistant could handle user inquiries, checking their account status before allowing any changes. For illustration, if a user attempts to add a bot while their account is in a canceled state, the system should appropriately decline their request and provide feedback.
00:20:43.120
The AI can effectively guide users, simulating personalized responses that resemble human interactions, making it feel intuitive. As I mentioned earlier, with clear role definitions and responsibilities outlined within the prompts, the AI can process requests effectively and accurately without compromising context.
00:21:36.440
To summarize, these AI-integrated patterns can find effective applications across various domains like e-commerce, healthcare, and more. They empower developers to create more responsive and engaging user experiences while minimizing manual intervention.
00:22:51.320
I hope you'll find this information valuable and can leverage the practical examples we've discussed today. Understanding how to craft precise prompts and engaging with AI as a discrete component will bolster your development efforts with Ruby on Rails.
00:23:42.720
Finally, I'd like to remind you that my new book contains numerous concrete patterns and insights on integrating AI into application development. It's based on real projects we’ve executed at Olympia and distills key concepts that can serve to illuminate your journey with AI.