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/lib/langchain/tool_definition.rb
lib/langchain/tool_definition.rb
# frozen_string_literal: true # # Extends a class to be used as a tool in the assistant. # A tool is a collection of functions (methods) used to perform specific tasks. # # == Usage # # 1. Extend your class with {Langchain::ToolDefinition} # 2. Use {#define_function} to define each function of the tool # # == Key Conc...
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/engine.rb
lib/langchain/engine.rb
module Langchain class Engine < ::Rails::Engine isolate_namespace Langchain config.autoload_paths << root.join("lib") config.eager_load_paths << root.join("lib") 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/tool_response.rb
lib/langchain/tool_response.rb
# frozen_string_literal: true module Langchain # ToolResponse represents the standardized output of a tool. # It can contain either text content or an image URL. class ToolResponse attr_reader :content, :image_url # Initializes a new ToolResponse. # # @param content [String] The text content of ...
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/chunker/text.rb
lib/langchain/chunker/text.rb
# frozen_string_literal: true require "baran" module Langchain module Chunker # Simple text chunker # # Usage: # Langchain::Chunker::Text.new(text).chunks class Text < Base attr_reader :text, :chunk_size, :chunk_overlap, :separator # @param [String] text # @param [Integer]...
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/chunker/semantic.rb
lib/langchain/chunker/semantic.rb
# frozen_string_literal: true module Langchain module Chunker # LLM-powered semantic chunker. # Semantic chunking is a technique of splitting texts by their semantic meaning, e.g.: themes, topics, and ideas. # We use an LLM to accomplish this. The Anthropic LLM is highly recommended for this task as it h...
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/chunker/base.rb
lib/langchain/chunker/base.rb
# frozen_string_literal: true module Langchain module Chunker # = Chunkers # Chunkers are used to split documents into smaller chunks before indexing into vector search databases. # Otherwise large documents, when retrieved and passed to LLMs, may hit the context window limits. # # == Available c...
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/chunker/sentence.rb
lib/langchain/chunker/sentence.rb
# frozen_string_literal: true require "pragmatic_segmenter" module Langchain module Chunker # This chunker splits text by sentences. # # Usage: # Langchain::Chunker::Sentence.new(text).chunks class Sentence < Base attr_reader :text # @param text [String] # @return [Langcha...
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/chunker/markdown.rb
lib/langchain/chunker/markdown.rb
# frozen_string_literal: true require "baran" module Langchain module Chunker # Simple text chunker # # Usage: # Langchain::Chunker::Markdown.new(text).chunks class Markdown < Base attr_reader :text, :chunk_size, :chunk_overlap # @param [String] text # @param [Integer] chu...
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/chunker/recursive_text.rb
lib/langchain/chunker/recursive_text.rb
# frozen_string_literal: true require "baran" module Langchain module Chunker # Recursive text chunker. Preferentially splits on separators. # # Usage: # Langchain::Chunker::RecursiveText.new(text).chunks class RecursiveText < Base attr_reader :text, :chunk_size, :chunk_overlap, :separ...
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/evals/ragas/main.rb
lib/langchain/evals/ragas/main.rb
# freeze_string_literal: true module Langchain module Evals # The RAGAS (Retrieval Augmented Generative Assessment) is a framework for evaluating RAG (Retrieval Augmented Generation) pipelines. # Based on the following research: https://arxiv.org/pdf/2309.15217.pdf module Ragas class Main a...
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/evals/ragas/faithfulness.rb
lib/langchain/evals/ragas/faithfulness.rb
# freeze_string_literal: true module Langchain module Evals module Ragas # Faithfulness refers to the idea that the answer should be grounded in the given context, # ensuring that the retrieved context can act as a justification for the generated answer. # The answer is faithful to the context ...
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/evals/ragas/context_relevance.rb
lib/langchain/evals/ragas/context_relevance.rb
# freeze_string_literal: true require "pragmatic_segmenter" module Langchain module Evals module Ragas # Context Relevance refers to the idea that the retrieved context should be focused, containing as little irrelevant information as possible. class ContextRelevance attr_reader :llm ...
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/evals/ragas/answer_relevance.rb
lib/langchain/evals/ragas/answer_relevance.rb
# freeze_string_literal: true require "matrix" module Langchain module Evals module Ragas # Answer Relevance refers to the idea that the generated answer should address the actual question that was provided. # This metric evaluates how closely the generated answer aligns with the initial question or...
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/utils/image_wrapper.rb
lib/langchain/utils/image_wrapper.rb
# frozen_string_literal: true require "open-uri" require "base64" module Langchain module Utils class ImageWrapper attr_reader :image_url def initialize(image_url) @image_url = image_url end def base64 @base64 ||= begin image_data = open_image.read B...
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/utils/hash_transformer.rb
lib/langchain/utils/hash_transformer.rb
module Langchain module Utils class HashTransformer def self.symbolize_keys(hash) hash.map do |k, v| new_key = begin k.to_sym rescue k end new_value = v.is_a?(Hash) ? symbolize_keys(v) : v [new_key, new_value] end.to_h...
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/utils/to_boolean.rb
lib/langchain/utils/to_boolean.rb
# frozen_string_literal: true module Langchain module Utils class ToBoolean TRUTHABLE_STRINGS = %w[1 true t yes y] private_constant :TRUTHABLE_STRINGS def to_bool(value) case value when String TRUTHABLE_STRINGS.include?(value.downcase) when Integer v...
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/utils/cosine_similarity.rb
lib/langchain/utils/cosine_similarity.rb
# frozen_string_literal: true module Langchain module Utils class CosineSimilarity attr_reader :vector_a, :vector_b # @param vector_a [Array<Float>] First vector # @param vector_b [Array<Float>] Second vector def initialize(vector_a, vector_b) @vector_a = vector_a @vector...
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/llm/ai21.rb
lib/langchain/llm/ai21.rb
# frozen_string_literal: true module Langchain::LLM # # Wrapper around AI21 Studio APIs. # # Gem requirements: # gem "ai21", "~> 0.2.1" # # Usage: # llm = Langchain::LLM::AI21.new(api_key: ENV["AI21_API_KEY"]) # # @deprecated Use another LLM provider. class AI21 < Base DEFAULTS = { ...
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/llm/mistralai.rb
lib/langchain/llm/mistralai.rb
# frozen_string_literal: true module Langchain::LLM # Gem requirements: # gem "mistral-ai" # # Usage: # llm = Langchain::LLM::MistralAI.new(api_key: ENV["MISTRAL_AI_API_KEY"]) class MistralAI < Base DEFAULTS = { chat_model: "mistral-large-latest", embedding_model: "mistral-embed" ...
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/llm/unified_parameters.rb
lib/langchain/llm/unified_parameters.rb
# frozen_string_literal: true module Langchain::LLM class UnifiedParameters include Enumerable attr_reader :schema, :aliases, :parameters, :ignored, :remapped class Null < self def initialize(parameters: {}) super(schema: {}, parameters: parameters) end end def initialize(s...
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/llm/ollama.rb
lib/langchain/llm/ollama.rb
# frozen_string_literal: true module Langchain::LLM # Interface to Ollama API. # Available models: https://ollama.ai/library # # Gem requirements: # gem "faraday" # # Usage: # llm = Langchain::LLM::Ollama.new(url: ENV["OLLAMA_URL"], default_options: {}) # class Ollama < Base attr_reader :...
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/llm/aws_bedrock.rb
lib/langchain/llm/aws_bedrock.rb
# frozen_string_literal: true module Langchain::LLM # LLM interface for Aws Bedrock APIs: https://docs.aws.amazon.com/bedrock/ # # Gem requirements: # gem 'aws-sdk-bedrockruntime', '~> 1.1' # # Usage: # llm = Langchain::LLM::AwsBedrock.new(default_options: {}) # class AwsBedrock < Base DEFA...
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/llm/google_gemini.rb
lib/langchain/llm/google_gemini.rb
# frozen_string_literal: true module Langchain::LLM # Usage: # llm = Langchain::LLM::GoogleGemini.new(api_key: ENV['GOOGLE_GEMINI_API_KEY']) class GoogleGemini < Base DEFAULTS = { chat_model: "gemini-1.5-pro-latest", embedding_model: "text-embedding-004", temperature: 0.0 } att...
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/llm/openai.rb
lib/langchain/llm/openai.rb
# frozen_string_literal: true require "openai" module Langchain::LLM # LLM interface for OpenAI APIs: https://platform.openai.com/overview # # Gem requirements: # gem "ruby-openai", "~> 6.3.0" # # Usage: # llm = Langchain::LLM::OpenAI.new( # api_key: ENV["OPENAI_API_KEY"], # llm_opti...
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/llm/anthropic.rb
lib/langchain/llm/anthropic.rb
# frozen_string_literal: true module Langchain::LLM # # Wrapper around Anthropic APIs. # # Gem requirements: # gem "anthropic", "~> 0.3.2" # # Usage: # llm = Langchain::LLM::Anthropic.new(api_key: ENV["ANTHROPIC_API_KEY"]) # class Anthropic < Base DEFAULTS = { temperature: 0.0, ...
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/llm/base.rb
lib/langchain/llm/base.rb
# frozen_string_literal: true module Langchain::LLM class ApiError < StandardError; end # A LLM is a language model consisting of a neural network with many parameters (typically billions of weights or more), trained on large quantities of unlabeled text using self-supervised learning or semi-supervised learning....
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/llm/hugging_face.rb
lib/langchain/llm/hugging_face.rb
# frozen_string_literal: true module Langchain::LLM # # Wrapper around the HuggingFace Inference API: https://huggingface.co/inference-api # # Gem requirements: # gem "hugging-face", "~> 0.3.4" # # Usage: # llm = Langchain::LLM::HuggingFace.new(api_key: ENV["HUGGING_FACE_API_KEY"]) # class ...
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/llm/azure.rb
lib/langchain/llm/azure.rb
# frozen_string_literal: true module Langchain::LLM # LLM interface for Azure OpenAI Service APIs: https://learn.microsoft.com/en-us/azure/ai-services/openai/ # # Gem requirements: # gem "ruby-openai", "~> 6.3.0" # # Usage: # llm = Langchain::LLM::Azure.new(api_key:, llm_options: {}, embedding_depl...
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/llm/llama_cpp.rb
lib/langchain/llm/llama_cpp.rb
# frozen_string_literal: true module Langchain::LLM # A wrapper around the LlamaCpp.rb library # # Gem requirements: # gem "llama_cpp" # # Usage: # llama = Langchain::LLM::LlamaCpp.new( # model_path: ENV["LLAMACPP_MODEL_PATH"], # n_gpu_layers: Integer(ENV["LLAMACPP_N_GPU_LAYERS"])...
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/llm/cohere.rb
lib/langchain/llm/cohere.rb
# frozen_string_literal: true module Langchain::LLM # # Wrapper around the Cohere API. # # Gem requirements: # gem "cohere-ruby", "~> 0.9.6" # # Usage: # llm = Langchain::LLM::Cohere.new(api_key: ENV["COHERE_API_KEY"]) # class Cohere < Base DEFAULTS = { temperature: 0.0, com...
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/llm/google_vertexai.rb
lib/langchain/llm/google_vertexai.rb
# frozen_string_literal: true module Langchain::LLM # # Wrapper around the Google Vertex AI APIs: https://cloud.google.com/vertex-ai # # Gem requirements: # gem "googleauth" # # Usage: # llm = Langchain::LLM::GoogleVertexAI.new(project_id: ENV["GOOGLE_VERTEX_AI_PROJECT_ID"], region: "us-central...
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/llm/replicate.rb
lib/langchain/llm/replicate.rb
# frozen_string_literal: true module Langchain::LLM # # Wrapper around Replicate.com LLM provider # # Gem requirements: # gem "replicate-ruby", "~> 0.2.2" # # Usage: # llm = Langchain::LLM::Replicate.new(api_key: ENV["REPLICATE_API_KEY"]) class Replicate < Base DEFAULTS = { # TODO: ...
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/llm/parameters/chat.rb
lib/langchain/llm/parameters/chat.rb
# frozen_string_literal: true require "delegate" module Langchain::LLM::Parameters class Chat < SimpleDelegator # TODO: At the moment, the UnifiedParamters only considers keys. In the # future, we may consider ActiveModel-style validations and further typed # options here. SCHEMA = { # Either...
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/llm/response/openai_response.rb
lib/langchain/llm/response/openai_response.rb
# frozen_string_literal: true module Langchain::LLM::Response class OpenAIResponse < BaseResponse def model raw_response["model"] end def created_at if raw_response.dig("created") Time.at(raw_response.dig("created")) end end def completion completions&.dig(0, "me...
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/llm/response/google_gemini_response.rb
lib/langchain/llm/response/google_gemini_response.rb
# frozen_string_literal: true module Langchain::LLM::Response class GoogleGeminiResponse < BaseResponse def initialize(raw_response, model: nil) super end def chat_completion raw_response.dig("candidates", 0, "content", "parts", 0, "text") end def role raw_response.dig("candid...
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/llm/response/replicate_response.rb
lib/langchain/llm/response/replicate_response.rb
# frozen_string_literal: true module Langchain::LLM::Response class ReplicateResponse < BaseResponse def completions # Response comes back as an array of strings, e.g.: ["Hi", "how ", "are ", "you?"] # The first array element is missing a space at the end, so we add it manually raw_response.out...
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/llm/response/hugging_face_response.rb
lib/langchain/llm/response/hugging_face_response.rb
# frozen_string_literal: true module Langchain::LLM::Response class HuggingFaceResponse < BaseResponse def embeddings [raw_response] end def embedding embeddings.first 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/lib/langchain/llm/response/ollama_response.rb
lib/langchain/llm/response/ollama_response.rb
# frozen_string_literal: true module Langchain::LLM::Response class OllamaResponse < BaseResponse def initialize(raw_response, model: nil, prompt_tokens: nil) @prompt_tokens = prompt_tokens super(raw_response, model: model) end def created_at Time.parse(raw_response.dig("created_at")) ...
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/llm/response/anthropic_response.rb
lib/langchain/llm/response/anthropic_response.rb
# frozen_string_literal: true module Langchain::LLM::Response class AnthropicResponse < BaseResponse def model raw_response.dig("model") end def completion completions.first end def chat_completion chat_completion = chat_completions.find { |h| h["type"] == "text" } chat_...
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/llm/response/aws_titan_response.rb
lib/langchain/llm/response/aws_titan_response.rb
# frozen_string_literal: true module Langchain::LLM::Response class AwsTitanResponse < BaseResponse def embedding embeddings&.first end def embeddings [raw_response.dig("embedding")] end def prompt_tokens raw_response.dig("inputTextTokenCount") 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/lib/langchain/llm/response/base_response.rb
lib/langchain/llm/response/base_response.rb
# frozen_string_literal: true module Langchain module LLM::Response class BaseResponse attr_reader :raw_response, :model # Save context in the response when doing RAG workflow vectorsearch#ask() attr_accessor :context def initialize(raw_response, model: nil) @raw_response = raw_...
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/llm/response/llama_cpp_response.rb
lib/langchain/llm/response/llama_cpp_response.rb
# frozen_string_literal: true module Langchain::LLM::Response class LlamaCppResponse < BaseResponse def embedding embeddings end def embeddings raw_response.embeddings 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/lib/langchain/llm/response/ai21_response.rb
lib/langchain/llm/response/ai21_response.rb
# frozen_string_literal: true module Langchain::LLM::Response class AI21Response < BaseResponse def completions raw_response.dig(:completions) end def completion completions.dig(0, :data, :text) end def chat_completion raw_response.dig(:choices, 0, :message, :content) 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/llm/response/cohere_response.rb
lib/langchain/llm/response/cohere_response.rb
# frozen_string_literal: true module Langchain::LLM::Response class CohereResponse < BaseResponse def embedding embeddings.first end def embeddings raw_response.dig("embeddings") end def completions raw_response.dig("generations") end def completion completions&...
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/llm/response/mistralai_response.rb
lib/langchain/llm/response/mistralai_response.rb
# frozen_string_literal: true module Langchain::LLM::Response class MistralAIResponse < BaseResponse def model raw_response["model"] end def chat_completion chat_completions.dig(0, "message", "content") end def chat_completions raw_response.dig("choices") end def tool...
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/llm/response/aws_bedrock_meta_response.rb
lib/langchain/llm/response/aws_bedrock_meta_response.rb
# frozen_string_literal: true module Langchain::LLM::Response class AwsBedrockMetaResponse < BaseResponse def completion completions.first end def completions [raw_response.dig("generation")] end def stop_reason raw_response.dig("stop_reason") end def prompt_tokens ...
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/messages/openai_message.rb
lib/langchain/assistant/messages/openai_message.rb
# frozen_string_literal: true module Langchain class Assistant module Messages class OpenAIMessage < Base # OpenAI uses the following roles: ROLES = [ "system", "assistant", "user", "tool" ].freeze TOOL_ROLE = "tool" # Initia...
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/messages/ollama_message.rb
lib/langchain/assistant/messages/ollama_message.rb
# frozen_string_literal: true module Langchain class Assistant module Messages class OllamaMessage < Base # OpenAI uses the following roles: ROLES = [ "system", "assistant", "user", "tool" ].freeze TOOL_ROLE = "tool" # Initia...
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/messages/base.rb
lib/langchain/assistant/messages/base.rb
# frozen_string_literal: true module Langchain class Assistant module Messages class Base attr_reader :role, :content, :image_url, :tool_calls, :tool_call_id # Check if the message came from a user # # @return [Boolean] true/false whe...
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/messages/google_gemini_message.rb
lib/langchain/assistant/messages/google_gemini_message.rb
# frozen_string_literal: true module Langchain class Assistant module Messages class GoogleGeminiMessage < Base # Google Gemini uses the following roles: ROLES = [ "user", "model", "function" ].freeze TOOL_ROLE = "function" # Initializ...
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/messages/mistralai_message.rb
lib/langchain/assistant/messages/mistralai_message.rb
# frozen_string_literal: true module Langchain class Assistant module Messages class MistralAIMessage < Base # MistralAI uses the following roles: ROLES = [ "system", "assistant", "user", "tool" ].freeze TOOL_ROLE = "tool" # ...
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/messages/anthropic_message.rb
lib/langchain/assistant/messages/anthropic_message.rb
# frozen_string_literal: true module Langchain class Assistant module Messages class AnthropicMessage < Base ROLES = [ "assistant", "user", "tool_result" ].freeze TOOL_ROLE = "tool_result" # Initialize a new Anthropic message # ...
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/llm/adapter.rb
lib/langchain/assistant/llm/adapter.rb
# frozen_string_literal: true module Langchain class Assistant module LLM # TODO: Fix the message truncation when context window is exceeded class Adapter def self.build(llm) if llm.is_a?(Langchain::LLM::Anthropic) LLM::Adapters::Anthropic.new elsif llm.is_a?(L...
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/llm/adapters/mistralai.rb
lib/langchain/assistant/llm/adapters/mistralai.rb
# frozen_string_literal: true module Langchain class Assistant module LLM module Adapters class MistralAI < Base # Build the chat parameters for the Mistral AI LLM # # @param messages [Array] The messages # @param instructions [String] The system instructions...
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/llm/adapters/aws_bedrock_anthropic.rb
lib/langchain/assistant/llm/adapters/aws_bedrock_anthropic.rb
# frozen_string_literal: true module Langchain class Assistant module LLM module Adapters class AwsBedrockAnthropic < Anthropic private # @param [String] choice # @param [Boolean] _parallel_tool_calls # @return [Hash] def build_tool_choice(choice, ...
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/llm/adapters/ollama.rb
lib/langchain/assistant/llm/adapters/ollama.rb
# frozen_string_literal: true module Langchain class Assistant module LLM module Adapters class Ollama < Base # Build the chat parameters for the Ollama LLM # # @param messages [Array] The messages # @param instructions [String] The system instructions ...
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/llm/adapters/google_gemini.rb
lib/langchain/assistant/llm/adapters/google_gemini.rb
# frozen_string_literal: true module Langchain class Assistant module LLM module Adapters class GoogleGemini < Base # Build the chat parameters for the Google Gemini LLM # # @param messages [Array] The messages # @param instructions [String] The system instru...
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/llm/adapters/openai.rb
lib/langchain/assistant/llm/adapters/openai.rb
# frozen_string_literal: true module Langchain class Assistant module LLM module Adapters class OpenAI < Base # Build the chat parameters for the OpenAI LLM # # @param messages [Array] The messages # @param instructions [String] The system instructions ...
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/llm/adapters/anthropic.rb
lib/langchain/assistant/llm/adapters/anthropic.rb
# frozen_string_literal: true module Langchain class Assistant module LLM module Adapters class Anthropic < Base # Build the chat parameters for the Anthropic API # # @param messages [Array<Hash>] The messages # @param instructions [String] The system instruc...
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/llm/adapters/base.rb
lib/langchain/assistant/llm/adapters/base.rb
# frozen_string_literal: true module Langchain class Assistant module LLM module Adapters class Base # Build the chat parameters for the LLM # # @param messages [Array] The messages # @param instructions [String] The system instructions # @param too...
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/few_shot_prompt_template.rb
lib/langchain/prompt/few_shot_prompt_template.rb
# frozen_string_literal: true module Langchain::Prompt # = Few Shot Prompt Templates # # Create a prompt with a few shot examples: # # prompt = Langchain::Prompt::FewShotPromptTemplate.new( # prefix: "Write antonyms for the following words.", # suffix: "Input: <code>{adjective}</code>\nOu...
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/prompt_template.rb
lib/langchain/prompt/prompt_template.rb
# frozen_string_literal: true module Langchain::Prompt # = Prompt Templates # # 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...
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/base.rb
lib/langchain/prompt/base.rb
# frozen_string_literal: true require "strscan" require "yaml" module Langchain::Prompt # Prompts are structured inputs to the LLMs. Prompts provide instructions, context and other user input that LLMs use to generate responses. # # @abstract class Base def format(**kwargs) raise NotImplementedError...
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/loading.rb
lib/langchain/prompt/loading.rb
# frozen_string_literal: true require "strscan" require "pathname" require "yaml" module Langchain::Prompt TYPE_TO_LOADER = { "prompt" => ->(config) { load_prompt(config) }, "few_shot" => ->(config) { load_few_shot_prompt(config) } } module Loading def self.included(base) base.extend ClassMet...
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/vectorsearch/weaviate.rb
lib/langchain/vectorsearch/weaviate.rb
# frozen_string_literal: true module Langchain::Vectorsearch # # Wrapper around Weaviate # # Gem requirements: # gem "weaviate-ruby", "~> 0.9.2" # # Usage: # weaviate = Langchain::Vectorsearch::Weaviate.new(url: ENV["WEAVIATE_URL"], api_key: ENV["WEAVIATE_API_KEY"], index_name: "Docs", llm: llm...
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/vectorsearch/qdrant.rb
lib/langchain/vectorsearch/qdrant.rb
# frozen_string_literal: true module Langchain::Vectorsearch # # Wrapper around Qdrant # # Gem requirements: # gem "qdrant-ruby", "~> 0.9.8" # # Usage: # qdrant = Langchain::Vectorsearch::Qdrant.new(url:, api_key:, index_name:, llm:) # class Qdrant < Base # Initialize the Qdrant client ...
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/vectorsearch/pinecone.rb
lib/langchain/vectorsearch/pinecone.rb
# frozen_string_literal: true module Langchain::Vectorsearch # # Wrapper around Pinecone API. # # Gem requirements: # gem "pinecone", "~> 0.1" # # Usage: # pinecone = Langchain::Vectorsearch::Pinecone.new(environment:, api_key:, index_name:, llm:) # class Pinecone < Base # Initialize th...
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/vectorsearch/milvus.rb
lib/langchain/vectorsearch/milvus.rb
# frozen_string_literal: true module Langchain::Vectorsearch # # Wrapper around Milvus REST APIs. # # Gem requirements: # gem "milvus", "~> 0.10.3" # # Usage: # milvus = Langchain::Vectorsearch::Milvus.new(url:, index_name:, llm:, api_key:) # class Milvus < Base def initialize(url:, ind...
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/vectorsearch/hnswlib.rb
lib/langchain/vectorsearch/hnswlib.rb
# frozen_string_literal: true module Langchain::Vectorsearch # # Wrapper around HNSW (Hierarchical Navigable Small World) library. # HNSWLib is an in-memory vectorstore that can be saved to a file on disk. # # Gem requirements: # gem "hnswlib", "~> 0.8.1" # # Usage: # hnsw = Langchain::Vector...
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/vectorsearch/pgvector.rb
lib/langchain/vectorsearch/pgvector.rb
# frozen_string_literal: true module Langchain::Vectorsearch # # The PostgreSQL vector search adapter # # Gem requirements: # gem "sequel", "~> 5.87.0" # gem "pgvector", "~> 0.2" # # Usage: # pgvector = Langchain::Vectorsearch::Pgvector.new(url:, index_name:, llm:, namespace: nil) # c...
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/vectorsearch/base.rb
lib/langchain/vectorsearch/base.rb
# frozen_string_literal: true module Langchain::Vectorsearch # = Vector Databases # A vector database a type of database that stores data as high-dimensional vectors, which are mathematical representations of features or attributes. Each vector has a certain number of dimensions, which can range from tens to thous...
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/vectorsearch/elasticsearch.rb
lib/langchain/vectorsearch/elasticsearch.rb
# frozen_string_literal: true module Langchain::Vectorsearch # # Wrapper around Elasticsearch vector search capabilities. # # Setting up Elasticsearch: # 1. Get Elasticsearch up and running with Docker: https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html # 2. Copy the HTTP CA certif...
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/vectorsearch/chroma.rb
lib/langchain/vectorsearch/chroma.rb
# frozen_string_literal: true module Langchain::Vectorsearch # # Wrapper around Chroma DB # # Gem requirements: # gem "chroma-db", "~> 0.6.0" # # Usage: # chroma = Langchain::Vectorsearch::Chroma.new(url:, index_name:, llm:, api_key: nil) # class Chroma < Base # Initialize the Chroma cl...
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/processors/jsonl.rb
lib/langchain/processors/jsonl.rb
# frozen_string_literal: true module Langchain module Processors class JSONL < Base EXTENSIONS = [".jsonl"] CONTENT_TYPES = ["application/jsonl", "application/json-lines", "application/jsonlines"] # Parse the document and return the text # @param [File] data # @return [Array of Has...
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/processors/text.rb
lib/langchain/processors/text.rb
# frozen_string_literal: true module Langchain module Processors class Text < Base EXTENSIONS = [".txt"] CONTENT_TYPES = ["text/plain"] # Parse the document and return the text # @param [File] data # @return [String] def parse(data) data.read end end end e...
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/processors/xlsx.rb
lib/langchain/processors/xlsx.rb
# frozen_string_literal: true module Langchain module Processors class Xlsx < Base EXTENSIONS = [".xlsx", ".xlsm"].freeze CONTENT_TYPES = ["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"].freeze def initialize(*) depends_on "roo" end # Parse the documen...
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/processors/csv.rb
lib/langchain/processors/csv.rb
# frozen_string_literal: true require "csv" module Langchain module Processors class CSV < Base class InvalidChunkMode < StandardError; end EXTENSIONS = [".csv"] CONTENT_TYPES = ["text/csv"] CHUNK_MODE = { row: "row", file: "file" } # Parse the document and ...
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/processors/json.rb
lib/langchain/processors/json.rb
# frozen_string_literal: true module Langchain module Processors class JSON < Base EXTENSIONS = [".json"] CONTENT_TYPES = ["application/json"] # Parse the document and return the text # @param [File] data # @return [Hash] def parse(data) ::JSON.parse(data.read) ...
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/processors/docx.rb
lib/langchain/processors/docx.rb
# frozen_string_literal: true module Langchain module Processors class Docx < Base EXTENSIONS = [".docx"] CONTENT_TYPES = ["application/vnd.openxmlformats-officedocument.wordprocessingml.document"] def initialize(*) depends_on "docx" end # Parse the document and return the...
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/processors/base.rb
lib/langchain/processors/base.rb
# frozen_string_literal: true module Langchain module Processors # Processors load and parse/process various data types such as CSVs, PDFs, Word documents, HTML pages, and others. class Base include Langchain::DependencyHelper EXTENSIONS = [] CONTENT_TYPES = [] def initialize(option...
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/processors/markdown.rb
lib/langchain/processors/markdown.rb
# frozen_string_literal: true module Langchain module Processors class Markdown < Base EXTENSIONS = [".markdown", ".md"] CONTENT_TYPES = ["text/markdown"] # Parse the document and return the text # @param [File] data # @return [String] def parse(data) data.read ...
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/processors/pptx.rb
lib/langchain/processors/pptx.rb
# frozen_string_literal: true module Langchain module Processors class Pptx < Base EXTENSIONS = [".pptx"] CONTENT_TYPES = ["application/vnd.openxmlformats-officedocument.presentationml.presentation"] def initialize(*) depends_on "power_point_pptx" end # Parse the document ...
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/processors/pdf.rb
lib/langchain/processors/pdf.rb
# frozen_string_literal: true require "pdf-reader" module Langchain module Processors class PDF < Base EXTENSIONS = [".pdf"] CONTENT_TYPES = ["application/pdf"] def initialize(*) depends_on "pdf-reader" end # Parse the document and return the text # @param [File] da...
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/processors/xls.rb
lib/langchain/processors/xls.rb
# frozen_string_literal: true module Langchain module Processors class Xls < Base EXTENSIONS = [".xls"].freeze CONTENT_TYPES = ["application/vnd.ms-excel"].freeze def initialize(*) depends_on "roo" depends_on "roo-xls" end # Parse the document and return the text ...
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/processors/eml.rb
lib/langchain/processors/eml.rb
# frozen_string_literal: true module Langchain module Processors class Eml < Base EXTENSIONS = [".eml"] CONTENT_TYPES = ["message/rfc822"] def initialize(*) depends_on "mail" end # Parse the document and return the cleaned text # @param [File] data # @return [S...
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/processors/html.rb
lib/langchain/processors/html.rb
# frozen_string_literal: true module Langchain module Processors class HTML < Base EXTENSIONS = [".html", ".htm"] CONTENT_TYPES = ["text/html"] # We only look for headings and paragraphs TEXT_CONTENT_TAGS = %w[h1 h2 h3 h4 h5 h6 p] def initialize(*) depends_on "nokogiri" ...
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/output_parsers/output_fixing_parser.rb
lib/langchain/output_parsers/output_fixing_parser.rb
# frozen_string_literal: true module Langchain::OutputParsers # = Output Fixing Parser # class OutputFixingParser < Base attr_reader :llm, :parser, :prompt # Initializes a new instance of the class. # # @param llm [Langchain::LLM] The LLM used in the fixing process # @param parser [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/output_parsers/output_parser_exception.rb
lib/langchain/output_parsers/output_parser_exception.rb
class Langchain::OutputParsers::OutputParserException < StandardError def initialize(message, text) @message = message @text = text end def to_s "#{@message}\nText: #{@text}" 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/output_parsers/structured_output_parser.rb
lib/langchain/output_parsers/structured_output_parser.rb
# frozen_string_literal: true require "json-schema" module Langchain::OutputParsers # = Structured Output Parser class StructuredOutputParser < Base attr_reader :schema # Initializes a new instance of the class. # # @param schema [JSON::Schema] The json schema def initialize(schema:) @s...
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/output_parsers/base.rb
lib/langchain/output_parsers/base.rb
# frozen_string_literal: true module Langchain::OutputParsers # Structured output parsers from the LLM. # # @abstract class Base # Parse the output of an LLM call. # # @param text - LLM output to parse. # # @return [Object] Parsed output. def parse(text:) raise NotImplementedError...
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/tool/news_retriever.rb
lib/langchain/tool/news_retriever.rb
# frozen_string_literal: true module Langchain::Tool # # A tool that retrieves latest news from various sources via https://newsapi.org/. # An API key needs to be obtained from https://newsapi.org/ to use this tool. # # Usage: # news_retriever = Langchain::Tool::NewsRetriever.new(api_key: ENV["NEWS_API_...
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/tool/weather.rb
lib/langchain/tool/weather.rb
# frozen_string_literal: true module Langchain::Tool # # A weather tool that gets current weather data # # Current weather data is free for 1000 calls per day (https://home.openweathermap.org/api_keys) # Forecast and historical data require registration with credit card, so not supported yet. # # 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/tool/vectorsearch.rb
lib/langchain/tool/vectorsearch.rb
# frozen_string_literal: true module Langchain::Tool # # A tool wraps vectorsearch classes # # Usage: # # Initialize the LLM that will be used to generate embeddings # ollama = Langchain::LLM::Ollama.new(url: ENV["OLLAMA_URL"] # chroma = Langchain::Vectorsearch::Chroma.new(url: ENV["CHROMA_URL"]...
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/tool/tavily.rb
lib/langchain/tool/tavily.rb
# frozen_string_literal: true module Langchain::Tool # # Tavily Search is a robust search API tailored specifically for LLM Agents. # It seamlessly integrates with diverse data sources to ensure a superior, relevant search experience. # # Usage: # tavily = Langchain::Tool::Tavily.new(api_key: ENV["TAVIL...
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/tool/ruby_code_interpreter.rb
lib/langchain/tool/ruby_code_interpreter.rb
# frozen_string_literal: true module Langchain::Tool # # A tool that execute Ruby code in a sandboxed environment. # # Gem requirements: # gem "safe_ruby", "~> 1.0.5" # # Usage: # interpreter = Langchain::Tool::RubyCodeInterpreter.new # class RubyCodeInterpreter extend Langchain::ToolDef...
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/tool/wikipedia.rb
lib/langchain/tool/wikipedia.rb
# frozen_string_literal: true module Langchain::Tool # # Tool that adds the capability to search using the Wikipedia API # # Gem requirements: # gem "wikipedia-client", "~> 1.17.0" # # Usage: # wikipedia = Langchain::Tool::Wikipedia.new # wikipedia.execute(input: "The Roman Empire") # ...
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/tool/file_system.rb
lib/langchain/tool/file_system.rb
# frozen_string_literal: true module Langchain::Tool # # A tool that wraps the Ruby file system classes. # # Usage: # file_system = Langchain::Tool::FileSystem.new # class FileSystem extend Langchain::ToolDefinition define_function :list_directory, description: "File System Tool: Lists out th...
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/tool/calculator.rb
lib/langchain/tool/calculator.rb
# frozen_string_literal: true module Langchain::Tool # # A calculator tool # # Gem requirements: # gem "eqn", "~> 1.6.5" # # Usage: # calculator = Langchain::Tool::Calculator.new # class Calculator extend Langchain::ToolDefinition include Langchain::DependencyHelper define_func...
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/tool/google_search.rb
lib/langchain/tool/google_search.rb
# frozen_string_literal: true module Langchain::Tool # # Wrapper around SerpApi's Google Search API # # Gem requirements: # gem "google_search_results", "~> 2.0.0" # # Usage: # search = Langchain::Tool::GoogleSearch.new(api_key: "YOUR_API_KEY") # search.execute(input: "What is the capital...
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/tool/database.rb
lib/langchain/tool/database.rb
# frozen_string_literal: true module Langchain::Tool # # Connects to a SQL database, executes SQL queries, and outputs DB schema for Agents to use # # Gem requirements: # gem "sequel", "~> 5.87.0" # # Usage: # database = Langchain::Tool::Database.new(connection_string: "postgres://user:password...
ruby
MIT
fca40568a1d5632d9efc8cf8779343bbbe03dc99
2026-01-04T15:59:30.394142Z
false