能力标签
🛠
AI工具

langroid Agent工作流

基于 Python · 开源 AI 工具,GitHub 社区精选
英文名:langroid
⭐ 4.0k Stars 🍴 374 Forks 💻 Python 📄 MIT 🏷 AI 8.2分
8.2AI 综合评分
多智能体LLM工作流函数调用Python框架AI编程
✦ AI Skill Hub 推荐

AI Skill Hub 强烈推荐:langroid Agent工作流 是一款优质的AI工具。已获得 4.0k 颗 GitHub Star,AI 综合评分 8.2 分,在同类工具中表现稳健。如果你正在寻找可靠的AI工具解决方案,这是一个值得深入了解的选择。

📚 深度解析
langroid Agent工作流 是一款基于 Python 的开源工具,在 GitHub 上收获 4k+ Star,是多智能体、LLM工作流、函数调用、Python框架领域中的优质开源项目。开源工具的最大优势在于代码完全透明,你可以审计每一行代码的安全性,也可以根据自身需求进行二次开发和定制。

**为什么要使用开源工具而非商业 SaaS?**
对于个人开发者和有隐私需求的用户,本地部署的开源工具意味着数据不离本机,不受第三方服务商的数据政策约束。同时,开源工具通常没有使用次数限制和月度费用,一次安装即可长期使用,对于高频使用场景的总拥有成本(TCO)远低于订阅制商业工具。

**安装与环境准备**
langroid Agent工作流 依赖 Python 运行环境。建议通过 pyenv(Python)或 nvm(Node.js)管理 Python 版本,避免全局环境污染。对于新手用户,推荐先创建虚拟环境(python -m venv venv && source venv/bin/activate),再安装依赖,这样即使出现问题也可以随时删除虚拟环境重新开始,不影响系统稳定性。

**社区与维护**
GitHub Issue 和 Discussion 是获取帮助的最快渠道。在提问前建议先检查 Closed Issues(已关闭的问题),大多数常见问题都已有解答。遇到 Bug 时,提供 pip list 的输出、完整错误堆栈和最小可复现示例,能显著提高开发者响应速度。AI Skill Hub 将持续追踪 langroid Agent工作流 的版本更新,及时通知重要功能变化。
📋 工具概览

langroid Agent工作流 是一款基于 Python 开发的开源工具,专注于 多智能体、LLM工作流、函数调用 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。

GitHub Stars
⭐ 4.0k
开发语言
Python
支持平台
Windows / macOS / Linux
维护状态
持续维护,定期更新
开源协议
MIT
AI 综合评分
8.2 分
工具类型
AI工具
Forks
374
📖 中文文档
以下内容由 AI Skill Hub 根据项目信息自动整理,如需查看完整原始文档请访问底部「原始来源」。

langroid Agent工作流 是一款基于 Python 开发的开源工具,专注于 多智能体、LLM工作流、函数调用 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。

📌 核心特色
  • 开源免费,支持本地部署,数据完全自主可控
  • 活跃的 GitHub 开源社区,持续迭代更新
  • 提供详细文档和使用示例,新手友好
  • 支持自定义配置,灵活适配不同使用环境
  • 可作为基础组件集成进现有技术栈或进行二次开发
🎯 主要使用场景
  • 本地部署运行,保护数据隐私,满足合规要求
  • 自定义集成到现有系统,扩展技术栈能力
  • 作为开源基础组件进行商业化二次开发
以下安装命令基于项目开发语言和类型自动生成,实际以官方 README 为准。
安装命令
# 方式一:pip 安装(推荐)
pip install langroid

# 方式二:虚拟环境安装(推荐生产环境)
python -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate
pip install langroid

# 方式三:从源码安装(获取最新功能)
git clone https://github.com/langroid/langroid
cd langroid
pip install -e .

# 验证安装
python -c "import langroid; print('安装成功')"
📋 安装步骤说明
  1. 访问 GitHub 仓库页面
  2. 按照 README 文档完成依赖安装
  3. 根据系统环境完成初始化配置
  4. 参考官方示例或文档开始使用
  5. 遇到问题可在 GitHub Issues 中查找解答
