patterns-ai-core/langchainrb

Build LLM-powered applications in Ruby

What it solves

Langchain.rb provides a unified framework for Ruby developers to build LLM-powered applications. It abstracts away the differences between various AI providers, allowing developers to switch between models or vector databases without rewriting their core application logic.

How it works

The project acts as a middleware layer that provides a consistent interface for LLM operations like chat completions, prompt management, and embedding generation. It includes modules for building Retrieval Augmented Generation (RAG) pipelines—connecting document loading and parsing to vector search databases—and an Assistant class that manages conversation threads, tool execution, and system instructions.

Who it’s for

This is designed for Ruby and Ruby on Rails developers who want to integrate AI capabilities into their existing applications without needing to switch to Python-based ecosystems.

Highlights

  • Unified LLM Interface: Supports major providers including OpenAI, Anthropic, Google Gemini, Mistral AI, and local models via Ollama.
  • Extensive RAG Support: Built-in integration for numerous vector databases like Pinecone, Weaviate, Chroma, and Pgvector.
  • Structured Output: Includes parsers to force LLMs to return data in specific JSON schemas, with automatic error-fixing capabilities.
  • Prompt Management: Tools for creating, saving, and loading prompt templates, including support for few-shot prompting.
  • Assistant Framework: High-level abstractions for managing multi-turn conversations and automated tool calling.

Related

  • Project
  • Project
  • Project
  • Project
  • Project