█

AI/TLDR

मुझे पिलाएं कॉफ़ी
मुझे एक कॉफ़ी पिलाएँ

Langroid

Python में Multi-agent LLM प्रोग्रामिंग, अंदर से LangChain के बिना

Multi-Agent Systemsओपन सोर्स
भाषा
Python
लाइसेंस
MIT
$pip install langroid
संक्षेप में

Langroid क्या है?

Langroid Python में Multi-agent LLM प्रोग्रामिंग, अंदर से LangChain के बिना. यह Agents & Automation टूल्स की Multi-Agent Systems श्रेणी में आता है; ओपन सोर्स है, Python में लिखा गया है और MIT लाइसेंस के तहत है। शुरू करने के लिए: langroid install करें.

सारांश

Langroid सहयोग करने वाले agents से LLM-आधारित applications बनाने के लिए एक हल्का Python फ्रेमवर्क है। आप Agents सेट अप करते हैं, हर एक को वैकल्पिक components से लैस करते हैं — एक LLM, एक vector store, tools और functions — उन्हें tasks सौंपते हैं, और messages का आदान-प्रदान करके उन्हें समस्या हल करने देते हैं। प्रोजेक्ट इस multi-agent paradigm को Actor model से प्रेरित बताता है, हालाँकि इसे इस्तेमाल करने के लिए उसके बारे में कुछ जानने की ज़रूरत नहीं है।

इसका मूल डिज़ाइन निर्णय यह है कि यह क्या छोड़ता है: Langroid के नीचे LangChain या कोई और LLM framework नहीं है, और यह OpenAI-compatible API के पीछे लगभग किसी भी LLM के साथ काम करता है, जिसमें Ollama के ज़रिए चलाए जाने वाले local models भी शामिल हैं। दो मुख्य abstractions छोटे हैं — `ChatAgent` किसी agent की configuration और conversation state रखता है, और `Task` किसी agent को एक loop में लपेटता है जो user से या `add_sub_task` के ज़रिए दूसरे agents के tasks से बात कर सकता है।

यह framework CMU और UW-Madison के researchers से आया है, और इसमें सादी chat से आगे कुछ specialised agents आते हैं: retrieval-augmented question answering के लिए `DocChatAgent`, natural language में databases और dataframes से query करने के लिए `SQLChatAgent` और `TableChatAgent`, knowledge graphs के लिए `Neo4jChatAgent`, और structured information extraction। यह MCP servers के tools को Langroid `ToolMessage` instances में भी बदलता है, ताकि कोई agent उन्हें किसी भी दूसरे tool की तरह call कर सके।

यह क्या करता है

  • Agent + Task abstractions: किसी agent को task में लपेटें, फिर `add_sub_task` से tasks को multi-agent loops में जोड़ें
  • किसी LangChain या दूसरे framework पर निर्भरता नहीं — OpenAI-compatible API के ज़रिए लगभग किसी भी LLM के साथ काम करता है, local हो या hosted
  • Specialised agents शामिल: DocChatAgent (RAG), SQLChatAgent, TableChatAgent, Neo4jChatAgent और structured information extraction
  • किसी भी agent के लिए MCP server के tools को Langroid ToolMessage instances में बदलने वाला MCP tool adapter
  • हर agent के लिए conversation state अलग रखी जाती है, इसलिए follow-up turns में manual history जोड़े बिना context बना रहता है
  • Document chat, vector stores और databases के लिए वैकल्पिक extras, जो केवल ज़रूरत पड़ने पर install होते हैं

शुरू करें

Langroid PyPI से एक छोटे core के रूप में install होता है, साथ में वैकल्पिक extras। जिस provider की ओर आप इशारा करें उसकी API key सेट करें, फिर एक सादे LLM call से लेकर दो-agent वाले loop तक बढ़ें।

Langroid install करें

Core package install करें, फिर सिर्फ़ उन हिस्सों के लिए extras जोड़ें जिन्हें आप इस्तेमाल करते हैं — document chat, databases, या local Hugging Face embeddings।

bashbash
pip install langroid

# optional extras
pip install "langroid[doc-chat]"
pip install "langroid[db]"
pip install "langroid[hf-embeddings]"
pip install "langroid[all]"

Model configure करें और उसे सीधे call करें

