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 |
|---|---|---|---|---|---|---|---|---|
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/stream_accumulator.rb | lib/ruby_llm/stream_accumulator.rb | # frozen_string_literal: true
module RubyLLM
# Assembles streaming responses from LLMs into complete messages.
class StreamAccumulator
attr_reader :content, :model_id, :tool_calls
def initialize
@content = +''
@tool_calls = {}
@input_tokens = nil
@output_tokens = nil
@cached_... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/models.rb | lib/ruby_llm/models.rb | # frozen_string_literal: true
module RubyLLM
# Registry of available AI models and their capabilities.
class Models
include Enumerable
class << self
def instance
@instance ||= new
end
def schema_file
File.expand_path('models_schema.json', __dir__)
end
def lo... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/railtie.rb | lib/ruby_llm/railtie.rb | # frozen_string_literal: true
if defined?(Rails::Railtie)
module RubyLLM
# Rails integration for RubyLLM
class Railtie < Rails::Railtie
initializer 'ruby_llm.inflections' do
ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.acronym 'RubyLLM'
end
end
i... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/attachment.rb | lib/ruby_llm/attachment.rb | # frozen_string_literal: true
module RubyLLM
# A class representing a file attachment.
class Attachment
attr_reader :source, :filename, :mime_type
def initialize(source, filename: nil)
@source = source
@source = source_type_cast
@filename = filename || source_filename
determine_mi... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/message.rb | lib/ruby_llm/message.rb | # frozen_string_literal: true
module RubyLLM
# A single message in a chat conversation.
class Message
ROLES = %i[system user assistant tool].freeze
attr_reader :role, :model_id, :tool_calls, :tool_call_id, :input_tokens, :output_tokens,
:cached_tokens, :cache_creation_tokens, :raw
attr... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/configuration.rb | lib/ruby_llm/configuration.rb | # frozen_string_literal: true
module RubyLLM
# Global configuration for RubyLLM
class Configuration
attr_accessor :openai_api_key,
:openai_api_base,
:openai_organization_id,
:openai_project_id,
:openai_use_system_role,
:a... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/connection.rb | lib/ruby_llm/connection.rb | # frozen_string_literal: true
module RubyLLM
# Connection class for managing API connections to various providers.
class Connection
attr_reader :provider, :connection, :config
def self.basic(&)
Faraday.new do |f|
f.response :logger,
RubyLLM.logger,
bodie... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/aliases.rb | lib/ruby_llm/aliases.rb | # frozen_string_literal: true
module RubyLLM
# Manages model aliases for provider-specific versions
class Aliases
class << self
def resolve(model_id, provider = nil)
return model_id unless aliases[model_id]
if provider
aliases[model_id][provider.to_s] || model_id
else
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/tool_call.rb | lib/ruby_llm/tool_call.rb | # frozen_string_literal: true
module RubyLLM
# Represents a function call from an AI model to a Tool.
class ToolCall
attr_reader :id, :name, :arguments
def initialize(id:, name:, arguments: {})
@id = id
@name = name
@arguments = arguments
end
def to_h
{
id: @id,
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/streaming.rb | lib/ruby_llm/streaming.rb | # frozen_string_literal: true
module RubyLLM
# Handles streaming responses from AI providers.
module Streaming
module_function
def stream_response(connection, payload, additional_headers = {}, &block)
accumulator = StreamAccumulator.new
response = connection.post stream_url, payload do |req|
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/context.rb | lib/ruby_llm/context.rb | # frozen_string_literal: true
module RubyLLM
# Holds per-call configs
class Context
attr_reader :config
def initialize(config)
@config = config
@connections = {}
end
def chat(*args, **kwargs, &)
Chat.new(*args, **kwargs, context: self, &)
end
def embed(*args, **kwargs, ... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/tool.rb | lib/ruby_llm/tool.rb | # frozen_string_literal: true
require 'ruby_llm/schema'
module RubyLLM
# Parameter definition for Tool methods.
class Parameter
attr_reader :name, :type, :description, :required
def initialize(name, type: 'string', desc: nil, required: true)
@name = name
@type = type
@description = desc... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/model.rb | lib/ruby_llm/model.rb | # frozen_string_literal: true
module RubyLLM
# Model-related classes for working with LLM models
module Model
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/image.rb | lib/ruby_llm/image.rb | # frozen_string_literal: true
module RubyLLM
# Represents a generated image from an AI model.
class Image
attr_reader :url, :data, :mime_type, :revised_prompt, :model_id
def initialize(url: nil, data: nil, mime_type: nil, revised_prompt: nil, model_id: nil)
@url = url
@data = data
@mime_... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/error.rb | lib/ruby_llm/error.rb | # frozen_string_literal: true
module RubyLLM
# Custom error class that wraps API errors from different providers
# into a consistent format with helpful error messages.
class Error < StandardError
attr_reader :response
def initialize(response = nil, message = nil)
@response = response
super(... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/moderation.rb | lib/ruby_llm/moderation.rb | # frozen_string_literal: true
module RubyLLM
# Identify potentially harmful content in text.
# https://platform.openai.com/docs/guides/moderation
class Moderation
attr_reader :id, :model, :results
def initialize(id:, model:, results:)
@id = id
@model = model
@results = results
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/mime_type.rb | lib/ruby_llm/mime_type.rb | # frozen_string_literal: true
require 'marcel'
module RubyLLM
# MimeTypes module provides methods to handle MIME types using Marcel gem
module MimeType
module_function
def for(...)
Marcel::MimeType.for(...)
end
def image?(type)
type.start_with?('image/')
end
def video?(type)... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/embedding.rb | lib/ruby_llm/embedding.rb | # frozen_string_literal: true
module RubyLLM
# Core embedding interface.
class Embedding
attr_reader :vectors, :model, :input_tokens
def initialize(vectors:, model:, input_tokens: 0)
@vectors = vectors
@model = model
@input_tokens = input_tokens
end
def self.embed(text, # ruboco... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/model/pricing_category.rb | lib/ruby_llm/model/pricing_category.rb | # frozen_string_literal: true
module RubyLLM
module Model
# Represents pricing tiers for different usage categories (standard and batch)
class PricingCategory
attr_reader :standard, :batch
def initialize(data = {})
@standard = PricingTier.new(data[:standard] || {}) unless empty_tier?(dat... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/model/info.rb | lib/ruby_llm/model/info.rb | # frozen_string_literal: true
module RubyLLM
module Model
# Information about an AI model's capabilities, pricing, and metadata.
class Info
attr_reader :id, :name, :provider, :family, :created_at, :context_window, :max_output_tokens, :knowledge_cutoff,
:modalities, :capabilities, :pri... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/model/pricing.rb | lib/ruby_llm/model/pricing.rb | # frozen_string_literal: true
module RubyLLM
module Model
# A collection that manages and provides access to different categories of pricing information
class Pricing
def initialize(data)
@data = {}
%i[text_tokens images audio_tokens embeddings].each do |category|
@data[categ... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/model/pricing_tier.rb | lib/ruby_llm/model/pricing_tier.rb | # frozen_string_literal: true
module RubyLLM
module Model
# A dynamic class for storing non-zero pricing values with flexible attribute access
class PricingTier
def initialize(data = {})
@values = {}
data.each do |key, value|
@values[key.to_sym] = value if value && value != 0... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/model/modalities.rb | lib/ruby_llm/model/modalities.rb | # frozen_string_literal: true
module RubyLLM
module Model
# Holds and manages input and output modalities for a language model
class Modalities
attr_reader :input, :output
def initialize(data)
@input = Array(data[:input]).map(&:to_s)
@output = Array(data[:output]).map(&:to_s)
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/bedrock.rb | lib/ruby_llm/providers/bedrock.rb | # frozen_string_literal: true
require 'openssl'
require 'time'
module RubyLLM
module Providers
# AWS Bedrock API integration.
class Bedrock < Provider
include Bedrock::Chat
include Bedrock::Streaming
include Bedrock::Models
include Bedrock::Signing
include Bedrock::Media
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/deepseek.rb | lib/ruby_llm/providers/deepseek.rb | # frozen_string_literal: true
module RubyLLM
module Providers
# DeepSeek API integration.
class DeepSeek < OpenAI
include DeepSeek::Chat
def api_base
'https://api.deepseek.com'
end
def headers
{
'Authorization' => "Bearer #{@config.deepseek_api_key}"
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/gpustack.rb | lib/ruby_llm/providers/gpustack.rb | # frozen_string_literal: true
module RubyLLM
module Providers
# GPUStack API integration based on Ollama.
class GPUStack < OpenAI
include GPUStack::Chat
include GPUStack::Models
include GPUStack::Media
def api_base
@config.gpustack_api_base
end
def headers
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/ollama.rb | lib/ruby_llm/providers/ollama.rb | # frozen_string_literal: true
module RubyLLM
module Providers
# Ollama API integration.
class Ollama < OpenAI
include Ollama::Chat
include Ollama::Media
include Ollama::Models
def api_base
@config.ollama_api_base
end
def headers
{}
end
class ... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/mistral.rb | lib/ruby_llm/providers/mistral.rb | # frozen_string_literal: true
module RubyLLM
module Providers
# Mistral API integration.
class Mistral < OpenAI
include Mistral::Chat
include Mistral::Models
include Mistral::Embeddings
def api_base
'https://api.mistral.ai/v1'
end
def headers
{
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/vertexai.rb | lib/ruby_llm/providers/vertexai.rb | # frozen_string_literal: true
module RubyLLM
module Providers
# Google Vertex AI implementation
class VertexAI < Gemini
include VertexAI::Chat
include VertexAI::Streaming
include VertexAI::Embeddings
include VertexAI::Models
include VertexAI::Transcription
def initialize(... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/openai.rb | lib/ruby_llm/providers/openai.rb | # frozen_string_literal: true
module RubyLLM
module Providers
# OpenAI API integration.
class OpenAI < Provider
include OpenAI::Chat
include OpenAI::Embeddings
include OpenAI::Models
include OpenAI::Moderation
include OpenAI::Streaming
include OpenAI::Tools
include O... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/anthropic.rb | lib/ruby_llm/providers/anthropic.rb | # frozen_string_literal: true
module RubyLLM
module Providers
# Anthropic Claude API integration.
class Anthropic < Provider
include Anthropic::Chat
include Anthropic::Embeddings
include Anthropic::Media
include Anthropic::Models
include Anthropic::Streaming
include Anthro... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/gemini.rb | lib/ruby_llm/providers/gemini.rb | # frozen_string_literal: true
module RubyLLM
module Providers
# Native Gemini API implementation
class Gemini < Provider
include Gemini::Chat
include Gemini::Embeddings
include Gemini::Images
include Gemini::Models
include Gemini::Transcription
include Gemini::Streaming
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/perplexity.rb | lib/ruby_llm/providers/perplexity.rb | # frozen_string_literal: true
module RubyLLM
module Providers
# Perplexity API integration.
class Perplexity < OpenAI
include Perplexity::Chat
include Perplexity::Models
def api_base
'https://api.perplexity.ai'
end
def headers
{
'Authorization' => "Be... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/openrouter.rb | lib/ruby_llm/providers/openrouter.rb | # frozen_string_literal: true
module RubyLLM
module Providers
# OpenRouter API integration.
class OpenRouter < OpenAI
include OpenRouter::Models
def api_base
'https://openrouter.ai/api/v1'
end
def headers
{
'Authorization' => "Bearer #{@config.openrouter_ap... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/gpustack/media.rb | lib/ruby_llm/providers/gpustack/media.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class GPUStack
# Handles formatting of media content (images, audio) for GPUStack APIs
module Media
extend OpenAI::Media
module_function
def format_content(content)
return content.value if content.is_a?(... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/gpustack/chat.rb | lib/ruby_llm/providers/gpustack/chat.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class GPUStack
# Chat methods of the GPUStack API integration
module Chat
module_function
def format_messages(messages)
messages.map do |msg|
{
role: format_role(msg.role),
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/gpustack/models.rb | lib/ruby_llm/providers/gpustack/models.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class GPUStack
# Models methods of the GPUStack API integration
module Models
module_function
def models_url
'models'
end
def parse_list_models_response(response, slug, _capabilities)
i... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/openai/capabilities.rb | lib/ruby_llm/providers/openai/capabilities.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class OpenAI
# Determines capabilities and pricing for OpenAI models
module Capabilities
module_function
MODEL_PATTERNS = {
dall_e: /^dall-e/,
chatgpt4o: /^chatgpt-4o/,
gpt41: /^gpt-4\.1(?!-(?... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/openai/tools.rb | lib/ruby_llm/providers/openai/tools.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class OpenAI
# Tools methods of the OpenAI API integration
module Tools
module_function
EMPTY_PARAMETERS_SCHEMA = {
'type' => 'object',
'properties' => {},
'required' => [],
'additio... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/openai/media.rb | lib/ruby_llm/providers/openai/media.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class OpenAI
# Handles formatting of media content (images, audio) for OpenAI APIs
module Media
module_function
def format_content(content) # rubocop:disable Metrics/PerceivedComplexity
return content.value if co... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/openai/chat.rb | lib/ruby_llm/providers/openai/chat.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class OpenAI
# Chat methods of the OpenAI API integration
module Chat
def completion_url
'chat/completions'
end
module_function
def render_payload(messages, tools:, temperature:, model:, stream: ... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/openai/transcription.rb | lib/ruby_llm/providers/openai/transcription.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class OpenAI
# Audio transcription methods for the OpenAI API integration
module Transcription
module_function
def transcription_url
'audio/transcriptions'
end
def render_transcription_payload(fi... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/openai/models.rb | lib/ruby_llm/providers/openai/models.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class OpenAI
# Models methods of the OpenAI API integration
module Models
module_function
def models_url
'models'
end
def parse_list_models_response(response, slug, capabilities)
Array(... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/openai/embeddings.rb | lib/ruby_llm/providers/openai/embeddings.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class OpenAI
# Embeddings methods of the OpenAI API integration
module Embeddings
module_function
def embedding_url(...)
'embeddings'
end
def render_embedding_payload(text, model:, dimensions:)
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/openai/streaming.rb | lib/ruby_llm/providers/openai/streaming.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class OpenAI
# Streaming methods of the OpenAI API integration
module Streaming
module_function
def stream_url
completion_url
end
def build_chunk(data)
usage = data['usage'] || {}
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/openai/images.rb | lib/ruby_llm/providers/openai/images.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class OpenAI
# Image generation methods for the OpenAI API integration
module Images
module_function
def images_url
'images/generations'
end
def render_image_payload(prompt, model:, size:)
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/openai/moderation.rb | lib/ruby_llm/providers/openai/moderation.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class OpenAI
# Moderation methods of the OpenAI API integration
module Moderation
module_function
def moderation_url
'moderations'
end
def render_moderation_payload(input, model:)
{
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/openrouter/models.rb | lib/ruby_llm/providers/openrouter/models.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class OpenRouter
# Models methods of the OpenRouter API integration
module Models
module_function
def models_url
'models'
end
def parse_list_models_response(response, slug, _capabilities)
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/ollama/media.rb | lib/ruby_llm/providers/ollama/media.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Ollama
# Handles formatting of media content (images, audio) for Ollama APIs
module Media
extend OpenAI::Media
module_function
def format_content(content)
return content.value if content.is_a?(Ruby... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/ollama/chat.rb | lib/ruby_llm/providers/ollama/chat.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Ollama
# Chat methods of the Ollama API integration
module Chat
module_function
def format_messages(messages)
messages.map do |msg|
{
role: format_role(msg.role),
con... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/ollama/models.rb | lib/ruby_llm/providers/ollama/models.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Ollama
# Models methods for the Ollama API integration
module Models
def models_url
'models'
end
def parse_list_models_response(response, slug, _capabilities)
data = response.body['data'] ... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/bedrock/capabilities.rb | lib/ruby_llm/providers/bedrock/capabilities.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Bedrock
# Determines capabilities and pricing for AWS Bedrock models
module Capabilities
module_function
def context_window_for(model_id)
case model_id
when /anthropic\.claude-2/ then 100_000
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/bedrock/media.rb | lib/ruby_llm/providers/bedrock/media.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Bedrock
# Media handling methods for the Bedrock API integration
# NOTE: Bedrock does not support url attachments
module Media
extend Anthropic::Media
module_function
def format_content(content) # rubo... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/bedrock/signing.rb | lib/ruby_llm/providers/bedrock/signing.rb | # Portions of this file are derived from AWS SDK for Ruby (Apache License 2.0)
# Modifications made by RubyLLM in 2025
# See THIRD_PARTY_LICENSES/AWS-SDK-NOTICE.txt for details
# frozen_string_literal: true
require 'openssl'
require 'tempfile'
require 'time'
require 'uri'
require 'set'
require 'cgi'
require 'pathname... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/bedrock/chat.rb | lib/ruby_llm/providers/bedrock/chat.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Bedrock
# Chat methods for the AWS Bedrock API implementation
module Chat
module_function
def sync_response(connection, payload, additional_headers = {})
signature = sign_request("#{connection.connection.ur... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/bedrock/models.rb | lib/ruby_llm/providers/bedrock/models.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Bedrock
# Models methods for the AWS Bedrock API implementation
module Models
def list_models
mgmt_api_base = "https://bedrock.#{@config.bedrock_region}.amazonaws.com"
full_models_url = "#{mgmt_api_base}/#... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/bedrock/streaming.rb | lib/ruby_llm/providers/bedrock/streaming.rb | # frozen_string_literal: true
require_relative 'streaming/base'
require_relative 'streaming/content_extraction'
require_relative 'streaming/message_processing'
require_relative 'streaming/payload_processing'
require_relative 'streaming/prelude_handling'
module RubyLLM
module Providers
class Bedrock
# Stre... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/bedrock/streaming/content_extraction.rb | lib/ruby_llm/providers/bedrock/streaming/content_extraction.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Bedrock
module Streaming
# Module for handling content extraction from AWS Bedrock streaming responses.
module ContentExtraction
def json_delta?(data)
data['type'] == 'content_block_delta' && data.dig(... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/bedrock/streaming/prelude_handling.rb | lib/ruby_llm/providers/bedrock/streaming/prelude_handling.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Bedrock
module Streaming
# Module for handling message preludes in AWS Bedrock streaming responses.
module PreludeHandling
def can_read_prelude?(chunk, offset)
chunk.bytesize - offset >= 12
e... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/bedrock/streaming/message_processing.rb | lib/ruby_llm/providers/bedrock/streaming/message_processing.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Bedrock
module Streaming
# Module for processing streaming messages from AWS Bedrock.
module MessageProcessing
def process_chunk(chunk, &)
offset = 0
offset = process_message(chunk, offset,... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/bedrock/streaming/payload_processing.rb | lib/ruby_llm/providers/bedrock/streaming/payload_processing.rb | # frozen_string_literal: true
require 'base64'
module RubyLLM
module Providers
class Bedrock
module Streaming
# Module for processing payloads from AWS Bedrock streaming responses.
module PayloadProcessing
def process_payload(payload, &)
json_payload = extract_json_pa... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/bedrock/streaming/base.rb | lib/ruby_llm/providers/bedrock/streaming/base.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Bedrock
module Streaming
# Base module for AWS Bedrock streaming functionality.
module Base
def self.included(base)
base.include ContentExtraction
base.include MessageProcessing
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/mistral/capabilities.rb | lib/ruby_llm/providers/mistral/capabilities.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Mistral
# Determines capabilities for Mistral models
module Capabilities
module_function
def supports_streaming?(model_id)
!model_id.match?(/embed|moderation|ocr|transcriptions/)
end
def su... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/mistral/chat.rb | lib/ruby_llm/providers/mistral/chat.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Mistral
# Chat methods for Mistral API
module Chat
module_function
def format_role(role)
role.to_s
end
# rubocop:disable Metrics/ParameterLists
def render_payload(messages, tools:, ... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/mistral/models.rb | lib/ruby_llm/providers/mistral/models.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Mistral
# Model information for Mistral
module Models
module_function
def models_url
'models'
end
def headers(config)
{
'Authorization' => "Bearer #{config.mistral_api... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/mistral/embeddings.rb | lib/ruby_llm/providers/mistral/embeddings.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Mistral
# Embeddings methods for Mistral API
module Embeddings
module_function
def embedding_url(...)
'embeddings'
end
def render_embedding_payload(text, model:, dimensions:) # rubocop:disa... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/anthropic/capabilities.rb | lib/ruby_llm/providers/anthropic/capabilities.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Anthropic
# Determines capabilities and pricing for Anthropic models
module Capabilities
module_function
def determine_context_window(_model_id)
200_000
end
def determine_max_tokens(model_i... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/anthropic/content.rb | lib/ruby_llm/providers/anthropic/content.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Anthropic
# Helper for constructing Anthropic native content blocks.
class Content
class << self
def new(text = nil, cache: false, cache_control: nil, parts: nil, **extras)
payload = resolve_payload(
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/anthropic/tools.rb | lib/ruby_llm/providers/anthropic/tools.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Anthropic
# Tools methods of the Anthropic API integration
module Tools
module_function
def find_tool_uses(blocks)
blocks.select { |c| c['type'] == 'tool_use' }
end
def format_tool_call(msg... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/anthropic/media.rb | lib/ruby_llm/providers/anthropic/media.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Anthropic
# Handles formatting of media content (images, PDFs, audio) for Anthropic
module Media
module_function
def format_content(content) # rubocop:disable Metrics/PerceivedComplexity
return content.valu... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/anthropic/chat.rb | lib/ruby_llm/providers/anthropic/chat.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Anthropic
# Chat methods of the OpenAI API integration
module Chat
module_function
def completion_url
'/v1/messages'
end
def render_payload(messages, tools:, temperature:, model:, stream: f... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/anthropic/models.rb | lib/ruby_llm/providers/anthropic/models.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Anthropic
# Models methods of the Anthropic API integration
module Models
module_function
def models_url
'/v1/models'
end
def parse_list_models_response(response, slug, capabilities)
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/anthropic/embeddings.rb | lib/ruby_llm/providers/anthropic/embeddings.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Anthropic
# Embeddings methods of the Anthropic API integration
module Embeddings
private
def embed
raise Error "Anthropic doesn't support embeddings"
end
alias render_embedding_payload emb... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/anthropic/streaming.rb | lib/ruby_llm/providers/anthropic/streaming.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Anthropic
# Streaming methods of the Anthropic API integration
module Streaming
private
def stream_url
completion_url
end
def build_chunk(data)
Chunk.new(
role: :assis... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/vertexai/chat.rb | lib/ruby_llm/providers/vertexai/chat.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class VertexAI
# Chat methods for the Vertex AI implementation
module Chat
def completion_url
"projects/#{@config.vertexai_project_id}/locations/#{@config.vertexai_location}/publishers/google/models/#{@model}:generateCont... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/vertexai/transcription.rb | lib/ruby_llm/providers/vertexai/transcription.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class VertexAI
# Vertex AI specific helpers for audio transcription
module Transcription
private
def transcription_url(model)
"projects/#{@config.vertexai_project_id}/locations/#{@config.vertexai_location}/publis... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/vertexai/models.rb | lib/ruby_llm/providers/vertexai/models.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class VertexAI
# Models methods for the Vertex AI integration
module Models
# Gemini and other Google models that aren't returned by the API
KNOWN_GOOGLE_MODELS = %w[
gemini-2.5-flash-lite
gemini-2.5-pro... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/vertexai/embeddings.rb | lib/ruby_llm/providers/vertexai/embeddings.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class VertexAI
# Embeddings methods for the Vertex AI implementation
module Embeddings
module_function
def embedding_url(model:)
"projects/#{@config.vertexai_project_id}/locations/#{@config.vertexai_location}/pub... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/vertexai/streaming.rb | lib/ruby_llm/providers/vertexai/streaming.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class VertexAI
# Streaming methods for the Vertex AI implementation
module Streaming
def stream_url
"projects/#{@config.vertexai_project_id}/locations/#{@config.vertexai_location}/publishers/google/models/#{@model}:stream... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/perplexity/capabilities.rb | lib/ruby_llm/providers/perplexity/capabilities.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Perplexity
# Determines capabilities and pricing for Perplexity models
module Capabilities
module_function
def context_window_for(model_id)
case model_id
when /sonar-pro/ then 200_000
el... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/perplexity/chat.rb | lib/ruby_llm/providers/perplexity/chat.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Perplexity
# Chat formatting for Perplexity provider
module Chat
module_function
def format_role(role)
role.to_s
end
end
end
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/providers/perplexity/models.rb | lib/ruby_llm/providers/perplexity/models.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Perplexity
# Models methods of the Perplexity API integration
module Models
def list_models(**)
slug = 'perplexity'
capabilities = Perplexity::Capabilities
parse_list_models_response(nil, slug, c... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/deepseek/capabilities.rb | lib/ruby_llm/providers/deepseek/capabilities.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class DeepSeek
# Determines capabilities and pricing for DeepSeek models
module Capabilities
module_function
def context_window_for(model_id)
case model_id
when /deepseek-(?:chat|reasoner)/ then 64_000
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/deepseek/chat.rb | lib/ruby_llm/providers/deepseek/chat.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class DeepSeek
# Chat methods of the DeepSeek API integration
module Chat
module_function
def format_role(role)
role.to_s
end
end
end
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/providers/gemini/capabilities.rb | lib/ruby_llm/providers/gemini/capabilities.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Gemini
# Determines capabilities and pricing for Google Gemini models
module Capabilities
module_function
def context_window_for(model_id)
case model_id
when /gemini-2\.5-pro-exp-03-25/, /gemini-2... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/gemini/tools.rb | lib/ruby_llm/providers/gemini/tools.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Gemini
# Tools methods for the Gemini API implementation
module Tools
def format_tools(tools)
return [] if tools.empty?
[{
functionDeclarations: tools.values.map { |tool| function_declaration_... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/gemini/media.rb | lib/ruby_llm/providers/gemini/media.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Gemini # rubocop:disable Style/Documentation
# Media handling methods for the Gemini API integration
module Media
module_function
def format_content(content)
return content.value if content.is_a?(RubyLLM::C... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/gemini/chat.rb | lib/ruby_llm/providers/gemini/chat.rb | # frozen_string_literal: true
require 'set'
require 'rubygems/version'
module RubyLLM
module Providers
class Gemini
# Chat methods for the Gemini API implementation
module Chat
module_function
def completion_url
"models/#{@model}:generateContent"
end
def r... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/gemini/transcription.rb | lib/ruby_llm/providers/gemini/transcription.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Gemini
# Audio transcription helpers for the Gemini API implementation
module Transcription
DEFAULT_PROMPT = 'Transcribe the provided audio and respond with only the transcript text.'
def transcribe(audio_file, model... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/gemini/models.rb | lib/ruby_llm/providers/gemini/models.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Gemini
# Models methods for the Gemini API integration
module Models
module_function
def models_url
'models'
end
def parse_list_models_response(response, slug, capabilities)
Array... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/gemini/embeddings.rb | lib/ruby_llm/providers/gemini/embeddings.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Gemini
# Embeddings methods for the Gemini API integration
module Embeddings
module_function
def embedding_url(model:)
"models/#{model}:batchEmbedContents"
end
def render_embedding_payload(... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/gemini/streaming.rb | lib/ruby_llm/providers/gemini/streaming.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Gemini
# Streaming methods for the Gemini API implementation
module Streaming
def stream_url
"models/#{@model}:streamGenerateContent?alt=sse"
end
def build_chunk(data)
Chunk.new(
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/providers/gemini/images.rb | lib/ruby_llm/providers/gemini/images.rb | # frozen_string_literal: true
module RubyLLM
module Providers
class Gemini
# Image generation methods for the Gemini API implementation
module Images
def images_url
"models/#{@model}:predict"
end
def render_image_payload(prompt, model:, size:)
RubyLLM.logg... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/active_record/chat_methods.rb | lib/ruby_llm/active_record/chat_methods.rb | # frozen_string_literal: true
module RubyLLM
module ActiveRecord
# Methods mixed into chat models.
module ChatMethods
extend ActiveSupport::Concern
included do
before_save :resolve_model_from_strings
end
attr_accessor :assume_model_exists, :context
def model=(value)
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/active_record/model_methods.rb | lib/ruby_llm/active_record/model_methods.rb | # frozen_string_literal: true
module RubyLLM
module ActiveRecord
# Methods mixed into model registry models.
module ModelMethods
extend ActiveSupport::Concern
class_methods do # rubocop:disable Metrics/BlockLength
def refresh!
RubyLLM.models.refresh!
transaction do
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/active_record/message_methods.rb | lib/ruby_llm/active_record/message_methods.rb | # frozen_string_literal: true
module RubyLLM
module ActiveRecord
# Methods mixed into message models.
module MessageMethods
extend ActiveSupport::Concern
class_methods do
attr_reader :chat_class, :tool_call_class, :chat_foreign_key, :tool_call_foreign_key
end
def to_llm
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/active_record/acts_as.rb | lib/ruby_llm/active_record/acts_as.rb | # frozen_string_literal: true
module RubyLLM
module ActiveRecord
# Adds chat and message persistence capabilities to ActiveRecord models.
module ActsAs
extend ActiveSupport::Concern
# When ActsAs is included, ensure models are loaded from database
def self.included(base)
super
... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
crmne/ruby_llm | https://github.com/crmne/ruby_llm/blob/1e315ab4b3f3a150c443dc9a17f504756c2aad6f/lib/ruby_llm/active_record/acts_as_legacy.rb | lib/ruby_llm/active_record/acts_as_legacy.rb | # frozen_string_literal: true
module RubyLLM
module ActiveRecord
# Adds chat and message persistence capabilities to ActiveRecord models.
module ActsAsLegacy
extend ActiveSupport::Concern
class_methods do # rubocop:disable Metrics/BlockLength
def acts_as_chat(message_class: 'Message', to... | ruby | MIT | 1e315ab4b3f3a150c443dc9a17f504756c2aad6f | 2026-01-04T15:50:46.100670Z | false |
rails/solid_queue | https://github.com/rails/solid_queue/blob/a0b35ead31216c198af4cff01cd289cd5b200208/app/jobs/solid_queue/recurring_job.rb | app/jobs/solid_queue/recurring_job.rb | # frozen_string_literal: true
class SolidQueue::RecurringJob < ActiveJob::Base
queue_as :solid_queue_recurring
def perform(command)
eval(command)
end
end
| ruby | MIT | a0b35ead31216c198af4cff01cd289cd5b200208 | 2026-01-04T15:56:23.248573Z | false |
rails/solid_queue | https://github.com/rails/solid_queue/blob/a0b35ead31216c198af4cff01cd289cd5b200208/app/models/solid_queue/semaphore.rb | app/models/solid_queue/semaphore.rb | # frozen_string_literal: true
module SolidQueue
class Semaphore < Record
scope :available, -> { where("value > 0") }
scope :expired, -> { where(expires_at: ...Time.current) }
class << self
def wait(job)
Proxy.new(job).wait
end
def signal(job)
Proxy.new(job).signal
... | ruby | MIT | a0b35ead31216c198af4cff01cd289cd5b200208 | 2026-01-04T15:56:23.248573Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.