langchainrb_rails  by patterns-ai-core

Rails gem for AI integration

Created 2 years ago
331 stars

Top 82.7% on SourcePulse

GitHubView on GitHub
Project Summary

This gem provides a Ruby on Rails integration for Langchain, enabling developers to quickly add AI-powered question-answering and similarity search capabilities to their applications. It targets Rails developers looking to leverage LLMs with their existing PostgreSQL, Pinecone, or Qdrant databases.

How It Works

The gem integrates with vector databases (Postgres with pgvector, Pinecone, Qdrant) to store and retrieve data embeddings. It generates embeddings for ActiveRecord models using specified LLMs and calculates cosine similarity to find relevant records for question-answering. A prompt is constructed with the question and context, then sent to the LLM for a natural language response.

Quick Start & Requirements

  • Install: bundle add langchainrb_rails
  • Requirements: Ruby 3.0+, Postgres 11+ (for pgvector integration).
  • Setup: Run rails generate langchainrb_rails:pgvector --model=<YourModel> --llm=<your_llm> followed by bundle install && rails db:migrate. Set OPENAI_API_KEY environment variable.
  • Docs: https://github.com/patterns-ai-core/langchainrb_rails

Highlighted Details

  • Supports multiple LLMs (OpenAI, Cohere, Hugging Face, Ollama, etc.) for embeddings and completions.
  • Offers generators for pgvector, Pinecone, and Qdrant, as well as prompt templating and assistant creation.
  • Allows customization of vector representation via an #as_vector method.
  • Enables similarity search directly on ActiveRecord relations.

Maintenance & Community

  • Developed by patterns-ai-core.
  • Community links are not explicitly provided in the README.

Licensing & Compatibility

  • License: Not specified in the README.
  • Compatibility: Designed for Ruby on Rails applications.

Limitations & Caveats

The README does not specify the license, which is crucial for commercial use. Initial setup for embedding large datasets can be time-consuming.

Health Check
Last Commit

8 months ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
0
Star History
5 stars in the last 30 days

Explore Similar Projects

Starred by Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems"), Nir Gazit Nir Gazit(Cofounder of Traceloop), and
4 more.

llmware by llmware-ai

0.6%
14k
Framework for enterprise RAG pipelines using small, specialized models
Created 2 years ago
Updated 1 month ago
Feedback? Help us improve.