以下用法示例由 AI Skill Hub 整理,涵盖最常见的使用场景。
常用命令 / 代码示例
# 命令行使用
langroid --help

# 基本用法
langroid input_file -o output_file

# Python 代码中调用
import langroid

# 示例
result = langroid.process("input")
print(result)
以下配置示例基于典型使用场景生成,具体参数请参照官方文档调整。
配置示例
# langroid 配置文件示例(config.yml)
app:
  name: "langroid"
  debug: false
  log_level: "INFO"

# 运行时指定配置文件
langroid --config config.yml

# 或通过环境变量配置
export LANGROID_API_KEY="your-key"
export LANGROID_OUTPUT_DIR="./output"
📑 README 深度解析 真实文档 完整度 81/100 查看 GitHub 原文 →
以下内容由系统直接从 GitHub README 解析整理,保留代码块、表格与列表结构。

简介

Logo

PyPI - Version Downloads Pytest codecov Multi-Architecture DockerHub

Static Badge Open in Colab Discord Substack

</div>

Documentation · Examples Repo · Discord · Contributing

<br /> </h3>

Langroid is an intuitive, lightweight, extensible and principled Python framework to easily build LLM-powered applications, from CMU and UW-Madison researchers. You set up Agents, equip them with optional components (LLM, vector-store and tools/functions), assign them tasks, and have them collaboratively solve a problem by exchanging messages. This Multi-Agent paradigm is inspired by the Actor Framework (but you do not need to know anything about this!).

Langroid is a fresh take on LLM app-development, where considerable thought has gone into simplifying the developer experience; it does not use Langchain, or any other LLM framework, and works with practically any LLM.

🔥 ✨ A Claude Code plugin is available to accelerate Langroid development with built-in patterns and best practices.

🔥 Read the (WIP) overview of the langroid architecture, and a quick tour of Langroid.

🔥 MCP Support: Allow any LLM-Agent to leverage MCP Servers via Langroid's simple MCP tool adapter that converts the server's tools into Langroid's ToolMessage instances.

📢 Companies are using/adapting Langroid in production. Here is a quote:

>Nullify uses AI Agents for secure software development. > It finds, prioritizes and fixes vulnerabilities. We have internally adapted Langroid's multi-agent orchestration framework in production, after evaluating CrewAI, Autogen, LangChain, Langflow, etc. We found Langroid to be far superior to those frameworks in terms of ease of setup and flexibility. Langroid's Agent and Task abstractions are intuitive, well thought out, and provide a great developer experience. We wanted the quickest way to get something in production. With other frameworks it would have taken us weeks, but with Langroid we got to good results in minutes. Highly recommended! <br> -- Jacky Wong, Head of AI at Nullify.

🔥 See this Intro to Langroid blog post from the LanceDB team

🔥 Just published in ML for Healthcare (2024): a Langroid-based Multi-Agent RAG system for pharmacovigilance, see blog post

We welcome contributions: See the contributions document for ideas on what to contribute.

Are you building LLM Applications, or want help with Langroid for your company, or want to prioritize Langroid features for your company use-cases? Prasad Chalasani is available for consulting (advisory/development): pchalasani at gmail dot com.

Sponsorship is also accepted via GitHub Sponsors

Questions, Feedback, Ideas? Join us on Discord!

⚡ Highlights

