1 पॉइंट द्वारा GN⁺ 4 시간 전 | 1 टिप्पणियां | WhatsApp पर शेयर करें
  • 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
  • कई 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 कराए जा सकते हैं
    • उदाहरण Weather tool latitude और longitude लेकर Open-Meteo API से current weather data लाता है
  • RubyLLM::Agent से instructions और tools सहित reusable agents define किए जा सकते हैं
    • उदाहरण WeatherAssistant gpt-5-nano model, concise response instruction, और Weather tool का उपयोग करता है
  • RubyLLM::Schema से structured output schema define किया जा सकता है
    • उदाहरण ProductSchema name, price, features fields 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 करना
  • 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:install
    • bin/rails db:migrate
    • bin/rails ruby_llm:load_models # v1.13+
  • वैकल्पिक रूप से chat UI भी जोड़ा जा सकता है
    • bin/rails generate ruby_llm:chat_ui
  • Rails model में acts_as_chat declare करने पर ActiveRecord-based chat का उपयोग किया जा सकता है
    • उदाहरण model Chat < ApplicationRecord में acts_as_chat declare करता है
    • Chat.create! model: "claude-sonnet-4" से chat बनाकर files पास कर सवाल पूछे जा सकते हैं
  • तैयार chat interface http://localhost:3000/chats पर खोला जा सकता है

1 टिप्पणियां

 
GN⁺ 4 시간 전
Hacker News की राय
  • RubyLLM उम्मीद से बेहतर निकला, और usability के मामले में Vercel के AI framework के काफ़ी करीब है
    यह तुरंत काम करने वाली सुविधा और flexibility के बीच संतुलन बनाने की कोशिश करता है, और यह जितना फ़ायदेमंद है उतना ही मुश्किल भी, लेकिन कुल मिलाकर अनुभव अच्छा रहा
    असल में सबसे बड़ी दिक्कत यह रही कि cache हमेशा काम नहीं करता। उदाहरण के लिए xAI सिर्फ completions API सपोर्ट करता है और thought signature गलत लौटाता है, जिससे समस्या होती है

  • 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 रूप से आ गया है तो मैं इसे ज़रूर देखूँगा

    • RubyLLM 1.x में Responses API implement न होने की वजह यह थी कि अंदरूनी डिज़ाइन में लगभग यह मान लिया गया था कि provider और protocol का 1:1 संबंध होता है
      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 को सही-सही देखना उतना अच्छा नहीं होता

  • मैं कुछ ऐसा बना रहा हूँ जो सिर्फ Claude के लिए है, और Anthropic ecosystem से बाहर जाने की कोई योजना नहीं है। ऐसे मामले में भी क्या RubyLLM का कोई फ़ायदा है, सीधे Anthropic की Ruby SDK इस्तेमाल करने की तुलना में, यह जानना चाहता हूँ
    दूसरे शब्दों में, क्या यह चुनाव Fog और aws-sdk-s3 के बीच वाले चुनाव जैसा है, या फिर Active Storage और 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 कराना भी बहुत मददगार रहा
    • बाद में किसी भी provider को चुन सकने वाला tool मौजूद हो तो उसे जानबूझकर एक ही provider पर dependent बनाकर क्यों बनाना चाहिए
      सिर्फ 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 मिलनी चाहिए

    • Ruby की बात करते समय Hacker News का MINASWAN जैसा माहौल होना अच्छा लगता है
  • Laravel में भी ऐसी ही एक library है
    https://laravel.com/docs/13.x/ai-sdk

  • मैं RubyLLM को production में भी इस्तेमाल कर रहा हूँ, और अब तक इस क्षेत्र में जो libraries देखी हैं उनमें यह सबसे elegant library है
    issue tracker चलाने का तरीका भी अच्छा लगा। “Feature Request” चुनने पर यह समझाना पड़ता है कि आपने workaround कैसे ढूँढ़ने की कोशिश की, और क्यों आपको लगता है कि यह RubyLLM में होना चाहिए, जिससे scope बेवजह अंतहीन बढ़ने से बचता है