Skip to content

Releases: crmne/ruby_llm

1.1.0rc2

04 Apr 09:28
Compare
Choose a tag to compare
1.1.0rc2 Pre-release
Pre-release

RubyLLM 1.1.0.rc2: Smart Error Handling & Testing Improvements 🛠️

This second release candidate introduces a new error handling paradigm for tools, improves error parsing across providers, and enhances testing infrastructure. The focus is on making applications more resilient and developer-friendly.

🛠️ Smarter Tool Error Handling

A completely new approach to handling errors in tools that lets LLMs handle recoverable issues while bubbling up critical errors to your application:

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:)
    validate_coordinates!(latitude, longitude)
    response = Faraday.get(weather_api_url(latitude, longitude))
    
    case response.status
    when 429
      # Return errors the LLM should know about and can retry
      { error: "Rate limit exceeded. Please try again in 60 seconds." }
    when 200
      JSON.parse(response.body)
    else
      # Let serious problems bubble up
      raise "Weather API error: #{response.status}"
    end
  end
end

When to Return vs Raise Errors

  • Return errors to the LLM when:

    • Input validation fails
    • The operation can be retried (rate limits, temporary failures)
    • Alternative approaches might work
  • Let errors bubble up when:

    • The tool encounters unexpected states
    • System resources are unavailable
    • Authentication or authorization fails
    • Data integrity is compromised

🔍 Provider Improvements

  • Better error parsing for AWS Bedrock responses
  • Enhanced system prompt handling across all providers
  • with_instructions(replace: true) now available for Plain Old Ruby Objects

🧪 Testing Infrastructure

New testing capabilities focusing on error handling:

  • Added chat_error_spec to catch problems with error parsing
  • Enhanced CI workflow with prerelease version checking

📚 Documentation Updates

  • New comprehensive model information guide listing 100+ models with capabilities
  • Updated error handling guidelines
  • Streamlined contribution guidelines

This is a release candidate. Please test thoroughly, especially the new error handling features!

gem 'ruby_llm', '1.1.0.rc2'

Contributors

Thanks to everyone who contributed to this release, especially @tpaulshippy for Bedrock improvements, and @keithrbennett for the model information guide.

New Contributors

Full Changelog: 1.1.0rc1...1.1.0rc2

1.1.0rc1

02 Apr 18:19
Compare
Choose a tag to compare
1.1.0rc1 Pre-release
Pre-release

RubyLLM 1.1.0.rc1: Cloud Expansion & Better Conversations 🚀

We're excited to introduce RubyLLM 1.1.0.rc1, expanding cloud provider support and enhancing conversation management. This release candidate brings AWS Bedrock support, improved system prompts, and much more.

🌩️ AWS Bedrock Support

Access Claude models through your existing AWS infrastructure:

RubyLLM.configure do |config|
  config.bedrock_api_key = ENV.fetch('AWS_ACCESS_KEY_ID')
  config.bedrock_secret_key = ENV.fetch('AWS_SECRET_ACCESS_KEY')
  config.bedrock_region = ENV.fetch('AWS_REGION')
  config.bedrock_session_token = ENV.fetch('AWS_SESSION_TOKEN') # optional
end

# Using Claude through Bedrock
chat = RubyLLM.chat(model: 'claude-3-5-sonnet', provider: 'bedrock')

Great for teams who want to keep everything within their existing AWS environment.

🧠 Simpler System Instructions

We've introduced with_instructions for a cleaner way to set system prompts:

chat = RubyLLM.chat
  .with_instructions("You are a helpful coding assistant that specializes in Ruby")
  .ask("How would I implement a binary search tree?")

You can also explicitly replace previous instructions instead of accumulating them:

chat.with_instructions("New instructions", replace: true)

This works across all providers, with smart handling of differences between OpenAI, Anthropic, and others.

🔀 Smarter Model Resolution

Model identification is now much smarter:

  • Model Aliases: Use simple names like gpt-4o instead of gpt-4o-2024-11-20
  • Provider-Specific Matching: Target specific providers with the same base model
  • Exact Match Priority: Exact matches are prioritized over aliases
# These all work now
chat = RubyLLM.chat(model: 'claude-3-5-sonnet')
chat = RubyLLM.chat(model: 'claude-3-5-sonnet', provider: 'anthropic')
chat = RubyLLM.chat(model: 'claude-3-5-sonnet', provider: 'bedrock')

🛠️ Tool Improvements

Tools get even better with support for parameterless tools:

class RandomNumber < RubyLLM::Tool
  description "Generates a random number between 1 and 100"
  
  def execute
    rand(1..100)
  end
end

🚂 Rails Enhancements