(For a more up-to-date list see the Updates/Releases section above) - Agents as first-class citizens: The Agent class encapsulates LLM conversation state, and optionally a vector-store and tools. Agents are a core abstraction in Langroid; Agents act as message transformers, and by default provide 3 responder methods, one corresponding to each entity: LLM, Agent, User. - Tasks: A Task class wraps an Agent, and gives the agent instructions (or roles, or goals), manages iteration over an Agent's responder methods, and orchestrates multi-agent interactions via hierarchical, recursive task-delegation. The Task.run() method has the same type-signature as an Agent's responder's methods, and this is key to how a task of an agent can delegate to other sub-tasks: from the point of view of a Task, sub-tasks are simply additional responders, to be used in a round-robin fashion after the agent's own responders. - Modularity, Reusability, Loose coupling: The Agent and Task abstractions allow users to design Agents with specific skills, wrap them in Tasks, and combine tasks in a flexible way. - LLM Support: Langroid supports OpenAI LLMs as well as LLMs from hundreds of providers (local/open or remote/commercial) via proxy libraries and local model servers such as ollama, oobabooga, LiteLLM that in effect mimic the OpenAI API. See the supported LLMs. - Caching of LLM responses: Langroid supports Redis to cache LLM responses. - Vector-stores: Qdrant, Chroma, LanceDB, Pinecone, PostgresDB (PGVector), Weaviate are currently supported. Vector stores allow for Retrieval-Augmented-Generation (RAG). - Grounding and source-citation: Access to external documents via vector-stores allows for grounding and source-citation. - Observability, Logging, Lineage: Langroid generates detailed logs of multi-agent interactions and maintains provenance/lineage of messages, so that you can trace back the origin of a message. - Tools/Plugins/Function-calling: Langroid supports OpenAI's function calling, as well as an equivalent ToolMessage mechanism which works with any LLM, not just OpenAI's. Function calling and tools have the same developer-facing interface, implemented using Pydantic, which makes it very easy to define tools/functions and enable agents to use them. Benefits of using Pydantic are that you never have to write complex JSON specs for function calling, and when the LLM hallucinates malformed JSON, the Pydantic error message is sent back to the LLM so it can fix it.

---

⚙️ Installation and Setup

Install `langroid`

Langroid requires Python 3.11+. We recommend using a virtual environment. Use pip to install a bare-bones slim version of langroid (from PyPi) to your virtual environment:

pip install langroid
The core Langroid package lets you use OpenAI Embeddings models via their API. If you instead want to use the sentence-transformers embedding models from HuggingFace, install Langroid like this:
pip install "langroid[hf-embeddings]"
For many practical scenarios, you may need additional optional dependencies: - To use various document-parsers, install langroid with the doc-chat extra:
    pip install "langroid[doc-chat]"
    
- For "chat with databases", use the db extra:
    pip install "langroid[db]"
    
- You can specify multiple extras by separating them with commas, e.g.:
    pip install "langroid[doc-chat,db]"
    
- To simply install all optional dependencies, use the all extra (but note that this will result in longer load/startup times and a larger install size):
    pip install "langroid[all]"
    
<details> <summary><b>Optional Installs for using SQL Chat with a PostgreSQL DB </b></summary>

If you are using SQLChatAgent (e.g. the script examples/data-qa/sql-chat/sql_chat.py), with a postgres db, you will need to:

- Install PostgreSQL dev libraries for your platform, e.g. - sudo apt-get install libpq-dev on Ubuntu, - brew install postgresql on Mac, etc. - Install langroid with the postgres extra, e.g. pip install langroid[postgres] or poetry add "langroid[postgres]" or poetry install -E postgres, (or the corresponding uv versions, e.g. uv add "langroid[postgres]" or uv pip install langroid[postgres]). If this gives you an error, try pip install psycopg2-binary in your virtualenv. </details>

📝 If you get strange errors involving mysqlclient, try doing pip uninstall mysqlclient followed by pip install mysqlclient.

🐳 Docker Instructions

We provide a containerized version of the langroid-examples repository via this Docker Image. All you need to do is set up environment variables in the .env file. Please follow these steps to setup the container:

```bash

Use this command to run any of the scripts in the `examples` directory

python examples/<Path/To/Example.py> ```

🎉 Usage Examples

These are quick teasers to give a glimpse of what you can do with Langroid and how your code would look.

⚠️ The code snippets below are intended to give a flavor of the code and they are not complete runnable examples! For that we encourage you to consult the langroid-examples repository.

ℹ️ The various LLM prompts and instructions in Langroid have been tested to work well with GPT-4 (and to some extent GPT-4o). Switching to other LLMs (local/open and proprietary) is easy (see guides mentioned above), and may suffice for some applications, but in general you may see inferior results unless you adjust the prompts and/or the multi-agent setup.

