What LLMs can (and can’t) do for your Ruby projects today
LRUG - May 2025
lbarasti
Confronting the Anxiety





Confronting the Anxiety






Confronting the Anxiety






Our angle today
Focus on what we can control.
Consider the adoption of techniques that look
- Effective
- Practical
- Low risk
- Fun
battle-tested
improves your day-to-day
internal use / read-only
think beyond current limitations
for Tools
3 use cases
class Weather < RubyLLM::Tool
description 'Gets current weather for a location'
param :latitude, desc: 'Latitude (e.g., 52.5200)'
param :longitude, desc: 'Longitude (e.g., 13.4050)'
end
Defining a tool in Ruby LLM
What
class Weather < RubyLLM::Tool
description 'Gets current weather for a location'
param :latitude, desc: 'Latitude (e.g., 52.5200)'
param :longitude, desc: 'Longitude (e.g., 13.4050)'
def execute(latitude:, longitude:)
url = "#{METEO_API}?lat=#{latitude}&lon=#{longitude}"
response = Faraday.get(url)
JSON.parse(response.body)
end
end
Defining a tool in Ruby LLM
class Weather < RubyLLM::Tool
description 'Gets current weather for a location'
param :latitude, desc: 'Latitude (e.g., 52.5200)'
param :longitude, desc: 'Longitude (e.g., 13.4050)'
def execute(latitude:, longitude:)
url = "#{METEO_API}?lat=#{latitude}&lon=#{longitude}"
response = Faraday.get(url)
JSON.parse(response.body)
rescue StandardError => e
{ error: e.message }
end
end
Defining a tool in Ruby LLM
class Weather < RubyLLM::Tool
description 'Gets current weather for a location'
param :latitude, desc: 'Latitude (e.g., 52.5200)'
param :longitude, desc: 'Longitude (e.g., 13.4050)'
def execute(latitude:, longitude:)
url = "#{METEO_API}?lat=#{latitude}&lon=#{longitude}"
response = Faraday.get(url)
JSON.parse(response.body)
rescue StandardError => e
{ error: e.message }
end
end
Defining a tool in Ruby LLM
What
Creating a chat with RubyLLM
How
require 'ruby_llm'
# require tools...
How
require 'ruby_llm'
# require tools...
chat = RubyLLM.chat(model: 'gpt-4o-mini')
weather_tool = Weather.new
search_tool = SemanticSearch.new
Creating a chat with RubyLLM
How
require 'ruby_llm'
# require tools...
chat = RubyLLM.chat(model: 'gpt-4o-mini')
weather_tool = Weather.new
search_tool = SemanticSearch.new
instructions = "You're a helpful assistant"
chat.with_instructions(instructions)
.with_tools(weather_tool, search_tool)
Creating a chat with RubyLLM
How
chat.with_instructions(instructions)
.with_tools(weather_tool, search_tool)
response = chat.ask(
"what's the weather like in London?")
puts response.content
# => The temperature is 15 degrees...
Creating a chat with RubyLLM
LLMs calling tools

How
LLMs calling tools

LLMs calling tools

LLMs calling tools

How
-
Making things upGuessing - Acting as a router
- Converting natural language into code (and back)
Tool calling...
... Leverages some LLMs strengths 👀
Why
Tool calling...
... Addresses some LLMs weaknesses
Why
- No agency in the real world
- Hallucinations
- Failing at elementary maths
Concept
Ruby Assistant
A terminal-based chatbot that knows about
🌦️ the weather
💿 your database
📚 ruby gems
Concept
Ruby Assistant
💎 RubyLLM
🤖 OpenAI
🌐 pgvector
Powered by
1. (Hand-wavy) API integrations
🙋 What's the weather in Rome?
Weather tool: api.open-meteo.com/v1/forecast?
latitude=#{latitude}&longitude=#{longitude}
[⠙] Thinking...Fetching weather for 41.9028, 12.4964
[⠇] Thinking...
🤖 The current weather in Rome is as follows:
- Temperature: 18.5°C
- Wind Speed: 12.7 km/h
2. Natural Language → SQL
🙋 Who submitted the last order in the database?
[⠋] Thinking...Executing query:
SELECT users.username FROM orders JOIN users ON
orders.user_id = users.id ORDER BY orders.order_date DESC
LIMIT 1;
[⠋] Thinking...
🤖 The last order in the database was submitted by the user "alex_wilson."
3. Semantic search
🙋 Does ruby_llm support image generation?
[⠋] Thinking...Query: "ruby_llm image generation"
[⠋] Thinking...
🤖 Yes, RubyLLM supports image generation. You can create images using the method RubyLLM.paint
.
References
- ruby_assistant - companion repository to my talk
- ruby_llm - unified Ruby interface to various LLM models
- text-to-SQL
- paper: C3: Zero-shot Text-to-SQL with ChatGPT (2023)
- Embeddings and semantic search
- LLM embeddings explained by Hesam Sheikh Hassani
- pgvector - Open-source vector similarity search for Postgres
- Extensive intro to using PostgreSQL as vector database by Timescale
- Building an AI-powered Slackbot by Amanda Bizzinotto
- OpenAI model (cost) comparison
Agent failures
Costs
Open-weight vs proprietary models
Privacy
Infosec
MCP
Bonus material
MCP example

Considerations on cost

What LLMs can (and can't) do for your Ruby project today
By Lorenzo Barasti
What LLMs can (and can't) do for your Ruby project today
- 241