ActiveRecord integration improvements make Rails usage even better:

# Now all these methods return self for chainability
chat = Chat.create!(model_id: 'gpt-4o-mini')
  .with_instructions("You are a helpful assistant")
  .with_tool(Calculator)
  .ask("What's 123 * 456?")

🔧 Technical Improvements

  • Fixed multimodal inputs for Bedrock Anthropic
  • Improved system prompt handling across all providers
  • Enhanced streaming functionality with better error parsing
  • Fixed model refreshing for read-only filesystems in production
  • Improvements to DeepSeek and Anthropic providers

📖 Documentation Updates

We've updated our documentation to cover:

  • Working with multiple providers
  • Using the model registry effectively
  • Deploying in production environments

This is a release candidate. Please try it out and report any issues before the final release!

gem 'ruby_llm', '1.1.0.rc1'

Contributors

Thanks to everyone who contributed to this release, especially @tpaulshippy for the AWS Bedrock implementation, @kieranklaassen for ActiveRecord improvements, and @seuros and @redox for their contributions.

What's Changed

  • Support tools without params by @redox in #62
  • Switched from git ls-files to Ruby's Dir.glob for defining spec.file by @seuros in #84
  • 16: Add support for Claude through Bedrock by @tpaulshippy in #50
  • Fix refresh of Bedrock models and remove some expired credentials from cassettes by @tpaulshippy in #89
  • fix acts_as delegation to return self instead of RubyLLM by @kieranklaassen in #82

New Contributors

Full Changelog: 1.0.1...1.1.0rc1

1.0.1

23 Mar 13:51
Compare
Choose a tag to compare

🚀 Improvements & Bug Fixes

This release has some important fixes and quality-of-life improvements:

  • Fixed temperature handling for OpenAI's o1 and o3 models (they require a temperature of 1.0, which we now normalize automatically)
  • Better tool naming with proper stripping of unsupported characters for OpenAI
  • Improved model capabilities detection for vision and function support
  • Added base64 to dependencies for Ruby 3.4.0+ compatibility
  • Enhanced Rails integration documentation with system message examples
  • Added VCR support for testing (because integration tests shouldn't require real API calls)
  • Fixed model refresh bug - no more stale model lists when you call RubyLLM.models.refresh!

📄 Documentation Enhancements

We've enhanced our documentation across the board:

  • Added a section on system prompts to the chat guide
  • Improved the contributing guidelines with model naming conventions
  • Better examples of streaming responses in the README

🧪 Testing Improvements

  • Added comprehensive specs for model filtering and chat functionalities
  • Better CI/CD workflows for version validation

🏆 Shoutouts

Thanks to our contributors for this release: @dalthon, @jaggdl, @Thomascountz, @stevegeek, @jeduardo824, @redox, and @mhmaguire. This is what makes open source great.

New Contributors

Full Changelog: 1.0.0...1.0.1

1.0.0

11 Mar 07:23
Compare
Choose a tag to compare

RubyLLM 1.0.0

A beautiful way to work with AI in Ruby. RubyLLM a unified interface to modern AI models from multiple providers with an elegant, Ruby-like API.

Features

  • Unified API for OpenAI, Anthropic Claude, Google Gemini, and DeepSeek
  • Simple conversation interface with automatic history tracking
  • Consistent streaming that works the same way across all providers
  • Built-in token tracking for cost management
  • Tool integration with a clean, Ruby-like interface
  • Rails integration with ActiveRecord persistence via acts_as_chat
  • Multimodal support for images, PDFs, and audio
  • Embeddings for vector search and semantic analysis
  • Image generation with DALL-E and other providers
  • Comprehensive error handling with specific error types
  • Minimal dependencies for a lightweight footprint

Installation

# In your Gemfile
gem 'ruby_llm'

# Or install directly
gem install ruby_llm

Quick Start

# Configure with API keys
RubyLLM.configure do |config|
  config.openai_api_key = ENV['OPENAI_API_KEY']
  config.anthropic_api_key = ENV['ANTHROPIC_API_KEY']
  config.gemini_api_key = ENV['GEMINI_API_KEY']
end

# Start chatting
chat = RubyLLM.chat
chat.ask "What's the best way to learn Ruby?"

# Or generate an image
image = RubyLLM.paint("a sunset over mountains")
image.save("sunset.png")

# Or create embeddings
embedding = RubyLLM.embed("Ruby is a programmer's best friend")

Documentation

Full documentation is available at rubyllm.com

License

Released under the MIT License.

0.1.0.pre42

26 Feb 23:08
Compare
Choose a tag to compare
0.1.0.pre42 Pre-release
Pre-release