langchainrb_rails  by patterns-ai-core

Rails gem for AI integration

created 2 years ago
324 stars

Top 85.2% 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

7 months ago

Responsiveness

1 day

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

Explore Similar Projects

Feedback? Help us improve.