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 |
|---|---|---|---|---|---|---|---|---|
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/evals/ragas/main_spec.rb | spec/lib/langchain/evals/ragas/main_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Evals::Ragas::Main do
let(:llm) { Langchain::LLM::OpenAI.new(api_key: "123") }
subject { described_class.new(llm: llm) }
let(:question) { "Who directed the film Oppenheimer and who stars as J. Robert Oppenheimer in the film?" }
let(:answer) { "Christophe... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/utils/to_boolean_spec.rb | spec/lib/langchain/utils/to_boolean_spec.rb | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Langchain::Utils::ToBoolean do
describe "#to_bool" do
subject(:to_bool) { described_class.new.to_bool(value) }
context "when Integer" do
context "when 1" do
let(:value) { 1 }
it { is_expected.to eq true }
end
... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/utils/hash_transformer_spec.rb | spec/lib/langchain/utils/hash_transformer_spec.rb | RSpec.describe Langchain::Utils::HashTransformer do
describe ".symbolize_keys" do
it "symbolizes string keys at the top level of the hash" do
hash = {"name" => "Alice", "age" => 30}
expected_hash = {name: "Alice", age: 30}
expect(described_class.symbolize_keys(hash)).to eq(expected_hash)
end... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/utils/image_wrapper_spec.rb | spec/lib/langchain/utils/image_wrapper_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Utils::ImageWrapper do
let(:image_url) { "https://example.com/sf-cable-car.jpeg" }
let(:uri_https) { instance_double(URI::HTTPS) }
before do
allow(URI).to receive(:parse).with(image_url).and_return(uri_https)
allow(uri_https).to receive(:scheme).an... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/llm/google_gemini_spec.rb | spec/lib/langchain/llm/google_gemini_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::LLM::GoogleGemini do
subject { described_class.new(api_key: "123") }
describe "#initialize" do
it "initializes with default options" do
expect(subject.api_key).to eq("123")
expect(subject.defaults[:chat_model]).to eq("gemini-1.5-pro-latest")
... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/llm/replicate_spec.rb | spec/lib/langchain/llm/replicate_spec.rb | # frozen_string_literal: true
require "replicate"
RSpec.describe Langchain::LLM::Replicate do
let(:subject) { described_class.new(api_key: "123") }
describe "#completion_model" do
before do
allow(subject.client).to receive_message_chain(:retrieve_model, :latest_version).and_return(
Replicate::R... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/llm/unified_parameters_spec.rb | spec/lib/langchain/llm/unified_parameters_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::LLM::UnifiedParameters do
# For now, the unifier only maps keys, but in the future it may be beneficial
# to introduce an ActiveModel-style validator to restrict inputs to conform to
# types required of the LLMs APIs
let(:schema) do
{beep: {default: "... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/llm/ai21_spec.rb | spec/lib/langchain/llm/ai21_spec.rb | # frozen_string_literal: true
require "ai21"
RSpec.describe Langchain::LLM::AI21 do
let(:subject) { described_class.new(api_key: "123") }
describe "#complete" do
let(:response) do
{
id: "812c650e-a0d0-4502-a084-45b0d32fcb9c",
prompt: {
text: "What is the meaining of life?"
... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/llm/cohere_spec.rb | spec/lib/langchain/llm/cohere_spec.rb | # frozen_string_literal: true
require "cohere"
RSpec.describe Langchain::LLM::Cohere do
let(:subject) { described_class.new(api_key: "123") }
describe "#initialize" do
context "when default_options are passed" do
let(:default_options) { {response_format: {type: "json_object"}} }
subject { descri... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/llm/ollama_spec.rb | spec/lib/langchain/llm/ollama_spec.rb | # frozen_string_literal: true
require "faraday"
RSpec.describe Langchain::LLM::Ollama do
let(:default_url) { "http://localhost:11434" }
let(:subject) { described_class.new(url: default_url, default_options: {completion_model: "llama3.2", embedding_model: "llama3.2"}) }
let(:client) { subject.send(:client) }
... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/llm/hugging_face_spec.rb | spec/lib/langchain/llm/hugging_face_spec.rb | # frozen_string_literal: true
require "hugging_face"
RSpec.describe Langchain::LLM::HuggingFace do
let(:subject) { described_class.new(api_key: "123") }
describe "#embed" do
context "when the embedding_model is not passed as an argument" do
let(:embedding) {
[-0.03447720780968666, 0.03102318942... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/llm/aws_bedrock_spec.rb | spec/lib/langchain/llm/aws_bedrock_spec.rb | # frozen_string_literal: true
require "aws-sdk-bedrockruntime"
RSpec.describe Langchain::LLM::AwsBedrock do
let(:subject) { described_class.new }
before do
stub_const("ENV", ENV.to_hash.merge("AWS_REGION" => "us-east-1"))
end
describe "#chat" do
context "with anthropic provider" do
let(:respon... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/llm/base_spec.rb | spec/lib/langchain/llm/base_spec.rb | # frozen_string_literal: true
class TestLLM < Langchain::LLM::Base
end
class CustomTestLLM < Langchain::LLM::Base
def initialize
chat_parameters.update(version: {default: 1})
end
end
RSpec.describe Langchain::LLM::Base do
let(:subject) { described_class.new }
describe "#chat" do
it "raises an error"... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/llm/mistral_ai_spec.rb | spec/lib/langchain/llm/mistral_ai_spec.rb | # frozen_string_literal: true
require "mistral-ai"
RSpec.describe Langchain::LLM::MistralAI do
let(:subject) { described_class.new(api_key: "123") }
let(:mock_client) { instance_double(Mistral::Controllers::Client) }
before do
allow(Mistral).to receive(:new).and_return(mock_client)
end
describe "#ini... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/llm/openai_spec.rb | spec/lib/langchain/llm/openai_spec.rb | # frozen_string_literal: true
require "openai"
RSpec.describe Langchain::LLM::OpenAI do
let(:subject) { described_class.new(api_key: "123", **options) }
let(:options) { {} }
describe "#initialize" do
it "initializes the client without any errors" do
expect { subject }.not_to raise_error
end
... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/llm/google_vertex_ai_spec.rb | spec/lib/langchain/llm/google_vertex_ai_spec.rb | # frozen_string_literal: true
require "googleauth"
RSpec.describe Langchain::LLM::GoogleVertexAI do
subject { described_class.new(project_id: "123", region: "us-central1") }
before do
allow(Google::Auth).to receive(:get_application_default).and_return(
double("Google::Auth::UserRefreshCredentials", fet... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/llm/anthropic_spec.rb | spec/lib/langchain/llm/anthropic_spec.rb | # frozen_string_literal: true
require "anthropic"
RSpec.describe Langchain::LLM::Anthropic do
let(:subject) { described_class.new(api_key: "123") }
describe "#initialize" do
context "when default_options are passed" do
let(:default_options) { {max_tokens: 512} }
subject { described_class.new(api... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/llm/azure_spec.rb | spec/lib/langchain/llm/azure_spec.rb | # frozen_string_literal: true
require "openai"
RSpec.describe Langchain::LLM::Azure do
let(:subject) do
described_class.new(
api_key: "123",
embedding_deployment_url: "http://localhost:1234/deployments/embedding",
chat_deployment_url: "http://localhost:1234/deployments/chat"
)
end
des... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/llm/parameters/chat_spec.rb | spec/lib/langchain/llm/parameters/chat_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::LLM::Parameters::Chat do
let(:aliases) do
{max_tokens_supported: :max_tokens}
end
let(:valid_params) do
{
system: "You are a cheerful happy chatbot",
messages: [{role: "system", content: "You're too cool."}],
model: "gpt-4",
... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/llm/response/cohere_response_spec.rb | spec/lib/langchain/llm/response/cohere_response_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::LLM::Response::CohereResponse do
let(:raw_chat_completions_response) {
JSON.parse File.read("spec/fixtures/llm/cohere/chat.json")
}
subject { described_class.new(raw_chat_completions_response) }
describe "#chat_completion" do
it "returns chat_co... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/llm/response/ollama_response_spec.rb | spec/lib/langchain/llm/response/ollama_response_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::LLM::Response::OllamaResponse do
subject { described_class.new(raw_response) }
describe "chat completions" do
let(:raw_response) { JSON.parse File.read("spec/fixtures/llm/ollama/chat.json") }
it "created_at returns correct value" do
expect(sub... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/llm/response/aws_bedrock_meta_response_spec.rb | spec/lib/langchain/llm/response/aws_bedrock_meta_response_spec.rb | # frozen_string_literal: true
require_relative "#{Langchain.root}/langchain/llm/response/aws_bedrock_meta_response"
RSpec.describe Langchain::LLM::Response::AwsBedrockMetaResponse do
let(:raw_chat_completions_response) {
JSON.parse File.read("spec/fixtures/llm/aws_bedrock_meta/complete.json")
}
subject { d... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/llm/response/anthropic_response_spec.rb | spec/lib/langchain/llm/response/anthropic_response_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::LLM::Response::AnthropicResponse do
let(:raw_chat_completions_response) {
JSON.parse File.read("spec/fixtures/llm/anthropic/chat.json")
}
describe "#chat_completion" do
it "return chat_completion" do
subject = described_class.new(raw_chat_com... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/llm/response/mistral_ai_response_spec.rb | spec/lib/langchain/llm/response/mistral_ai_response_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::LLM::Response::MistralAIResponse do
let(:raw_chat_completions_response) {
JSON.parse File.read("spec/fixtures/llm/mistral_ai/chat.json")
}
describe "#chat_completion" do
it "return chat_completion" do
subject = described_class.new(raw_chat_co... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/llm/response/google_gemini_response_spec.rb | spec/lib/langchain/llm/response/google_gemini_response_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::LLM::Response::GoogleGeminiResponse do
describe "#chat_completion" do
let(:raw_response) {
JSON.parse File.read("spec/fixtures/llm/google_gemini/chat.json")
}
let(:response) { described_class.new(raw_response) }
it "returns text" do
... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/assistant/assistant_spec.rb | spec/lib/langchain/assistant/assistant_spec.rb | # frozen_string_literal: true
require "spec_helper"
require "googleauth"
RSpec.describe Langchain::Assistant do
context "initialization" do
let(:llm) { Langchain::LLM::OpenAI.new(api_key: "123") }
it "raises an error if tools array contains non-Langchain::Tool instance(s)" do
expect { described_class... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | true |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/assistant/messages/google_gemini_message_spec.rb | spec/lib/langchain/assistant/messages/google_gemini_message_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Assistant::Messages::GoogleGeminiMessage do
it "raises an error if role is not one of allowed" do
expect { described_class.new(role: "foo") }.to raise_error(ArgumentError)
end
describe "#to_hash" do
it "returns function" do
message = describe... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/assistant/messages/mistral_ai_message_spec.rb | spec/lib/langchain/assistant/messages/mistral_ai_message_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Assistant::Messages::MistralAIMessage do
it "raises an error if role is not one of allowed" do
expect { described_class.new(role: "foo") }.to raise_error(ArgumentError)
end
describe "#to_hash" do
context "when role and content are not nil" do
... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/assistant/messages/ollama_message_spec.rb | spec/lib/langchain/assistant/messages/ollama_message_spec.rb | # spec/langchain/messages/ollama_message_spec.rb
require "spec_helper"
RSpec.describe Langchain::Assistant::Messages::OllamaMessage do
let(:valid_roles) { ["system", "assistant", "user", "tool"] }
let(:role) { "assistant" }
let(:content) { "This is a message" }
let(:image_url) { "https://example.com/image.jpg... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/assistant/messages/openai_message_spec.rb | spec/lib/langchain/assistant/messages/openai_message_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Assistant::Messages::OpenAIMessage do
it "raises an error if role is not one of allowed" do
expect { described_class.new(role: "foo") }.to raise_error(ArgumentError)
end
describe "#to_hash" do
context "when role is user" do
let(:role) { "user... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/assistant/messages/base_spec.rb | spec/lib/langchain/assistant/messages/base_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Assistant::Messages::Base do
describe "tool?" do
it "raises an error" do
expect { described_class.new.tool? }.to raise_error(NotImplementedError)
end
end
describe "system?" do
it "raises an error" do
expect { described_class.new.sys... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/assistant/messages/anthropic_message_spec.rb | spec/lib/langchain/assistant/messages/anthropic_message_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Assistant::Messages::AnthropicMessage do
it "raises an error if role is not one of allowed" do
expect { described_class.new(role: "foo") }.to raise_error(ArgumentError)
end
describe "#to_hash" do
context "when role is assistant" do
let(:role)... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/assistant/llm/adapter_spec.rb | spec/lib/langchain/assistant/llm/adapter_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Assistant::LLM::Adapter do
let(:llm) { Langchain::LLM::OpenAI.new(api_key: "123") }
it "initialize a new OpenAI adapter" do
expect(described_class.build(llm)).to be_a(Langchain::Assistant::LLM::Adapters::OpenAI)
end
end
| ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/assistant/llm/adapters/google_gemini_spec.rb | spec/lib/langchain/assistant/llm/adapters/google_gemini_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Assistant::LLM::Adapters::GoogleGemini do
describe "#build_chat_params" do
it "returns the chat parameters" do
expect(
subject.build_chat_params(
messages: [{role: "user", content: "Hello"}],
instructions: "Instructions",
... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/assistant/llm/adapters/aws_bedrock_anthropic_spec.rb | spec/lib/langchain/assistant/llm/adapters/aws_bedrock_anthropic_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Assistant::LLM::Adapters::AwsBedrockAnthropic do
describe "#build_tool_choice" do
it "returns the tool choice object with 'auto'" do
expect(subject.send(:build_tool_choice, "auto", false)).to eq({type: "auto"})
end
it "returns the tool choice... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/assistant/llm/adapters/ollama_spec.rb | spec/lib/langchain/assistant/llm/adapters/ollama_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Assistant::LLM::Adapters::Ollama do
describe "#build_chat_params" do
it "returns the chat parameters" do
expect(
subject.build_chat_params(
messages: [{role: "user", content: "Hello"}],
instructions: "Instructions",
... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/assistant/llm/adapters/base_spec.rb | spec/lib/langchain/assistant/llm/adapters/base_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Assistant::LLM::Adapters::Base do
describe "#build_chat_params" do
it "raises NotImplementedError" do
expect { subject.build_chat_params(tools: [], instructions: "", messages: [], tool_choice: "", parallel_tool_calls: false) }.to raise_error(NotImplem... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/assistant/llm/adapters/mistral_ai_spec.rb | spec/lib/langchain/assistant/llm/adapters/mistral_ai_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Assistant::LLM::Adapters::MistralAI do
describe "#build_chat_params" do
it "returns the chat parameters" do
expect(
subject.build_chat_params(
messages: [{role: "user", content: "Hello"}],
instructions: "Instructions",
... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/assistant/llm/adapters/openai_spec.rb | spec/lib/langchain/assistant/llm/adapters/openai_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Assistant::LLM::Adapters::OpenAI do
describe "#build_chat_params" do
it "returns the chat parameters" do
expect(
subject.build_chat_params(
messages: [{role: "user", content: "Hello"}],
instructions: "Instructions",
... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/assistant/llm/adapters/anthropic_spec.rb | spec/lib/langchain/assistant/llm/adapters/anthropic_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Assistant::LLM::Adapters::Anthropic do
describe "#build_chat_params" do
it "returns the chat parameters" do
expect(
subject.build_chat_params(
messages: [{role: "user", content: "Hello"}],
instructions: "Instructions",
... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/prompts/few_shot_prompt_template_spec.rb | spec/lib/langchain/prompts/few_shot_prompt_template_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Prompt::FewShotPromptTemplate do
let(:input_variables) { ["adjective"] }
let(:validate_template) { true }
let(:prompt) do
described_class.new(
prefix: "Write antonyms for the following words.",
suffix: "Input: {adjective}\nOutput:",
ex... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/prompts/loading_spec.rb | spec/lib/langchain/prompts/loading_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Prompt do
describe "#load_from_path" do
context "when json file" do
it "loads a new prompt from file" do
prompt = described_class.load_from_path(file_path: "spec/fixtures/prompt/prompt_template.json")
expect(prompt).to be_a(Langchain::... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/prompts/base_spec.rb | spec/lib/langchain/prompts/base_spec.rb | # frozen_string_literal: true
require "tempfile"
RSpec.describe Langchain::Prompt::Base do
subject { Langchain::Prompt::PromptTemplate.new(template: "Tell me a {adjective} joke.", input_variables: ["adjective"]) }
describe "#save" do
let(:file_path) { Tempfile.new(["test_file", ".json"]).path }
let(:inva... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/prompts/prompt_template_spec.rb | spec/lib/langchain/prompts/prompt_template_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Prompt::PromptTemplate do
let!(:prompt_example) do
<<~PROMPT.chomp
I want you to act as a naming consultant for new companies.
What is a good name for a company that makes {product}?
PROMPT
end
describe "#initialize" do
it "creates ... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/vectorsearch/weaviate_spec.rb | spec/lib/langchain/vectorsearch/weaviate_spec.rb | # frozen_string_literal: true
require "weaviate"
RSpec.describe Langchain::Vectorsearch::Weaviate do
subject {
described_class.new(
url: "http://localhost:8080",
api_key: "123",
index_name: "Products",
llm: Langchain::LLM::OpenAI.new(api_key: "123")
)
}
describe "#create_default... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/vectorsearch/milvus_spec.rb | spec/lib/langchain/vectorsearch/milvus_spec.rb | # frozen_string_literal: true
require "milvus"
RSpec.describe Langchain::Vectorsearch::Milvus do
let(:index_name) { "documents" }
subject {
described_class.new(
url: "http://localhost:8000",
api_key: "123",
index_name: index_name,
llm: Langchain::LLM::OpenAI.new(api_key: "123")
)
... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/vectorsearch/pinecone_spec.rb | spec/lib/langchain/vectorsearch/pinecone_spec.rb | # frozen_string_literal: true
require "pinecone"
RSpec.describe Langchain::Vectorsearch::Pinecone do
let(:index_name) { "documents" }
let(:namespace) { "namespaced" }
let(:llm) { Langchain::LLM::OpenAI.new(api_key: "123") }
subject {
described_class.new(
environment: "test",
api_key: "secret"... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/vectorsearch/base_spec.rb | spec/lib/langchain/vectorsearch/base_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Vectorsearch::Base do
subject { described_class.new(llm: Langchain::LLM::OpenAI.new(api_key: "123")) }
describe "#initialize" do
it "correctly sets llm" do
expect(
subject.llm
).to be_a(Langchain::LLM::OpenAI)
end
end
describ... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/vectorsearch/hnswlib_spec.rb | spec/lib/langchain/vectorsearch/hnswlib_spec.rb | # frozen_string_literal: true
require "hnswlib"
RSpec.describe Langchain::Vectorsearch::Hnswlib do
before do
FileUtils.rm("./test.ann") if File.exist?("./test.ann")
end
before do
allow_any_instance_of(Langchain::LLM::GoogleGemini).to receive(:default_dimensions).and_return(3)
end
let(:llm) { Langc... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/vectorsearch/elasticsearch_spec.rb | spec/lib/langchain/vectorsearch/elasticsearch_spec.rb | # frozen_string_literal: true
require "elasticsearch"
RSpec.describe Langchain::Vectorsearch::Elasticsearch do
let!(:llm) { Langchain::LLM::HuggingFace.new(api_key: "123456") }
subject {
Langchain::Vectorsearch::Elasticsearch.new(
url: "http://localhost:9200",
index_name: "langchain",
llm: l... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/vectorsearch/pgvector_spec.rb | spec/lib/langchain/vectorsearch/pgvector_spec.rb | # frozen_string_literal: true
require "pg"
if ENV["POSTGRES_URL"]
client = ::PG.connect(ENV["POSTGRES_URL"])
subject = Langchain::Vectorsearch::Pgvector.new(
url: ENV["POSTGRES_URL"],
index_name: "products",
llm: Langchain::LLM::OpenAI.new(api_key: "123")
)
subject.create_default_schema
RSpec.... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/vectorsearch/chroma_spec.rb | spec/lib/langchain/vectorsearch/chroma_spec.rb | # frozen_string_literal: true
require "chroma-db"
RSpec.describe Langchain::Vectorsearch::Chroma do
let(:index_name) { "documents" }
subject {
described_class.new(
url: "http://localhost:8000",
index_name: index_name,
llm: Langchain::LLM::OpenAI.new(api_key: "123")
)
}
before(:each... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/vectorsearch/qdrant_spec.rb | spec/lib/langchain/vectorsearch/qdrant_spec.rb | # frozen_string_literal: true
require "qdrant"
RSpec.describe Langchain::Vectorsearch::Qdrant do
let(:index_name) { "documents" }
subject {
described_class.new(
url: "http://localhost:8000",
index_name: index_name,
api_key: "secret",
llm: Langchain::LLM::OpenAI.new(api_key: "123")
... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/processors/xls_spec.rb | spec/lib/langchain/processors/xls_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Processors::Xls do
describe "#parse" do
let(:file) { File.open("spec/fixtures/loaders/sample.xls") }
let(:data) {
[
["Username", "Identifier", "First name", "Last name"],
["booker12", "9012", "Rachel", "Booker"],
["grey07",... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/processors/xlsx_spec.rb | spec/lib/langchain/processors/xlsx_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Processors::Xlsx do
describe "#parse" do
let(:file) { File.open("spec/fixtures/loaders/sample.xlsx") }
let(:data) {
[
["Username", "Identifier", "First name", "Last name"],
["booker12", "9012", "Rachel", "Booker"],
["grey07... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/processors/text_spec.rb | spec/lib/langchain/processors/text_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Processors::Text do
describe "#parse" do
let(:file) { File.open("spec/fixtures/loaders/example.txt") }
let(:text) { "Lorem Ipsum is simply dummy text of the printing and typesetting industry" }
it "parses the file and returns the text" do
exp... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/processors/jsonl_spec.rb | spec/lib/langchain/processors/jsonl_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Processors::JSONL do
describe "#parse" do
let(:file) { File.open("spec/fixtures/loaders/example.jsonl") }
let(:data) do
[
{"name" => "Luke Skywalker", "height" => "172", "mass" => "77"},
{"name" => "C-3PO", "height" => "167", "mass... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/processors/pdf_spec.rb | spec/lib/langchain/processors/pdf_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Processors::PDF do
describe "#parse" do
let(:file) { File.open("spec/fixtures/loaders/cairo-unicode.pdf") }
let(:text) { "UTF-8 encoded sample plain-text file" }
it "parses the file and returns the text" do
expect(described_class.new.parse(fi... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/processors/csv_spec.rb | spec/lib/langchain/processors/csv_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Processors::CSV do
describe "#parse" do
let(:file) { File.open("spec/fixtures/loaders/example.csv") }
context "without chunk_mode options" do
let(:data) {
<<~EXPECTED_OUTPUT.chomp
Username,Identifier,First name,Last name
... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/processors/html_spec.rb | spec/lib/langchain/processors/html_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Processors::HTML do
describe "#parse" do
let(:file) { File.open("spec/fixtures/loaders/example.html") }
let(:text) { "Lorem Ipsum\n\nDolor sit amet." }
it "parses the file and returns the text" do
expect(described_class.new.parse(file)).to in... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/processors/pptx_spec.rb | spec/lib/langchain/processors/pptx_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Processors::Pptx do
describe "#parse" do
let(:file) { File.open("spec/fixtures/loaders/sample.pptx") }
let(:text) { "Lorem ipsum dolor sit amet, consectetur adipiscing elit" }
it "parses the file and returns the text" do
expect(described_clas... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/processors/base_spec.rb | spec/lib/langchain/processors/base_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Processors::Base do
describe "#parse" do
it "must be implemented by subclasses" do
expect { described_class.new.parse("") }.to raise_error(NotImplementedError)
end
end
end
| ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/processors/json_spec.rb | spec/lib/langchain/processors/json_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Processors::JSON do
describe "#parse" do
let(:file) { File.open("spec/fixtures/loaders/example.json") }
let(:data) do
{
"name" => "Luke Skywalker",
"height" => 172,
"mass" => 77,
"hair_color" => "blond",
"sk... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/processors/eml_spec.rb | spec/lib/langchain/processors/eml_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Processors::Eml do
describe "#parse" do
let(:file) { File.open("spec/fixtures/loaders/sample.eml") }
let(:text) { "Lorem Ipsum.\nDolor sit amet." }
it "parses the file and returns the text" do
expect(described_class.new.parse(file)).to includ... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/processors/docx_spec.rb | spec/lib/langchain/processors/docx_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Processors::Docx do
describe "#parse" do
let(:file) { File.open("spec/fixtures/loaders/sample.docx") }
let(:text) { "Lorem ipsum dolor sit amet, consectetur adipiscing elit" }
it "parses the file and returns the text" do
expect(described_clas... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/processors/markdown_spec.rb | spec/lib/langchain/processors/markdown_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Processors::Markdown do
describe "#parse" do
let(:file) { File.open("spec/fixtures/loaders/example.md") }
let(:text) { "Lorem ipsum dolor sit amet, consectetur adipiscing elit." }
it "parses the file and returns the text" do
expect(described_... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/output_parsers/structured_spec.rb | spec/lib/langchain/output_parsers/structured_spec.rb | # frozen_string_literal: true
require_relative "spec_helper"
RSpec.describe Langchain::OutputParsers::StructuredOutputParser do
let!(:json_with_backticks_text_response) do
<<~RESPONSE
I'm responding with a narrative even though you asked for only json response:
```json
#{json_response.to_json... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/output_parsers/fix_spec.rb | spec/lib/langchain/output_parsers/fix_spec.rb | # frozen_string_literal: true
require_relative "spec_helper"
RSpec.describe Langchain::OutputParsers::OutputFixingParser do
let!(:llm_example) do
Langchain::LLM::OpenAI.new(api_key: "123")
end
let!(:parser_example) do
Langchain::OutputParsers::StructuredOutputParser.from_json_schema(schema_example)
e... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/output_parsers/base_spec.rb | spec/lib/langchain/output_parsers/base_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::OutputParsers::Base do
describe "#parse" do
it "must be implemented by subclasses" do
expect { described_class.new.parse(text: "") }.to raise_error(NotImplementedError)
end
end
describe "#get_format_instructions" do
it "must be implemente... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/output_parsers/spec_helper.rb | spec/lib/langchain/output_parsers/spec_helper.rb | # frozen_string_literal: true
def schema_example
{
type: "object",
properties: {
name: {
type: "string",
description: "Persons name"
},
age: {
type: "number",
description: "Persons age"
},
interests: {
type: "array",
items: {
... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/tool/database_spec.rb | spec/lib/langchain/tool/database_spec.rb | # frozen_string_literal: true
require "sequel"
RSpec.describe Langchain::Tool::Database do
subject { described_class.new(connection_string: "mock:///") }
describe "#execute" do
before do
rows = []
rows.push(salary: 23500, count: 101)
rows2 = []
rows2.push(job: "teacher", count: 5)
... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/tool/tavily_spec.rb | spec/lib/langchain/tool/tavily_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Tool::Tavily do
subject { described_class.new(api_key: "123") }
let(:response) {
"{\"query\":\"What's the height of Burj Khalifa?\",\"follow_up_questions\":null,\"answer\":\"The height of Burj Khalifa is 828 meters (2,717 feet).\"}"
}
describe "#sea... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/tool/ruby_code_interpreter_spec.rb | spec/lib/langchain/tool/ruby_code_interpreter_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Tool::RubyCodeInterpreter do
describe "#execute" do
it "executes the expression" do
response = subject.execute(input: '"hello world".reverse!')
expect(response).to be_a(Langchain::ToolResponse)
expect(response.content).to eq("dlrow olleh")... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/tool/file_system_spec.rb | spec/lib/langchain/tool/file_system_spec.rb | # frozen_string_literal: true
RSpec.describe Langchain::Tool::FileSystem do
subject { described_class.new }
context "directory operations" do
let(:directory_path) { "directory/path" }
let(:entries) { ["file1.txt", "file2.rb"] }
it "lists a directory" do
allow(Dir).to receive(:entries).with(dire... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/tool/google_search_spec.rb | spec/lib/langchain/tool/google_search_spec.rb | # frozen_string_literal: true
require "google_search_results"
RSpec.describe Langchain::Tool::GoogleSearch do
subject {
described_class.new(api_key: "123")
}
let(:response) do
{
answer_box: {
type: "organic_result",
title: "Empire State Building/Height",
link: "https://www... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/tool/weather_spec.rb | spec/lib/langchain/tool/weather_spec.rb | # spec/langchain/tool/weather_spec.rb
RSpec.describe Langchain::Tool::Weather do
let(:api_key) { "dummy_api_key" }
let(:weather_tool) { described_class.new(api_key: api_key) }
describe "#initialize" do
it "sets the API key" do
expect(weather_tool.instance_variable_get(:@api_key)).to eq(api_key)
en... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/tool/calculator_spec.rb | spec/lib/langchain/tool/calculator_spec.rb | # frozen_string_literal: true
require "eqn"
RSpec.describe Langchain::Tool::Calculator do
describe "#execute" do
it "calculates the result" do
response = subject.execute(input: "2+2")
expect(response).to be_a(Langchain::ToolResponse)
expect(response.content).to eq(4)
end
it "rescue an... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/spec/lib/langchain/tool/wikipedia_spec.rb | spec/lib/langchain/tool/wikipedia_spec.rb | # frozen_string_literal: true
require "wikipedia"
RSpec.describe Langchain::Tool::Wikipedia do
describe "#execute" do
before do
allow(Wikipedia).to receive(:find)
.with("Ruby")
.and_return(
double(summary: "Ruby is an interpreted, high-level, general-purpose programming language.... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/examples/create_and_manage_prompt_templates.rb | examples/create_and_manage_prompt_templates.rb | require "langchain"
# Create a prompt with one input variable
prompt = Langchain::Prompt::PromptTemplate.new(template: "Tell me a {adjective} joke.", input_variables: ["adjective"])
prompt.format(adjective: "funny") # "Tell me a funny joke."
# Create a prompt with multiple input variables
prompt = Langchain::Prompt::... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/examples/store_and_query_with_weaviate.rb | examples/store_and_query_with_weaviate.rb | require "langchain"
require "dotenv/load"
# gem install weaviate-ruby
# or add `gem "weaviate-ruby"` to your Gemfile
# Instantiate the Weaviate client
weaviate = Langchain::Vectorsearch::Weaviate.new(
url: ENV["WEAVIATE_URL"],
api_key: ENV["WEAVIATE_API_KEY"],
index_name: "Recipes",
llm: Langchain::LLM::OpenA... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/examples/store_and_query_with_milvus.rb | examples/store_and_query_with_milvus.rb | require "langchain"
# gem install pinecone
# or add `gem "milvus"` to your Gemfile
# Instantiate the OpenAI client
openai = Langchain::LLM::OpenAI.new(api_key: ENV["OPENAI_API_KEY"])
# Instantiate the Milvus client
milvus = Langchain::Vectorsearch::Milvus.new(
url: ENV["MILVUS_URL"],
index_name: "recipes",
llm... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/examples/create_and_manage_few_shot_prompt_templates.rb | examples/create_and_manage_few_shot_prompt_templates.rb | require "langchain"
# Create a prompt with a few shot examples
prompt = Langchain::Prompt::FewShotPromptTemplate.new(
prefix: "Write antonyms for the following words.",
suffix: "Input: {adjective}\nOutput:",
example_prompt: Langchain::Prompt::PromptTemplate.new(
input_variables: ["input", "output"],
temp... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/examples/create_and_manage_prompt_templates_using_structured_output_parser.rb | examples/create_and_manage_prompt_templates_using_structured_output_parser.rb | require "langchain"
# Generate a prompt that directs the LLM to provide a JSON response that adheres to a specific JSON schema.
json_schema = {
type: "object",
properties: {
name: {
type: "string",
description: "Persons name"
},
age: {
type: "number",
description: "Persons age"
... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/examples/store_and_query_with_pinecone.rb | examples/store_and_query_with_pinecone.rb | require "langchain"
require "dotenv/load"
# gem install pinecone
# or add `gem "pinecone"` to your Gemfile
# Instantiate the Pinecone client
pinecone = Langchain::Vectorsearch::Pinecone.new(
environment: ENV["PINECONE_ENVIRONMENT"],
api_key: ENV["PINECONE_API_KEY"],
index_name: "recipes",
llm: Langchain::LLM:... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/examples/openai_qdrant_function_calls.rb | examples/openai_qdrant_function_calls.rb | require "langchain"
require "dotenv/load"
functions = [
{
name: "create_rails_controller",
description: "gives a command to create a rails controller",
parameters: {
type: :object,
properties: {
controller_name: {
type: :string,
description: "the controller name, e... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/examples/store_and_query_with_pgvector_using_metadata.rb | examples/store_and_query_with_pgvector_using_metadata.rb | # frozen_string_literal: true
require "langchain"
require "dotenv/load"
require "ruby/openai"
# Initialize the Pgvector client
pgvector = Langchain::Vectorsearch::Pgvector.new(
url: ENV["POSTGRES_URL"],
index_name: "documents",
llm: Langchain::LLM::OpenAI.new(api_key: ENV["OPENAI_API_KEY"])
)
# Create the defa... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/examples/store_and_query_with_qdrant.rb | examples/store_and_query_with_qdrant.rb | require "langchain"
require "dotenv/load"
# gem install qdrant-ruby
# or add `gem "qdrant-ruby"` to your Gemfile
# Instantiate the Qdrant client
qdrant = Langchain::Vectorsearch::Qdrant.new(
url: ENV["QDRANT_URL"],
api_key: ENV["QDRANT_API_KEY"],
index_name: "recipes",
llm: Langchain::LLM::Cohere.new(api_key:... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/examples/ollama_inquire_about_image.rb | examples/ollama_inquire_about_image.rb | require_relative "../lib/langchain"
require "faraday"
llm = Langchain::LLM::Ollama.new(default_options: {chat_model: "llava"})
assistant = Langchain::Assistant.new(llm: llm)
response = assistant.add_message_and_run(
image_url: "https://gist.githubusercontent.com/andreibondarev/b6f444194d0ee7ab7302a4d83184e53e/raw/... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/examples/assistant_chat.rb | examples/assistant_chat.rb | require "dotenv/load"
require "langchain"
require "openai"
require "reline"
# gem install reline
# or add `gem "reline"` to your Gemfile
openai = Langchain::LLM::OpenAI.new(api_key: ENV["OPENAI_API_KEY"])
assistant = Langchain::Assistant.new(
llm: openai,
instructions: "You are a Meteorologist Assistant that is a... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/examples/pdf_store_and_query_with_chroma.rb | examples/pdf_store_and_query_with_chroma.rb | require "langchain"
require "dotenv/load"
# gem install chroma-db
# or add `gem "chroma-db", "~> 0.6.0"` to your Gemfile
# Instantiate the Chroma client
chroma = Langchain::Vectorsearch::Chroma.new(
url: ENV["CHROMA_URL"],
index_name: "documents",
llm: Langchain::LLM::OpenAI.new(api_key: ENV["OPENAI_API_KEY"])
... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/lib/langchainrb.rb | lib/langchainrb.rb | require "langchain"
| ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/lib/langchain.rb | lib/langchain.rb | require "logger"
require "langchain/version"
require "langchain/engine"
module Langchain
class << self
# @return [Logger]
attr_accessor :logger
# @return [Pathname]
attr_reader :root
end
module Errors
class BaseError < StandardError; end
end
module Colorizer
class << self
def ... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/lib/langchain/dependency_helper.rb | lib/langchain/dependency_helper.rb | # frozen_string_literal: true
module Langchain
module DependencyHelper
class LoadError < ::LoadError; end
class VersionError < ScriptError; end
# This method requires and loads the given gem, and then checks to see if the version of the gem meets the requirements listed in `langchain.gemspec`
# Thi... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/lib/langchain/chunk.rb | lib/langchain/chunk.rb | # frozen_string_literal: true
module Langchain
class Chunk
# The chunking process is the process of splitting a document into smaller chunks and creating instances of Langchain::Chunk
attr_reader :text
# Initialize a new chunk
# @param [String] text
# @return [Langchain::Chunk]
def initiali... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/lib/langchain/data.rb | lib/langchain/data.rb | # frozen_string_literal: true
module Langchain
# Abstraction for data loaded by a {Langchain::Loader}
class Data
# URL or Path of the data source
# @return [String]
attr_reader :source
# @param data [String] data that was loaded
# @option options [String] :source URL or Path of the data source... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/lib/langchain/version.rb | lib/langchain/version.rb | # frozen_string_literal: true
module Langchain
VERSION = "0.19.5"
Version = VERSION
end
| ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/lib/langchain/loader.rb | lib/langchain/loader.rb | # frozen_string_literal: true
require "open-uri"
module Langchain
class Loader
class FileNotFound < StandardError; end
class UnknownFormatError < StandardError; end
URI_REGEX = %r{\A[A-Za-z][A-Za-z0-9+\-.]*://}
# Load data from a file or URL. Shorthand for `Langchain::Loader.new(path).load`
... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/lib/langchain/assistant.rb | lib/langchain/assistant.rb | # frozen_string_literal: true
module Langchain
# Assistants are Agent-like objects that leverage helpful instructions, LLMs, tools and knowledge to respond to user queries.
# Assistants can be configured with an LLM of your choice, any vector search database and easily extended with additional tools.
#
# Usage... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/lib/langchain/application_record.rb | lib/langchain/application_record.rb | module Langchain
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
end
| ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/lib/langchain/prompt.rb | lib/langchain/prompt.rb | module Langchain
module Prompt
include Loading
end
end
| ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.