- RubyLLM Ruby apps में chatbot, AI agent, RAG, content generation जैसे AI workflow को एक ही framework में बनाने देता है
- GPT, Claude, लोकल Ollama आदि को एक ही interface से संभालता है, और dependencies को Faraday, Zeitwerk, Marcel इन 3 तक सीमित रखता है
- सिर्फ chat ही नहीं, बल्कि image·video analysis, audio transcription, document processing, image generation, embeddings, moderation, tool calling, structured output, और streaming तक को कवर करता है
- Rails में
acts_as_chat, model loading, और optional chat UI generator देता है औरतुरंत इस्तेमाल किया जा सकने वाला चैट इंटरफ़ेस खोला जा सकता है - OpenAI, xAI, Anthropic, Gemini, VertexAI, Bedrock, DeepSeek, Mistral, Ollama, OpenRouter, Perplexity, GPUStack, OpenAI-compatible API को support करता है
Ruby के लिए एक सिंगल AI framework
- RubyLLM प्रमुख AI providers को एक Ruby framework में संभालने के लिए एक tool है
- यह chatbot, AI agent, RAG applications, content generators, और अन्य AI workflows बनाने के लिए है
- Chat with Work में इसका वास्तविक उपयोग हो रहा है
provider-specific API differences को छिपाने वाला interface
- इसका फोकस AI providers के client, API, response format, और conventions में अंतर से पैदा होने वाली समस्याओं को कम करना है
- एक ही interface से GPT, Claude, और लोकल Ollama का उपयोग किया जा सकता है
- यह सिर्फ Faraday, Zeitwerk, और Marcel इन 3 dependencies का उपयोग करता है
बुनियादी उपयोग का तरीका
- साधारण सवालों के लिए
RubyLLM.chatसे chat object बनाया जाता है औरchat.askसे चलाया जाता है- उदाहरण:
chat.ask "What's the best way to learn Ruby?"
- उदाहरण:
- file analysis के लिए
with:option में file पास की जाती है- image:
ruby_conf.jpg - video:
video.mp4 - audio:
meeting.wav - PDF:
contract.pdf - code:
app.rb
- image:
- कई files को array के रूप में पास करके एक साथ analyze किया जा सकता है
- उदाहरण:
with: ["diagram.png", "report.pdf", "notes.txt"]
- उदाहरण:
- streaming response में block पास करके
chunk.contentको process किया जाता है
AI features की range
RubyLLM.paintसे image generation किया जाता हैRubyLLM.embedसे text embeddings बनाए जाते हैंRubyLLM.transcribeसे audio को text में transcribe किया जाता हैRubyLLM.moderateसे content safety की जाँच की जाती हैRubyLLM::Toolको inherit करने वाली class के जरिए AI से Ruby methods call कराए जा सकते हैं- उदाहरण
Weathertool latitude और longitude लेकर Open-Meteo API से current weather data लाता है
- उदाहरण
RubyLLM::Agentसे instructions और tools सहित reusable agents define किए जा सकते हैं- उदाहरण
WeatherAssistantgpt-5-nanomodel, concise response instruction, औरWeathertool का उपयोग करता है
- उदाहरण
RubyLLM::Schemaसे structured output schema define किया जा सकता है- उदाहरण
ProductSchemaname,price,featuresfields define करता है
- उदाहरण
feature list और provider support
- मुख्य features इस प्रकार हैं
- Chat:
RubyLLM.chatआधारित conversational AI - Vision: image और video analysis
- Audio:
RubyLLM.transcribeआधारित speech transcription और understanding - Documents: PDF, CSV, JSON जैसे file types से extraction
- Image generation:
RubyLLM.paintआधारित image generation - Embeddings:
RubyLLM.embedआधारित embeddings generation - Moderation:
RubyLLM.moderateआधारित content safety checking - Tools: AI द्वारा Ruby methods call करना
- Agents:
RubyLLM::Agentआधारित reusable assistants - Structured output: JSON schema आधारित structured output
- Streaming: block-based real-time response
- Rails:
acts_as_chatआधारित ActiveRecord integration - Async: Fiber-based concurrency
- Model registry: feature detection और pricing information सहित 800 से अधिक models
- Extended thinking: model thinking process को control, view, और store करना
- Chat:
- supported providers हैं OpenAI, xAI, Anthropic, Gemini, VertexAI, Bedrock, DeepSeek, Mistral, Ollama, OpenRouter, Perplexity, GPUStack, और OpenAI-compatible API
installation और Rails integration
- installation के लिए Gemfile में
gem 'ruby_llm'जोड़ने के बादbundle installचलाएँ - API keys
config/initializers/ruby_llm.rbमें सेट की जाती हैं- उदाहरण:
config.openai_api_key = ENV['OPENAI_API_KEY']
- उदाहरण:
- Rails integration निम्न commands से install किया जाता है
bin/rails generate ruby_llm:installbin/rails db:migratebin/rails ruby_llm:load_models # v1.13+
- वैकल्पिक रूप से chat UI भी जोड़ा जा सकता है
bin/rails generate ruby_llm:chat_ui
- Rails model में
acts_as_chatdeclare करने पर ActiveRecord-based chat का उपयोग किया जा सकता है- उदाहरण model
Chat < ApplicationRecordमेंacts_as_chatdeclare करता है Chat.create! model: "claude-sonnet-4"से chat बनाकर files पास कर सवाल पूछे जा सकते हैं
- उदाहरण model
- तैयार chat interface
http://localhost:3000/chatsपर खोला जा सकता है
1 टिप्पणियां
Hacker News की राय
RubyLLM उम्मीद से बेहतर निकला, और usability के मामले में Vercel के AI framework के काफ़ी करीब है
यह तुरंत काम करने वाली सुविधा और flexibility के बीच संतुलन बनाने की कोशिश करता है, और यह जितना फ़ायदेमंद है उतना ही मुश्किल भी, लेकिन कुल मिलाकर अनुभव अच्छा रहा
असल में सबसे बड़ी दिक्कत यह रही कि cache हमेशा काम नहीं करता। उदाहरण के लिए xAI सिर्फ completions API सपोर्ट करता है और thought signature गलत लौटाता है, जिससे समस्या होती है
https://github.com/crmne/ruby_llm/blob/main/lib/ruby_llm/pro...
RubyLLM के abstraction के ऊपर बना एक open source gem Raix है, और इसका काफ़ी इस्तेमाल होता है
https://github.com/OlympiaAI/raix
मैं RubyLLM को production में इस्तेमाल कर रहा हूँ और मुझे यह बहुत पसंद है। यह शानदार और इस्तेमाल में आसान framework है
Responses API का default support न होना, जैसा दूसरे लोगों ने भी कहा, काफ़ी निराशाजनक था और यह एक बड़ी कमी जैसा लगा। किसी दूसरे developer ने बनाया हुआ connector है, लेकिन उसमें bugs हैं और उसकी quality main gem जितनी अच्छी नहीं है
आगे का development, खासकर 2.0, देखने का इंतज़ार है। अब अगर Responses API native रूप से आ गया है तो मैं इसे ज़रूर देखूँगा
OpenAI में अलग-अलग capabilities वाले 2 protocols हैं, और VertexAI के सभी models तक पहुँचने के लिए एक ही provider के नीचे कई protocols सपोर्ट करने पड़ते हैं, इसलिए यह मान्यता अब सही नहीं रही
इसलिए Protocols और Providers को अलग करना पड़ा, और एक ही Provider के भीतर भी model के आधार पर अलग Protocol पर transparently route करने के लिए बड़ा refactoring करना पड़ा। यह काम RubyLLM 2.0 में शामिल होगा
अगर दिलचस्पी हो तो ये commits देख सकते हैं: https://github.com/crmne/ruby_llm/commit/d398354da493570b050...
https://github.com/crmne/ruby_llm/commit/0875ce2dfeae9d28a3a...
RubyLLM इस्तेमाल करने में बहुत आसान है। पिछले साल एक project में इसका काफ़ी उपयोग किया था
कमी यह थी कि असली trace observability के लिए instrumentation करना मुश्किल था, और retries के समय internal models को हटाने का एक pattern है, जिससे दिखने वाला history साफ़-सुथरा लगता है लेकिन असली API call order को सही-सही देखना उतना अच्छा नहीं होता
https://rubyllm.com/instrumentation/
मैं कुछ ऐसा बना रहा हूँ जो सिर्फ Claude के लिए है, और Anthropic ecosystem से बाहर जाने की कोई योजना नहीं है। ऐसे मामले में भी क्या RubyLLM का कोई फ़ायदा है, सीधे Anthropic की Ruby SDK इस्तेमाल करने की तुलना में, यह जानना चाहता हूँ
दूसरे शब्दों में, क्या यह चुनाव Fog और aws-sdk-s3 के बीच वाले चुनाव जैसा है, या फिर Active Storage और aws-sdk-s3 के बीच वाले चुनाव जैसा
RubyLLM की अच्छी बातों में ActiveRecord जैसी method-chaining DSL, agents·tools·prompts को व्यवस्थित रखने की संरचना, और Anthropic से DeepSeek पर आसानी से test और migrate करके cost को 90% से ज़्यादा घटा पाने वाली portability शामिल है
bin/rails generate ruby_llm:installसे हर chat को database में store कर सकने वाला ActiveRecord integration भी बढ़िया है। stored chat history को समय-समय पर डाउनलोड करके claude code को देना और उससे agent instructions को refine कराना भी बहुत मददगार रहासिर्फ outage handling को ही देख लें, जिस दिन सेवा सबसे ज़्यादा चाहिए उसी दिन अगर Anthropic API डाउन हो जाए तो क्या करेंगे, यह सोचना चाहिए
मैं side project में RubyLLM इस्तेमाल कर रहा हूँ और यह शानदार है
यह दिलचस्प है कि पिछले साल के SF Ruby conf के सवालों और comments में जो बातें थीं, वे अब ecosystem features के रूप में रिलीज़ हो चुकी हैं: https://youtu.be/y535u1EWqAg?si=rbyv52T035apKwQk
कुछ महीने पहले मैंने RubyLLM को काफ़ी गहराई से इस्तेमाल किया था, और इसका design और implementation बहुत अच्छा लगा
मेरे पास कई Lisp भाषाओं में खुद बनाए हुए LLM clients हैं, और मैं RubyLLM के design के कुछ हिस्से अपनाने के बारे में सोचने लगा था। imitation भी एक तरह की तारीफ़ है
Ruby को AI community तक लाने और open source में यह काम करने के लिए धन्यवाद
अच्छी भाषाओं को और ज़्यादा explore और attention मिलनी चाहिए
Laravel में भी ऐसी ही एक library है
https://laravel.com/docs/13.x/ai-sdk
मैं RubyLLM को production में भी इस्तेमाल कर रहा हूँ, और अब तक इस क्षेत्र में जो libraries देखी हैं उनमें यह सबसे elegant library है
issue tracker चलाने का तरीका भी अच्छा लगा। “Feature Request” चुनने पर यह समझाना पड़ता है कि आपने workaround कैसे ढूँढ़ने की कोशिश की, और क्यों आपको लगता है कि यह RubyLLM में होना चाहिए, जिससे scope बेवजह अंतहीन बढ़ने से बचता है