📖 Also see the Getting Started Guide for a detailed tutorial.

Click to expand any of the code examples below. All of these can be run in a Colab notebook: Open in Colab

<details> <summary> <b> Direct interaction with LLM </b> </summary>

import langroid.language_models as lm

mdl = lm.OpenAIGPT(
    lm.OpenAIGPTConfig(
        chat_model=lm.OpenAIChatModel.GPT4o, # or, e.g.  "ollama/qwen2.5"
    ),
)

messages = [
  lm.LLMMessage(content="You are a helpful assistant",  role=lm.Role.SYSTEM), 
  lm.LLMMessage(content="What is the capital of Ontario?",  role=lm.Role.USER),
]

response = mdl.chat(messages, max_tokens=200)
print(response.message)
See the guides to use (local/open LLMs or remote/commercial LLMs). </details>

<details> <summary> <b> Interaction with non-OpenAI LLM (local or remote) </b> </summary> Local model: if model is served at http://localhost:8000:

```python cfg = lm.OpenAIGPTConfig( chat_model="local/localhost:8000", chat_context_length=4096 ) mdl = lm.OpenAIGPT(cfg)

🚀 Demo

Suppose you want to extract structured information about the key terms of a commercial lease document. You can easily do this with Langroid using a two-agent system, as we show in the langroid-examples repo. (See this script for a version with the same functionality using a local Mistral-7b model.) The demo showcases just a few of the many features of Langroid, such as: - Multi-agent collaboration: LeaseExtractor is in charge of the task, and its LLM (GPT4) generates questions to be answered by the DocAgent. - Retrieval augmented question-answering, with source-citation: DocAgent LLM (GPT4) uses retrieval from a vector-store to answer the LeaseExtractor's questions, cites the specific excerpt supporting the answer. - Function-calling (also known as tool/plugin): When it has all the information it needs, the LeaseExtractor LLM presents the information in a structured format using a Function-call.

Here is what it looks like in action (a pausable mp4 video is here).

Demo

Claude Code Plugin (Optional)

This plugin provides two skills:

- langroid:patterns - Your Claude Code agent can leverage this skill to produce Langroid multi-agent code using proper design patterns. - langroid:add-pattern - The agent can use this skill to record new patterns it learns, for future reference, either autonomously or when prompted by the user.

Step 1: Add the Langroid marketplace

From terminal:

claude plugin marketplace add langroid/langroid

Or within Claude Code:

/plugin marketplace add langroid/langroid

Step 2: Install the Langroid plugin

From terminal:

claude plugin install langroid@langroid

Or within Claude Code:

/plugin install langroid@langroid

Once installed, simply ask your Claude Code agent to implement Langroid patterns in natural language, e.g.,

set up a Langroid agent so it uses the EditTool, and wrap it in a task that ends as soon as the tool is generated

and it will automatically use the langroid:patterns skill to follow the right design pattern.

You can also ask Claude Code to record a new pattern when you discover one, e.g.,

record this as a new Langroid pattern for setting up MCP tools

Set up environment variables (API keys, etc)

To get started, all you need is an OpenAI API Key. If you don't have one, see this OpenAI Page. (Note that while this is the simplest way to get started, Langroid works with practically any LLM, not just those from OpenAI. See the guides to using Open/Local LLMs, and other non-OpenAI proprietary LLMs.)

In the root of the repo, copy the .env-template file to a new file .env:

cp .env-template .env
Then insert your OpenAI API Key. Your .env file should look like this (the organization is optional but may be required in some scenarios).
OPENAI_API_KEY=your-key-here-without-quotes
OPENAI_ORGANIZATION=optionally-your-organization-id
`

Alternatively, you can set this as an environment variable in your shell (you will need to do this every time you open a new shell):

export OPENAI_API_KEY=your-key-here-without-quotes

<details> <summary><b>Optional Setup Instructions (click to expand) </b></summary>

All of the following environment variable settings are optional, and some are only needed to use specific features (as noted below).