`OpenAIGPTConfig` किसी भी ऐसे model की ओर इशारा करता है जो OpenAI-compatible API के पीछे चल रहा हो — hosted model, या `ollama/mistral` जैसा local model।

pythonpython
import langroid as lr
import langroid.language_models as lm

llm_cfg = lm.OpenAIGPTConfig(
    # any model served via an OpenAI-compatible API
    chat_model=lm.OpenAIChatModel.GPT4o,  # or, e.g., "ollama/mistral"
)
mdl = lm.OpenAIGPT(llm_cfg)
response = mdl.chat("What is the capital of Ontario?", max_tokens=10)

Model को Agent में, फिर Task में लपेटें

`ChatAgent` calls के बीच conversation state बनाए रखता है; उसे `Task` में लपेटने पर user या दूसरे agent के साथ interactive loop चलता है।

pythonpython
agent_cfg = lr.ChatAgentConfig(llm=llm_cfg)
agent = lr.ChatAgent(agent_cfg)
agent.llm_response("What is the capital of China?")
response = agent.llm_response("And India?")  # maintains conversation state

task = lr.Task(agent, name="Bot", system_message="You are a helpful assistant")
task.run("Hello")  # kick off with user saying "Hello"

दो agents को एक loop में जोड़ें

हर agent को अपना task और system message दें, फिर एक को sub-task के रूप में जोड़ें। यहाँ एक Teacher सवाल पूछता है और एक single-round Student उनका जवाब देता है।

pythonpython
teacher_agent = lr.ChatAgent(agent_cfg)
teacher_task = lr.Task(
    teacher_agent, name="Teacher",
    system_message="""
      Ask your student concise numbers questions, and give feedback.
      Start with a question.
      """
)
student_agent = lr.ChatAgent(agent_cfg)
student_task = lr.Task(
    student_agent, name="Student",
    system_message="Concisely answer the teacher's questions.",
    single_round=True,
)

teacher_task.add_sub_task(student_task)
teacher_task.run()

कमांड और कोड प्रोजेक्ट के अपने दस्तावेज़ों से लिए गए हैं — हमेशा जांचें आधिकारिक repo ताज़ा जानकारी के लिए।

कब इस्तेमाल करें

  • जब आपको explicit multi-agent structure चाहिए हो — जैसे एक reviewer agent writer agent की जाँच करे, या एक planner workers को काम सौंपे — तब इसे चुनें, न कि एक ही prompt से सब कुछ करवाने के बजाय
  • DocChatAgent के साथ document question answering बनाने के लिए इसे चुनें, न कि हाथ से retrieval pipeline जोड़ने के लिए
  • specialised chat agents के ज़रिए natural language को SQL database, dataframe या Neo4j graph के सामने रखने के लिए इसे चुनें
  • जब आप बड़े frameworks से दूर रहना चाहें और OpenAI-compatible endpoint के पीछे local model लगाने का विकल्प खुला रखना चाहें, तब इसे चुनें

How Langroid compares

Langroid alongside other open-source multi-agent systems tools AI/TLDR tracks, ranked by GitHub stars.

टूलस्टारयह क्या करता है
Paperclip★ 119kएक सेल्फ-होस्टेड कंट्रोल प्लेन, जो AI एजेंट्स की टीम को कंपनी की तरह चलाता है, जिसमें ऑर्गनाइज़ेशन चार्ट, टास्क, बजट और अप्रूवल शामिल हैं
Ruflo★ 82.8kClaude Code और Codex के लिए एक एजेंट मेटा-हार्नेस
MetaGPT★ 71.6kएक multi-agent framework जो एक ही prompt से पूरी LLM-आधारित software company का काम करता है
AutoGen★ 62kऐसे multi-agent AI apps बनाएं जिनमें agents एक-दूसरे, tools और इंसानों के साथ बातचीत करें
CrewAI★ 61.4kRole-playing AI agents की टीमें बनाएं जो काम बांटें और एक लक्ष्य के लिए मिलकर काम करें
AgentScope★ 37.1kप्रोडक्शन में चलने वाले मल्टी-एजेंट ऐप्स बनाने के लिए एक Python फ़्रेमवर्क
OpenAI Agents SDK★ 31kMulti-agent workflows बनाने के लिए tools, handoffs और guardrails वाला हल्का Python SDK
Langroid★ 4.2kPython में Multi-agent LLM प्रोग्रामिंग, अंदर से LangChain के बिना