repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
hotwired/turbo-rails | https://github.com/hotwired/turbo-rails/blob/16f76133cbef0cfec65a3c8693d795670fb725ac/test/streams/action_helper_test.rb | test/streams/action_helper_test.rb | require "test_helper"
class Turbo::ActionHelperTest < ActionCable::Channel::TestCase
include Turbo::Streams::ActionHelper
test "target responds to #to_key" do
message = Message.new(id: 1)
stream = "<turbo-stream action=\"append\" target=\"message_1\"><template></template></turbo-stream>"
assert_equa... | ruby | MIT | 16f76133cbef0cfec65a3c8693d795670fb725ac | 2026-01-04T15:56:20.581696Z | false |
hotwired/turbo-rails | https://github.com/hotwired/turbo-rails/blob/16f76133cbef0cfec65a3c8693d795670fb725ac/test/streams/streams_helper_test.rb | test/streams/streams_helper_test.rb | require "test_helper"
class TestChannel < ApplicationCable::Channel; end
class Turbo::StreamsHelperTest < ActionView::TestCase
class Component
include ActiveModel::Model
attr_accessor :id, :content
def render_in(view_context)
content
end
def to_key
[id]
end
end
attr_acces... | ruby | MIT | 16f76133cbef0cfec65a3c8693d795670fb725ac | 2026-01-04T15:56:20.581696Z | false |
hotwired/turbo-rails | https://github.com/hotwired/turbo-rails/blob/16f76133cbef0cfec65a3c8693d795670fb725ac/lib/turbo-rails.rb | lib/turbo-rails.rb | require "turbo/engine"
require "active_support/core_ext/module/attribute_accessors_per_thread"
module Turbo
extend ActiveSupport::Autoload
mattr_accessor :draw_routes, default: true
thread_mattr_accessor :current_request_id
class << self
attr_writer :signed_stream_verifier_key
def signed_stream_ver... | ruby | MIT | 16f76133cbef0cfec65a3c8693d795670fb725ac | 2026-01-04T15:56:20.581696Z | false |
hotwired/turbo-rails | https://github.com/hotwired/turbo-rails/blob/16f76133cbef0cfec65a3c8693d795670fb725ac/lib/turbo/system_test_helper.rb | lib/turbo/system_test_helper.rb | module Turbo::SystemTestHelper
# Delay until every `<turbo-cable-stream-source>` element present in the page
# is ready to receive broadcasts
#
# test "renders broadcasted Messages" do
# message = Message.new content: "Hello, from Action Cable"
#
# visit "/"
# click_link "All Messages"
#... | ruby | MIT | 16f76133cbef0cfec65a3c8693d795670fb725ac | 2026-01-04T15:56:20.581696Z | false |
hotwired/turbo-rails | https://github.com/hotwired/turbo-rails/blob/16f76133cbef0cfec65a3c8693d795670fb725ac/lib/turbo/version.rb | lib/turbo/version.rb | module Turbo
VERSION = "2.0.20"
end
| ruby | MIT | 16f76133cbef0cfec65a3c8693d795670fb725ac | 2026-01-04T15:56:20.581696Z | false |
hotwired/turbo-rails | https://github.com/hotwired/turbo-rails/blob/16f76133cbef0cfec65a3c8693d795670fb725ac/lib/turbo/test_assertions.rb | lib/turbo/test_assertions.rb | module Turbo
module TestAssertions
extend ActiveSupport::Concern
included do
# FIXME: Should happen in Rails at a different level
delegate :dom_id, :dom_class, to: ActionView::RecordIdentifier
end
# Assert that the rendered fragment of HTML contains a `<turbo-stream>`
# element.
... | ruby | MIT | 16f76133cbef0cfec65a3c8693d795670fb725ac | 2026-01-04T15:56:20.581696Z | false |
hotwired/turbo-rails | https://github.com/hotwired/turbo-rails/blob/16f76133cbef0cfec65a3c8693d795670fb725ac/lib/turbo/engine.rb | lib/turbo/engine.rb | require "rails/engine"
module Turbo
class Engine < Rails::Engine
isolate_namespace Turbo
config.eager_load_namespaces << Turbo
config.turbo = ActiveSupport::OrderedOptions.new
config.turbo.test_connect_after_actions = %i[visit]
config.autoload_once_paths = %W(
#{root}/app/channels
#{r... | ruby | MIT | 16f76133cbef0cfec65a3c8693d795670fb725ac | 2026-01-04T15:56:20.581696Z | false |
hotwired/turbo-rails | https://github.com/hotwired/turbo-rails/blob/16f76133cbef0cfec65a3c8693d795670fb725ac/lib/turbo/broadcastable/test_helper.rb | lib/turbo/broadcastable/test_helper.rb | module Turbo
module Broadcastable
module TestHelper
extend ActiveSupport::Concern
included do
include ActionCable::TestHelper
include Turbo::Streams::StreamName
end
# Asserts that `<turbo-stream>` elements were broadcast over Action Cable
#
# ==== Arguments
... | ruby | MIT | 16f76133cbef0cfec65a3c8693d795670fb725ac | 2026-01-04T15:56:20.581696Z | false |
hotwired/turbo-rails | https://github.com/hotwired/turbo-rails/blob/16f76133cbef0cfec65a3c8693d795670fb725ac/lib/turbo/test_assertions/integration_test_assertions.rb | lib/turbo/test_assertions/integration_test_assertions.rb | module Turbo
module TestAssertions
module IntegrationTestAssertions
# Assert that the Turbo Stream request's response body's HTML contains a
# `<turbo-stream>` element.
#
# ==== Options
#
# * <tt>:status</tt> [Integer, Symbol] the HTTP response status
# * <tt>:action</tt>... | ruby | MIT | 16f76133cbef0cfec65a3c8693d795670fb725ac | 2026-01-04T15:56:20.581696Z | false |
hotwired/turbo-rails | https://github.com/hotwired/turbo-rails/blob/16f76133cbef0cfec65a3c8693d795670fb725ac/lib/install/turbo_with_bun.rb | lib/install/turbo_with_bun.rb | if (js_entrypoint_path = Rails.root.join("app/javascript/application.js")).exist?
say "Import Turbo"
append_to_file "app/javascript/application.js", %(import "@hotwired/turbo-rails"\n)
else
say "You must import @hotwired/turbo-rails in your JavaScript entrypoint file", :red
end
say "Install Turbo"
run "bun add @... | ruby | MIT | 16f76133cbef0cfec65a3c8693d795670fb725ac | 2026-01-04T15:56:20.581696Z | false |
hotwired/turbo-rails | https://github.com/hotwired/turbo-rails/blob/16f76133cbef0cfec65a3c8693d795670fb725ac/lib/install/turbo_with_node.rb | lib/install/turbo_with_node.rb | if (js_entrypoint_path = Rails.root.join("app/javascript/application.js")).exist?
say "Import Turbo"
append_to_file "app/javascript/application.js", %(import "@hotwired/turbo-rails"\n)
else
say "You must import @hotwired/turbo-rails in your JavaScript entrypoint file", :red
end
say "Install Turbo"
run "yarn add ... | ruby | MIT | 16f76133cbef0cfec65a3c8693d795670fb725ac | 2026-01-04T15:56:20.581696Z | false |
hotwired/turbo-rails | https://github.com/hotwired/turbo-rails/blob/16f76133cbef0cfec65a3c8693d795670fb725ac/lib/install/turbo_with_importmap.rb | lib/install/turbo_with_importmap.rb | say "Import Turbo"
append_to_file "app/javascript/application.js", %(import "@hotwired/turbo-rails"\n)
say "Pin Turbo"
append_to_file "config/importmap.rb", %(pin "@hotwired/turbo-rails", to: "turbo.min.js"\n)
| ruby | MIT | 16f76133cbef0cfec65a3c8693d795670fb725ac | 2026-01-04T15:56:20.581696Z | false |
hotwired/turbo-rails | https://github.com/hotwired/turbo-rails/blob/16f76133cbef0cfec65a3c8693d795670fb725ac/config/routes.rb | config/routes.rb | Rails.application.routes.draw do
get "recede_historical_location", to: "turbo/native/navigation#recede", as: :turbo_recede_historical_location
get "resume_historical_location", to: "turbo/native/navigation#resume", as: :turbo_resume_historical_location
get "refresh_historical_location", to: "turbo/native/navigati... | ruby | MIT | 16f76133cbef0cfec65a3c8693d795670fb725ac | 2026-01-04T15:56:20.581696Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm_spec.rb | spec/ruby_llm_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe RubyLLM do
describe '.logger' do
let(:logger) { instance_double(Logger) }
let(:log_file) { double }
let(:log_level) { double }
before do
described_class.instance_variable_set(:@config, nil)
described_class.instance_varia... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/rails_helper.rb | spec/rails_helper.rb | # frozen_string_literal: true
ENV['RAILS_ENV'] = 'test'
require_relative 'spec_helper'
require_relative 'dummy/config/application'
require 'ruby_llm/railtie'
Rails.application.initialize! unless Rails.application.initialized?
# Drop and recreate database to avoid foreign key constraint issues
begin
ActiveRecord::... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/spec_helper.rb | spec/spec_helper.rb | # frozen_string_literal: true
require 'dotenv/load'
require 'simplecov'
require 'simplecov-cobertura'
require 'codecov'
require 'vcr'
require 'bundler/setup'
require 'fileutils'
require 'ruby_llm'
require 'webmock/rspec'
require 'active_support'
require 'active_support/core_ext'
require_relative 'support/rspec_configu... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/support/vcr_configuration.rb | spec/support/vcr_configuration.rb | # frozen_string_literal: true
# VCR Configuration
VCR.configure do |config|
config.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
config.hook_into :webmock
config.configure_rspec_metadata!
# Don't record new HTTP interactions when running in CI
config.default_cassette_options = {
record: ENV['CI']... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/support/simplecov_configuration.rb | spec/support/simplecov_configuration.rb | # frozen_string_literal: true
unless ENV['SKIP_COVERAGE']
SimpleCov.start do
add_filter '/spec/'
add_filter '/vendor/'
add_filter 'acts_as_legacy.rb'
add_filter '/lib/generators/'
enable_coverage :branch
formatter SimpleCov::Formatter::MultiFormatter.new(
[
SimpleCov::Formatte... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/support/streaming_error_helpers.rb | spec/support/streaming_error_helpers.rb | # frozen_string_literal: true
module StreamingErrorHelpers
ERROR_HANDLING_CONFIGS = {
anthropic: {
url: 'https://api.anthropic.com/v1/messages',
error_response: {
type: 'error',
error: {
type: 'overloaded_error',
message: 'Overloaded'
}
},
chunk... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/support/rspec_configuration.rb | spec/support/rspec_configuration.rb | # frozen_string_literal: true
require 'fileutils'
RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = '.rspec_status'
# Disable RSpec exposing methods globally on `Module` and `main`
config.disable_monkey_patching!
config.expect_... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/support/models_to_test.rb | spec/support/models_to_test.rb | # frozen_string_literal: true
CHAT_MODELS = [
{ provider: :openrouter, model: 'claude-haiku-4-5' },
{ provider: :bedrock, model: 'claude-3-5-haiku' },
{ provider: :deepseek, model: 'deepseek-chat' },
{ provider: :gemini, model: 'gemini-2.5-flash' },
{ provider: :gpustack, model: 'qwen3' },
{ provider: :mis... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/support/rubyllm_configuration.rb | spec/support/rubyllm_configuration.rb | # frozen_string_literal: true
RubyLLM.configure do |config|
config.model_registry_class = 'Model'
end
RSpec.shared_context 'with configured RubyLLM' do
before do
RubyLLM.configure do |config|
config.openai_api_key = ENV.fetch('OPENAI_API_KEY', 'test')
config.anthropic_api_key = ENV.fetch('ANTHROPI... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/support/generator_test_helpers.rb | spec/support/generator_test_helpers.rb | # frozen_string_literal: true
require 'English'
module GeneratorTestHelpers
def self.cleanup_test_app(app_path)
FileUtils.rm_rf(app_path)
end
def self.create_test_app(name, template:, template_path:)
template_file = File.join(template_path, template)
Bundler.with_unbundled_env do
Dir.chdir(Di... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/fixtures/templates/default_models_template.rb | spec/fixtures/templates/default_models_template.rb | # frozen_string_literal: true
gem 'ruby_llm', path: ENV['RUBYLLM_PATH'] || '../../../..'
after_bundle do
generate 'ruby_llm:install'
rails_command 'db:migrate'
generate 'ruby_llm:chat_ui'
end
| ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/fixtures/templates/namespaced_models_template.rb | spec/fixtures/templates/namespaced_models_template.rb | # frozen_string_literal: true
gem 'ruby_llm', path: ENV['RUBYLLM_PATH'] || '../../../..'
after_bundle do
generate 'ruby_llm:install',
'chat:Llm::Chat',
'message:Llm::Message',
'model:Llm::Model',
'tool_call:Llm::ToolCall'
rails_command 'db:migrate'
generate 'ruby_llm:... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/chat_functions_spec.rb | spec/ruby_llm/chat_functions_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe RubyLLM::Chat do
include_context 'with configured RubyLLM'
describe '#with_tool' do
it 'adds tools regardless of model capabilities' do
# Create a non-function-calling model by patching the supports_functions attribute
model = Rub... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/error_handling_spec.rb | spec/ruby_llm/error_handling_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe RubyLLM::Error do
it 'handles invalid API keys gracefully' do
RubyLLM.configure do |config|
config.openai_api_key = 'invalid-key'
end
chat = RubyLLM.chat(model: 'gpt-4.1-nano')
expect do
chat.ask('Hello')
end.to rai... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/embeddings_spec.rb | spec/ruby_llm/embeddings_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe RubyLLM::Embedding do
include_context 'with configured RubyLLM'
let(:test_text) { "Ruby is a programmer's best friend" }
let(:test_texts) { %w[Ruby Python JavaScript] }
let(:test_dimensions) { 768 }
describe 'basic functionality' do
EM... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/chat_request_options_spec.rb | spec/ruby_llm/chat_request_options_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe RubyLLM::Chat do
include_context 'with configured RubyLLM'
describe 'with params' do
# Supported params vary by provider, and to lesser degree, by model.
# Providers [:openai, :ollama, :deepseek] support {response_format: {type: 'json_ob... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/models_spec.rb | spec/ruby_llm/models_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'tempfile'
RSpec.describe RubyLLM::Models do
include_context 'with configured RubyLLM'
# Reset Models singleton after tests that modify it
after do
described_class.instance_variable_set(:@instance, nil)
end
describe 'filtering and chaining' d... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/chat_error_spec.rb | spec/ruby_llm/chat_error_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec::Matchers.define :include_words do |*words|
match do |actual|
words.all? { |word| actual.downcase.include?(word.downcase) }
end
failure_message do |actual|
"expected '#{actual}' to include all words: #{words.join(', ')}"
end
end
RSpec::Matche... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/chat_content_spec.rb | spec/ruby_llm/chat_content_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'action_dispatch/http/upload'
RSpec.describe RubyLLM::Chat do # rubocop:disable RSpec/MultipleMemoizedHelpers
include_context 'with configured RubyLLM'
let(:image_path) { File.expand_path('../fixtures/ruby.png', __dir__) }
let(:video_path) { File.expan... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/context_spec.rb | spec/ruby_llm/context_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe RubyLLM::Context do
include_context 'with configured RubyLLM'
describe '#initialize' do
it 'creates a copy of the global configuration' do
# Get current config values
original_model = RubyLLM.config.default_model
original_ap... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/moderation_spec.rb | spec/ruby_llm/moderation_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe RubyLLM::Moderation do
include_context 'with configured RubyLLM'
let(:test_input) { 'This is a safe message' }
describe '.moderate' do
context 'with OpenAI provider' do
it 'moderates content and returns a Moderation instance' do
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/utils_spec.rb | spec/ruby_llm/utils_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe RubyLLM::Utils do
describe '.hash_get' do
it 'fetches a value using a symbol when the hash key is stored as a string' do
hash = { 'name' => 'RubyLLM' }
expect(described_class.hash_get(hash, :name)).to eq('RubyLLM')
end
it '... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/tool_spec.rb | spec/ruby_llm/tool_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe RubyLLM::Tool do
describe '#name' do
it 'converts class name to snake_case and removes _tool suffix' do
stub_const('SampleTool', Class.new(described_class))
expect(SampleTool.new.name).to eq('sample')
end
# rubocop:disable N... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/transcription_spec.rb | spec/ruby_llm/transcription_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe RubyLLM::Transcription do
include_context 'with configured RubyLLM'
let(:audio_path) { File.expand_path('../fixtures/ruby.wav', __dir__) }
describe 'basic functionality' do
TRANSCRIPTION_MODELS.each do |config|
provider = config[:pro... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/chat_spec.rb | spec/ruby_llm/chat_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe RubyLLM::Chat do
include_context 'with configured RubyLLM'
describe 'basic chat functionality' do
CHAT_MODELS.each do |model_info|
model = model_info[:model]
provider = model_info[:provider]
it "#{provider}/#{model} can have... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/chat_schema_spec.rb | spec/ruby_llm/chat_schema_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe RubyLLM::Chat do
include_context 'with configured RubyLLM'
describe '#with_schema' do
let(:person_schema) do
{
type: 'object',
properties: {
name: { type: 'string' },
age: { type: 'integer' }
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/chat_model_aliases_spec.rb | spec/ruby_llm/chat_model_aliases_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe RubyLLM::Chat do
include_context 'with configured RubyLLM'
it 'finds models by alias name' do
# Core test - can we find a model using just its alias?
chat = RubyLLM.chat(model: 'claude-haiku-4-5')
expect(chat.model.id).to eq('claude-h... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/chat_assume_model_exists_spec.rb | spec/ruby_llm/chat_assume_model_exists_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe RubyLLM::Chat do
include_context 'with configured RubyLLM'
describe '#assume_model_exists' do
let(:real_model) { 'gpt-4.1-nano' }
let(:custom_model) { 'my-custom-model' }
let(:provider) { 'openai' }
# Keep a reference to the origi... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/image_generation_spec.rb | spec/ruby_llm/image_generation_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'tempfile'
def save_and_verify_image(image)
# Create a temp file to save to
temp_file = Tempfile.new(['image', '.png'])
temp_path = temp_file.path
temp_file.close
begin
saved_path = image.save(temp_path)
expect(saved_path).to eq(temp_path)... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/chat_streaming_spec.rb | spec/ruby_llm/chat_streaming_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe RubyLLM::Chat do
include_context 'with configured RubyLLM'
include StreamingErrorHelpers
describe 'streaming responses' do
CHAT_MODELS.each do |model_info|
model = model_info[:model]
provider = model_info[:provider]
it "#{... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/models_json_validation_spec.rb | spec/ruby_llm/models_json_validation_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'json-schema'
RSpec.describe RubyLLM::Models do
let(:schema_path) { described_class.schema_file }
let(:models_json_path) { RubyLLM.config.model_registry_file }
it 'validates that models.json conforms to the schema' do
models_data = JSON.parse(File... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/models_local_refresh_spec.rb | spec/ruby_llm/models_local_refresh_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe RubyLLM::Models do
include_context 'with configured RubyLLM'
describe 'local provider model fetching' do
describe '.refresh!' do
context 'with default parameters' do # rubocop:disable RSpec/NestedGroups
it 'includes local provid... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/models_refresh_spec.rb | spec/ruby_llm/models_refresh_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe RubyLLM::Models do
include_context 'with configured RubyLLM'
describe 'models.json structure validation' do
let(:models_json_path) { RubyLLM.config.model_registry_file }
let(:models_data) { JSON.parse(File.read(models_json_path)) }
i... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/chat_tools_spec.rb | spec/ruby_llm/chat_tools_spec.rb | # frozen_string_literal: true
require 'spec_helper'
def supports_functions?(provider, model)
return false if RubyLLM::Provider.providers[provider]&.local?
model_info = RubyLLM.models.find(model)
skip "#{model} doesn't support function calling" unless model_info&.supports_functions?
end
RSpec.describe RubyLLM:... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/chat_headers_spec.rb | spec/ruby_llm/chat_headers_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe RubyLLM::Chat do
include_context 'with configured RubyLLM'
describe '#with_headers' do
it 'stores headers' do
chat = RubyLLM.chat.with_headers('X-Custom-Header' => 'value')
expect(chat.headers).to eq('X-Custom-Header' => 'value')
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/generators/chat_ui_generator_spec.rb | spec/ruby_llm/generators/chat_ui_generator_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'fileutils'
require 'generators/ruby_llm/chat_ui/chat_ui_generator'
require_relative '../../support/generator_test_helpers'
RSpec.describe RubyLLM::Generators::ChatUIGenerator, :generator, type: :generator do
include GeneratorTestHelpers
let(:rails_root... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/generators/install_generator_spec.rb | spec/ruby_llm/generators/install_generator_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'fileutils'
require 'generators/ruby_llm/install/install_generator'
require_relative '../../support/generator_test_helpers'
RSpec.describe RubyLLM::Generators::InstallGenerator, :generator, type: :generator do
include GeneratorTestHelpers
let(:template_... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/providers/open_ai/capabilities_spec.rb | spec/ruby_llm/providers/open_ai/capabilities_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe RubyLLM::Providers::OpenAI::Capabilities do
describe '.normalize_temperature' do
it 'forces temperature to 1.0 for O1 models' do
%w[o1 o1-mini o1-preview o3-mini].each do |model|
expect(described_class.normalize_temperature(0.7, mo... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/providers/open_ai/chat_spec.rb | spec/ruby_llm/providers/open_ai/chat_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe RubyLLM::Providers::OpenAI::Chat do
describe '.parse_completion_response' do
it 'captures cached token information when present' do
response_body = {
'model' => 'gpt-4.1-nano',
'choices' => [
{
'messag... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/providers/bedrock/models_spec.rb | spec/ruby_llm/providers/bedrock/models_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe RubyLLM::Providers::Bedrock::Models do
let(:slug) { 'bedrock' }
let(:capabilities) { class_double(RubyLLM::Providers::Bedrock::Capabilities) }
before do
allow(capabilities).to receive_messages(
context_window_for: 4096,
max_toke... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/providers/anthropic/tools_spec.rb | spec/ruby_llm/providers/anthropic/tools_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe RubyLLM::Providers::Anthropic::Tools do
let(:tools) { described_class }
describe '.format_tool_call' do
let(:msg) do
instance_double(RubyLLM::Message,
content: 'Some content',
tool_calls: {
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/providers/anthropic/content_spec.rb | spec/ruby_llm/providers/anthropic/content_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe RubyLLM::Providers::Anthropic::Content do
describe '.new' do
it 'builds a raw text block' do
raw = described_class.new('Hello world')
expect(raw).to be_a(RubyLLM::Content::Raw)
expect(raw.value).to eq([{ type: 'text', text: 'H... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/providers/anthropic/chat_spec.rb | spec/ruby_llm/providers/anthropic/chat_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe RubyLLM::Providers::Anthropic::Chat do
describe '.render_payload' do
let(:model) { instance_double(RubyLLM::Model::Info, id: 'claude-sonnet-4-5', max_tokens: nil) }
it 'embeds raw system content blocks unchanged' do
system_raw = RubyL... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/providers/anthropic/media_spec.rb | spec/ruby_llm/providers/anthropic/media_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe RubyLLM::Providers::Anthropic::Media do
describe '.format_content' do
let(:pdf_path) { File.join('spec', 'fixtures', 'sample.pdf') }
it 'serializes RubyLLM::Content with attachments into Anthropic blocks' do
content = RubyLLM::Content... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/providers/gemini/tools_spec.rb | spec/ruby_llm/providers/gemini/tools_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe RubyLLM::Providers::Gemini::Tools do
include_context 'with configured RubyLLM'
let(:test_obj) do
Object.new.tap { |obj| obj.extend(described_class) }
end
describe '#extract_tool_calls' do
it 'captures all function calls returned in a... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/providers/gemini/chat_spec.rb | spec/ruby_llm/providers/gemini/chat_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe RubyLLM::Providers::Gemini::Chat do
include_context 'with configured RubyLLM'
# Create a test object that includes the module to access private methods
let(:test_obj) do
Object.new.tap do |obj|
obj.extend(RubyLLM::Providers::Gemini::M... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/providers/gemini/streaming_spec.rb | spec/ruby_llm/providers/gemini/streaming_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe RubyLLM::Providers::Gemini::Streaming do
include_context 'with configured RubyLLM'
it 'correctly sums candidatesTokenCount and thoughtsTokenCount in streaming' do
chat = RubyLLM.chat(model: 'gemini-2.5-flash', provider: :gemini)
chunks =... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/active_record/acts_as_spec.rb | spec/ruby_llm/active_record/acts_as_spec.rb | # frozen_string_literal: true
require 'rails_helper'
RSpec.describe RubyLLM::ActiveRecord::ActsAs do
include_context 'with configured RubyLLM'
let(:model) { 'gpt-4.1-nano' }
class Calculator < RubyLLM::Tool # rubocop:disable Lint/ConstantDefinitionInBlock,RSpec/LeakyConstantDeclaration
description 'Perfor... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/active_record/acts_as_attachment_spec.rb | spec/ruby_llm/active_record/acts_as_attachment_spec.rb | # frozen_string_literal: true
require 'rails_helper'
RSpec.describe RubyLLM::ActiveRecord::ActsAs do
include_context 'with configured RubyLLM'
let(:image_path) { File.expand_path('../../fixtures/ruby.png', __dir__) }
let(:pdf_path) { File.expand_path('../../fixtures/sample.pdf', __dir__) }
let(:model) { 'gpt... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/active_record/acts_as_model_spec.rb | spec/ruby_llm/active_record/acts_as_model_spec.rb | # frozen_string_literal: true
require 'rails_helper'
RSpec.describe RubyLLM::ActiveRecord::ActsAs do
include_context 'with configured RubyLLM'
describe 'acts_as_model' do
let(:model_class) do
stub_const('TestModel', Class.new(ActiveRecord::Base) do
self.table_name = 'models'
acts_as_mod... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/ruby_llm/active_record/acts_as_with_context_spec.rb | spec/ruby_llm/active_record/acts_as_with_context_spec.rb | # frozen_string_literal: true
require 'rails_helper'
RSpec.describe RubyLLM::ActiveRecord::ActsAs do
let(:model) { 'gpt-4.1-nano' }
describe 'when global configuration is missing' do
around do |example|
# Save current config
original_config = RubyLLM.instance_variable_get(:@config)
# Reset... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/dummy/app/controllers/application_controller.rb | spec/dummy/app/controllers/application_controller.rb | # frozen_string_literal: true
class ApplicationController < ActionController::API
end
| ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/dummy/app/models/chat.rb | spec/dummy/app/models/chat.rb | # frozen_string_literal: true
class Chat < ApplicationRecord
acts_as_chat
end
| ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/dummy/app/models/message.rb | spec/dummy/app/models/message.rb | # frozen_string_literal: true
class Message < ApplicationRecord
acts_as_message
has_many_attached :attachments
end
| ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/dummy/app/models/application_record.rb | spec/dummy/app/models/application_record.rb | # frozen_string_literal: true
class ApplicationRecord < ActiveRecord::Base
primary_abstract_class
end
| ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/dummy/app/models/tool_call.rb | spec/dummy/app/models/tool_call.rb | # frozen_string_literal: true
class ToolCall < ApplicationRecord
acts_as_tool_call
end
| ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/dummy/app/models/model.rb | spec/dummy/app/models/model.rb | # frozen_string_literal: true
class Model < ApplicationRecord
acts_as_model
end
| ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/dummy/db/seeds.rb | spec/dummy/db/seeds.rb | # frozen_string_literal: true
# This file should ensure the existence of records required to run the application in every environment (production,
# development, test). The code here should be idempotent so that it can be executed at any point in every environment.
# The data can then be loaded with the bin/rails db:s... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/dummy/db/schema.rb | spec/dummy/db/schema.rb | # frozen_string_literal: true
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define yo... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/dummy/db/migrate/20251021170000_add_v1_9_columns.rb | spec/dummy/db/migrate/20251021170000_add_v1_9_columns.rb | # frozen_string_literal: true
class AddV19Columns < ActiveRecord::Migration[7.0]
def change
return if column_exists?(:messages, :cached_tokens)
add_column :messages, :cached_tokens, :integer
add_column :messages, :cache_creation_tokens, :integer
add_column :messages, :content_raw, :json
end
end
| ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/dummy/db/migrate/20250602133502_create_tables.rb | spec/dummy/db/migrate/20250602133502_create_tables.rb | # frozen_string_literal: true
class CreateTables < ActiveRecord::Migration[7.0]
def change
# Create models table first (for foreign key references)
create_table :models do |t|
t.string :model_id, null: false
t.string :name, null: false
t.string :provider, null: false
t.string :family
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/dummy/db/migrate/20250602134116_create_active_storage_tables.active_storage.rb | spec/dummy/db/migrate/20250602134116_create_active_storage_tables.active_storage.rb | # frozen_string_literal: true
# This migration comes from active_storage (originally 20170806125915)
class CreateActiveStorageTables < ActiveRecord::Migration[7.0]
def change
# Use Active Record's configured type for primary and foreign keys
primary_key_type, foreign_key_type = primary_and_foreign_key_types
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/dummy/config/application.rb | spec/dummy/config/application.rb | # frozen_string_literal: true
require_relative 'boot'
require 'rails'
require 'active_model/railtie'
require 'active_record/railtie'
require 'active_storage/engine'
require 'action_controller/railtie'
Bundler.require(*Rails.groups)
module Dummy
class Application < Rails::Application
config.load_defaults Rails... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/dummy/config/environment.rb | spec/dummy/config/environment.rb | # frozen_string_literal: true
# Load the Rails application.
require_relative 'application'
# Initialize the Rails application.
Rails.application.initialize! unless Rails.application.initialized?
| ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/dummy/config/puma.rb | spec/dummy/config/puma.rb | # frozen_string_literal: true
# This configuration file will be evaluated by Puma. The top-level methods that
# are invoked here are part of Puma's configuration DSL. For more information
# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
#
# Puma starts a configurable number of processes (wo... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/dummy/config/routes.rb | spec/dummy/config/routes.rb | # frozen_string_literal: true
Rails.application.routes.draw do
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
# Can be used by load balancers and uptime monitors to ver... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/dummy/config/boot.rb | spec/dummy/config/boot.rb | # frozen_string_literal: true
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup' # Set up gems listed in the Gemfile.
| ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/dummy/config/initializers/filter_parameter_logging.rb | spec/dummy/config/initializers/filter_parameter_logging.rb | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file.
# Use this to limit dissemination of sensitive information.
# See the ActiveSupport::ParameterFilter documentation for ... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/dummy/config/initializers/inflections.rb | spec/dummy/config/initializers/inflections.rb | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflec... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/dummy/config/initializers/ruby_llm.rb | spec/dummy/config/initializers/ruby_llm.rb | # frozen_string_literal: true
RubyLLM.configure do |config|
# Use new acts_as API for tests
config.use_new_acts_as = true
end
| ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/dummy/config/initializers/cors.rb | spec/dummy/config/initializers/cors.rb | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Avoid CORS issues when API is called from the frontend app.
# Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin Ajax requests.
# Read more: https://github.com/cyu/rack-cors
# Rails.application.confi... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/dummy/config/environments/test.rb | spec/dummy/config/environments/test.rb | # frozen_string_literal: true
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
Rails.applic... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/dummy/config/environments/development.rb | spec/dummy/config/environments/development.rb | # frozen_string_literal: true
require 'active_support/core_ext/integer/time'
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Make code changes take effect immediately without server restart.
config.enable_reloading = true
# Do not eager lo... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/spec/dummy/config/environments/production.rb | spec/dummy/config/environments/production.rb | # frozen_string_literal: true
require 'active_support/core_ext/integer/time'
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.enable_reloading = false
# Eager load code on boot for better perfor... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm.rb | lib/ruby_llm.rb | # frozen_string_literal: true
require 'base64'
require 'event_stream_parser'
require 'faraday'
require 'faraday/multipart'
require 'faraday/retry'
require 'json'
require 'logger'
require 'marcel'
require 'securerandom'
require 'zeitwerk'
loader = Zeitwerk::Loader.for_gem
loader.inflector.inflect(
'ruby_llm' => 'Rub... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/generators/ruby_llm/generator_helpers.rb | lib/generators/ruby_llm/generator_helpers.rb | # frozen_string_literal: true
module RubyLLM
module Generators
# Shared helpers for RubyLLM generators
module GeneratorHelpers
def parse_model_mappings
@model_names = {
chat: 'Chat',
message: 'Message',
tool_call: 'ToolCall',
model: 'Model'
}
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/generators/ruby_llm/upgrade_to_v1_7/upgrade_to_v1_7_generator.rb | lib/generators/ruby_llm/upgrade_to_v1_7/upgrade_to_v1_7_generator.rb | # frozen_string_literal: true
require 'rails/generators'
require 'rails/generators/active_record'
require_relative '../generator_helpers'
module RubyLLM
module Generators
# Generator to upgrade existing RubyLLM apps to v1.7 with new Rails-like API
class UpgradeToV17Generator < Rails::Generators::Base
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/generators/ruby_llm/chat_ui/chat_ui_generator.rb | lib/generators/ruby_llm/chat_ui/chat_ui_generator.rb | # frozen_string_literal: true
require 'rails/generators'
require_relative '../generator_helpers'
module RubyLLM
module Generators
# Generates a simple chat UI scaffold for RubyLLM
class ChatUIGenerator < Rails::Generators::Base
include RubyLLM::Generators::GeneratorHelpers
source_root File.expa... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/generators/ruby_llm/upgrade_to_v1_9/upgrade_to_v1_9_generator.rb | lib/generators/ruby_llm/upgrade_to_v1_9/upgrade_to_v1_9_generator.rb | # frozen_string_literal: true
require 'rails/generators'
require 'rails/generators/active_record'
require_relative '../generator_helpers'
module RubyLLM
module Generators
# Generator to add v1.9 columns (cached tokens + raw content support) to existing apps.
class UpgradeToV19Generator < Rails::Generators::... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/generators/ruby_llm/install/install_generator.rb | lib/generators/ruby_llm/install/install_generator.rb | # frozen_string_literal: true
require 'rails/generators'
require 'rails/generators/active_record'
require_relative '../generator_helpers'
module RubyLLM
module Generators
# Generator for RubyLLM Rails models and migrations
class InstallGenerator < Rails::Generators::Base
include Rails::Generators::Mig... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/provider.rb | lib/ruby_llm/provider.rb | # frozen_string_literal: true
module RubyLLM
# Base class for LLM providers.
class Provider
include Streaming
attr_reader :config, :connection
def initialize(config)
@config = config
ensure_configured!
@connection = Connection.new(self, @config)
end
def api_base
raise... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/chunk.rb | lib/ruby_llm/chunk.rb | # frozen_string_literal: true
module RubyLLM
class Chunk < Message
end
end
| ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/content.rb | lib/ruby_llm/content.rb | # frozen_string_literal: true
module RubyLLM
# Represents the content sent to or received from an LLM.
class Content
attr_reader :text, :attachments
def initialize(text = nil, attachments = nil)
@text = text
@attachments = []
process_attachments(attachments)
raise ArgumentError, '... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/version.rb | lib/ruby_llm/version.rb | # frozen_string_literal: true
module RubyLLM
VERSION = '1.9.1'
end
| ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/utils.rb | lib/ruby_llm/utils.rb | # frozen_string_literal: true
module RubyLLM
# Provides utility functions for data manipulation within the RubyLLM library
module Utils
module_function
def hash_get(hash, key)
hash[key.to_sym] || hash[key.to_s]
end
def to_safe_array(item)
case item
when Array
item
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/chat.rb | lib/ruby_llm/chat.rb | # frozen_string_literal: true
module RubyLLM
# Represents a conversation with an AI model
class Chat
include Enumerable
attr_reader :model, :messages, :tools, :params, :headers, :schema
def initialize(model: nil, provider: nil, assume_model_exists: false, context: nil)
if assume_model_exists &&... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/transcription.rb | lib/ruby_llm/transcription.rb | # frozen_string_literal: true
module RubyLLM
# Represents a transcription of audio content.
class Transcription
attr_reader :text, :model, :language, :duration, :segments, :input_tokens, :output_tokens
def initialize(text:, model:, **attributes)
@text = text
@model = model
@language = at... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.