- Qdrant Vector Store API Key, URL. This is only required if you want to use Qdrant cloud. Alternatively Chroma or LanceDB are also currently supported. We use the local-storage version of Chroma, so there is no need for an API key. - Redis Password, host, port: This is optional, and only needed to cache LLM API responses using Redis Cloud. Redis offers a free 30MB Redis account which is more than sufficient to try out Langroid and even beyond. If you don't set up these, Langroid will use a pure-python Redis in-memory cache via the Fakeredis library. - Momento Serverless Caching of LLM API responses (as an alternative to Redis). To use Momento instead of Redis: - enter your Momento Token in the .env file, as the value of MOMENTO_AUTH_TOKEN (see example file below), - in the .env file set CACHE_TYPE=momento (instead of CACHE_TYPE=redis which is the default). - GitHub Personal Access Token (required for apps that need to analyze git repos; token-based API calls are less rate-limited). See this GitHub page. - Google Custom Search API Credentials: Only needed to enable an Agent to use the GoogleSearchTool. To use Google Search as an LLM Tool/Plugin/function-call, you'll need to set up a Google API key, then setup a Google Custom Search Engine (CSE) and get the CSE ID. (Documentation for these can be challenging, we suggest asking GPT4 for a step-by-step guide.) After obtaining these credentials, store them as values of GOOGLE_API_KEY and GOOGLE_CSE_ID in your .env file. Full documentation on using this (and other such "stateless" tools) is coming soon, but in the meantime take a peek at this chat example, which shows how you can easily equip an Agent with a GoogleSearchtool.

If you add all of these optional variables, your .env file should look like this:

OPENAI_API_KEY=your-key-here-without-quotes
GITHUB_ACCESS_TOKEN=your-personal-access-token-no-quotes
CACHE_TYPE=redis # or momento
REDIS_PASSWORD=your-redis-password-no-quotes
REDIS_HOST=your-redis-hostname-no-quotes
REDIS_PORT=your-redis-port-no-quotes
MOMENTO_AUTH_TOKEN=your-momento-token-no-quotes # instead of REDIS* variables
QDRANT_API_KEY=your-key
QDRANT_API_URL=https://your.url.here:6333 # note port number must be included
GOOGLE_API_KEY=your-key
GOOGLE_CSE_ID=your-cse-id
</details>

<details> <summary><b>Optional setup instructions for Microsoft Azure OpenAI(click to expand)</b></summary>

When using Azure OpenAI, additional environment variables are required in the .env file. This page Microsoft Azure OpenAI provides more information, and you can set each environment variable as follows:

- AZURE_OPENAI_API_KEY, from the value of API_KEY - AZURE_OPENAI_API_BASE from the value of ENDPOINT, typically looks like https://your.domain.azure.com. - For AZURE_OPENAI_API_VERSION, you can use the default value in .env-template, and latest version can be found here - AZURE_OPENAI_DEPLOYMENT_NAME is the name of the deployed model, which is defined by the user during the model setup - AZURE_OPENAI_MODEL_NAME Azure OpenAI allows specific model names when you select the model for your deployment. You need to put precisly the exact model name that was selected. For example, GPT-4 (should be gpt-4-32k or gpt-4). - AZURE_OPENAI_MODEL_VERSION is required if AZURE_OPENAI_MODEL_NAME = gpt=4, which will assist Langroid to determine the cost of the model </details>

---

get the .env file template from `langroid` repo

wget -O .env https://raw.githubusercontent.com/langroid/langroid/main/.env-template

Edit the .env file with your favorite editor (here nano), and remove any un-used settings. E.g. there are "dummy" values like "your-redis-port" etc -- if you are not using them, you MUST remove them.

nano .env

answer = agent.llm_response("What is the capital of Ontario?")

# ... OR instead, set up a task (which has a built-in loop) and run it task = lr.Task(agent, name="Bot") task.run() # ... a loop seeking response from LLM or User at each turn

</details>

<details>
<summary><b> Three communicating agents </b></summary>

A toy numbers game, where when given a number `n`:
- `repeater_task`'s LLM simply returns `n`,
- `even_task`'s LLM returns `n/2` if `n` is even, else says "DO-NOT-KNOW"
- `odd_task`'s LLM returns `3*n+1` if `n` is odd, else says "DO-NOT-KNOW"

Each of these `Task`s automatically configures a default `ChatAgent`.
python import langroid as lr from langroid.utils.constants import NO_ANSWER

repeater_task = lr.Task( name = "Repeater", system_message=""" Your job is to repeat whatever number you receive. """, llm_delegate=True, # LLM takes charge of task single_round=False, )

even_task = lr.Task( name = "EvenHandler", system_message=f""" You will be given a number. If it is even, divide by 2 and say the result, nothing else. If it is odd, say {NO_ANSWER} """, single_round=True, # task done after 1 step() with valid response )

odd_task = lr.Task( name = "OddHandler", system_message=f""" You will be given a number n. If it is odd, return (n*3+1), say nothing else. If it is even, say {NO_ANSWER} """, single_round=True, # task done after 1 step() with valid response )

Then add the `even_task` and `odd_task` as sub-tasks of `repeater_task`, 
and run the `repeater_task`, kicking it off with a number as input:
python repeater_task.add_sub_task([even_task, odd_task]) repeater_task.run("3")

</details>

<details>
<summary><b> Simple Tool/Function-calling example </b></summary>

Langroid leverages Pydantic to support OpenAI's
[Function-calling API](https://platform.openai.com/docs/guides/gpt/function-calling)
as well as its own native tools. The benefits are that you don't have to write
any JSON to specify the schema, and also if the LLM hallucinates a malformed
tool syntax, Langroid sends the Pydantic validation error (suitably sanitized) 
to the LLM so it can fix it!

Simple example: Say the agent has a secret list of numbers, 
and we want the LLM to find the smallest number in the list. 
We want to give the LLM a `probe` tool/function which takes a
single number `n` as argument. The tool handler method in the agent
returns how many numbers in its list are at most `n`.

First define the tool using Langroid's `ToolMessage` class:

python import langroid as lr

class ProbeTool(lr.agent.ToolMessage): request: str = "probe" # specifies which agent method handles this tool purpose: str = """ To find how many numbers in my list are less than or equal to the <number> you specify. """ # description used to instruct the LLM on when/how to use the tool number: int # required argument to the tool


Then define a `SpyGameAgent` as a subclass of `ChatAgent`, 
with a method `probe` that handles this tool:
python class SpyGameAgent(lr.ChatAgent): def init(self, config: lr.ChatAgentConfig): super().init(config) self.numbers = [3, 4, 8, 11, 15, 25, 40, 80, 90]

def probe(self, msg: ProbeTool) -> str: # return how many numbers in self.numbers are less or equal to msg.number return str(len([n for n in self.numbers if n <= msg.number]))


We then instantiate the agent and enable it to use and respond to the tool:
python spy_game_agent = SpyGameAgent( lr.ChatAgentConfig( name="Spy", vecdb=None, use_tools=False, # don't use Langroid native tool use_functions_api=True, # use OpenAI function-call API ) ) spy_game_agent.enable_message(ProbeTool)

For a full working example see the
[chat-agent-tool.py](https://github.com/langroid/langroid-examples/blob/main/examples/quick-start/chat-agent-tool.py)
script in the `langroid-examples` repo.
</details>

<details>
<summary> <b>Tool/Function-calling to extract structured information from text </b> </summary>

Suppose you want an agent to extract 
the key terms of a lease, from a lease document, as a nested JSON structure.
First define the desired structure via Pydantic models:
python from pydantic import BaseModel class LeasePeriod(BaseModel): start_date: str end_date: str

class LeaseFinancials(BaseModel): monthly_rent: str deposit: str

class Lease(BaseModel): period: LeasePeriod financials: LeaseFinancials address: str


Then define the `LeaseMessage` tool as a subclass of Langroid's `ToolMessage`.
Note the tool has a required argument `terms` of type `Lease`:
python import langroid as lr

class LeaseMessage(lr.agent.ToolMessage): request: str = "lease_info" purpose: str = """ Collect information about a Commercial Lease. """ terms: Lease


Then define a `LeaseExtractorAgent` with a method `lease_info` that handles this tool,
instantiate the agent, and enable it to use and respond to this tool:
python class LeaseExtractorAgent(lr.ChatAgent): def lease_info(self, message: LeaseMessage) -> str: print( f""" DONE! Successfully extracted Lease Info: {message.terms} """ ) return json.dumps(message.terms.dict()) lease_extractor_agent = LeaseExtractorAgent() lease_extractor_agent.enable_message(LeaseMessage)

See the [`chat_multi_extract.py`](https://github.com/langroid/langroid-examples/blob/main/examples/docqa/chat_multi_extract.py)
script in the `langroid-examples` repo for a full working example.
</details>

<details>
<summary><b> Chat with documents (file paths, URLs, etc) </b></summary>

Langroid provides a specialized agent class `DocChatAgent` for this purpose.
It incorporates document sharding, embedding, storage in a vector-DB, 
and retrieval-augmented query-answer generation.
Using this class to chat with a collection of documents is easy.
First create a `DocChatAgentConfig` instance, with a 
`doc_paths` field that specifies the documents to chat with.
python import langroid as lr from langroid.agent.special import DocChatAgentConfig, DocChatAgent

config = DocChatAgentConfig( doc_paths = [ "https://en.wikipedia.org/wiki/Language_model", "https://en.wikipedia.org/wiki/N-gram_language_model", "/path/to/my/notes-on-language-models.txt", ], vecdb=lr.vector_store.QdrantDBConfig(), )


Then instantiate the `DocChatAgent` (this ingests the docs into the vector-store):
python agent = DocChatAgent(config)
Then we can either ask the agent one-off questions,
python agent.llm_response("What is a language model?")
or wrap it in a `Task` and run an interactive loop with the user:
python task = lr.Task(agent) task.run()

See full working scripts in the 
[`docqa`](https://github.com/langroid/langroid-examples/tree/main/examples/docqa)
folder of the `langroid-examples` repo.
</details>

<details>
<summary><b> 🔥 Chat with tabular data (file paths, URLs, dataframes) </b></summary>

Using Langroid you can set up a `TableChatAgent` with a dataset (file path, URL or dataframe),
and query it. The Agent's LLM generates Pandas code to answer the query, 
via function-calling (or tool/plugin), and the Agent's function-handling method
executes the code and returns the answer.

Here is how you can do this:
python import langroid as lr from langroid.agent.special import TableChatAgent, TableChatAgentConfig

Set up a `TableChatAgent` for a data file, URL or dataframe
(Ensure the data table has a header row; the delimiter/separator is auto-detected):
python dataset = "https://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-red.csv"

2-Agent chat loop: Teacher Agent asks questions to Student Agent

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() ```

🎯 aiskill88 AI 点评 A 级 2026-05-21

Langroid是专业的多智能体编程框架,设计理念清晰,社区活跃。相比通用链式框架更适合复杂智能体协作场景,代码质量和文档完整度较高。

📚 实用指南(长尾问题)
适合谁
  • 需要让 Claude / Cursor 操作本地工具的 AI 工程师
  • 构建多智能体协作系统的 Agent 开发者
  • 构建企业知识库 / RAG 检索应用的团队
  • 跨境业务、多语言内容运营团队
最佳实践
  • 配置 MCP 服务器时建议使用 stdio 传输 + JSON-RPC,避免暴露公网
  • 生产部署优先使用 Docker Compose 隔离依赖,并挂载 volume 持久化数据
  • 本地部署优先选 GGUF 量化模型,节省显存并保持响应速度
  • 分块大小建议 256-512 tokens,向量库优选 pgvector 或 Qdrant
  • Agent 任务先做 dry-run 验证工具调用链,再开启自主执行
常见错误
  • API key 直接提交到 git 仓库(请用 .env 并加入 .gitignore)
  • MCP 配置路径拼错或权限不足,重启 Claude Desktop 才生效
  • 容器内无法访问宿主机 localhost — 使用 host.docker.internal
  • embedding 模型与查询模型不一致导致检索失效
  • 显存不足直接 OOM — 优先降低 context 或换更小的量化模型
  • Python 依赖冲突:建议用 venv / uv 隔离环境
部署方案
  • Docker:langroid 提供官方镜像,docker compose up 一键启动
  • CLI:直接 npm install -g / pip install,命令行调用
  • 本地部署:CPU 8GB 起,GPU 推荐 16GB+ 显存
  • 云端托管:可放在 Vercel / Railway / Fly.io 等 PaaS 平台
相关搜索
langroid 中文教程langroid 安装报错怎么办langroid MCP 配置langroid Docker 部署langroid Agent 工作流langroid 与同类工具对比langroid 最佳实践langroid 适合谁用
⚡ 核心功能
👥 适合谁
  • 需要让 Claude / Cursor 操作本地工具的 AI 工程师
  • 构建多智能体协作系统的 Agent 开发者
  • 构建企业知识库 / RAG 检索应用的团队
  • 跨境业务、多语言内容运营团队
⭐ 最佳实践
  • 配置 MCP 服务器时建议使用 stdio 传输 + JSON-RPC,避免暴露公网
  • 生产部署优先使用 Docker Compose 隔离依赖,并挂载 volume 持久化数据
  • 本地部署优先选 GGUF 量化模型,节省显存并保持响应速度
  • 分块大小建议 256-512 tokens,向量库优选 pgvector 或 Qdrant
⚠️ 常见错误
  • API key 直接提交到 git 仓库(请用 .env 并加入 .gitignore)
  • MCP 配置路径拼错或权限不足,重启 Claude Desktop 才生效
  • 容器内无法访问宿主机 localhost — 使用 host.docker.internal
  • embedding 模型与查询模型不一致导致检索失效
👥 适合人群
AI 技术爱好者研究人员和学生开发者和工程师技术创业者
🎯 使用场景
  • 本地部署运行,保护数据隐私,满足合规要求
  • 自定义集成到现有系统,扩展技术栈能力
  • 作为开源基础组件进行商业化二次开发
⚖️ 优点与不足
✅ 优点
  • +MIT 协议,可免费商用
  • +完全开源免费,无授权费用
  • +本地部署,数据完全自主可控
  • +开发者社区支持,遇问题可查可问
⚠️ 不足
  • 安装和初始配置可能需要一定技术基础
  • 功能完整性通常不如成熟商业产品
  • 技术支持主要依赖开源社区,响应速度不稳定
⚠️ 使用须知

AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。

建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。

📄 License 说明

✅ MIT 协议 — 最宽松的开源协议之一,可自由商用、修改、分发,仅需保留版权声明。

🔗 相关工具推荐
📰 相关 AI 新闻
🍿 AI 圈相关吃瓜
🗺️ 相关解决方案
🧩 你可能还需要
基于当前 Skill 的能力图谱,自动补全的工具组合
❓ 常见问题 FAQ
Langroid专注多智能体编程和工作流,内置Agent模式;LangChain更多是链式调用工具集合。
💡 AI Skill Hub 点评

总体来看,langroid Agent工作流 是一款质量优秀的AI工具,在同类工具中具备一定竞争力。AI Skill Hub 将持续追踪其更新动态,建议收藏备用,结合自身场景选择合适时机引入使用。

📚 深入学习 langroid Agent工作流
查看分步骤安装教程和完整使用指南,快速上手这款工具
🌐 原始信息
原始名称 langroid
原始描述 开源AI工作流:Harness LLMs with Multi-Agent Programming。⭐4.0k · Python
Topics 多智能体LLM工作流函数调用Python框架AI编程
GitHub https://github.com/langroid/langroid
License MIT
语言 Python
🔗 原始来源
🐙 GitHub 仓库  https://github.com/langroid/langroid 🌐 官方网站  https://langroid.github.io/langroid/

收录时间:2026-05-14 · 更新时间:2026-05-16 · License:MIT · AI Skill Hub 不对第三方内容的准确性作法律背书。