# AI use cases for Langroid (langroid/langroid)

Repo: [langroid/langroid](https://github.com/langroid/langroid) | Use cases: 3 | Page: https://dedupedai.com/use-cases/langroid-langroid/

Langroid is a Python framework for building LLM powered agents and multi agent systems. Agents wrap an LLM, tools and optional vector stores, and Tasks run them in loops with users or other agents, with extras for document chat and databases.

This file holds every use case of this repo. Each one starts with a "## " heading and ends with its URL.

- Build a two agent teacher and student loop: https://dedupedai.com/use-cases/langroid-langroid/build-a-two-agent-chat-loop-with-langroid/
- Chat with your documents using DocChatAgent: https://dedupedai.com/use-cases/langroid-langroid/chat-with-your-documents-using-langroid-docchatagent/
- Run the Langroid examples in Docker: https://dedupedai.com/use-cases/langroid-langroid/run-langroid-examples-in-docker/

## How to build a two agent teacher and student loop with Langroid

Repo: [langroid/langroid](https://github.com/langroid/langroid) | Difficulty: Intermediate | Time: 30 minutes | Basis: From the README

Use ChatAgent and Task to make one agent ask questions and another answer, as in the README glimpse.

**Who it is for:** A developer learning multi agent patterns.

**The problem:** Multi agent code often becomes tangled message passing.

**The outcome:** Two agents talking in a loop, with you able to watch or join.

### Steps

1. Install with `pip install langroid`
2. Configure the LLM with lm.OpenAIGPTConfig, as in the README
3. Create a teacher ChatAgent and a student ChatAgent
4. Wrap each in a Task and add the student task as a sub task of the teacher
5. Run the teacher task

### Prompt to paste into your agent

```text
Using langroid/langroid, install `pip install langroid` and write a script based on the README's 2 agent chat loop where a teacher agent quizzes a student agent about <my topic>.
```

### Caveat

Loops between agents can run many LLM turns; set limits on the task.

Risk, cost: Each agent turn is an LLM call on your account.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/langroid-langroid/build-a-two-agent-chat-loop-with-langroid/

## How to chat with your documents using DocChatAgent with Langroid

Repo: [langroid/langroid](https://github.com/langroid/langroid) | Difficulty: Intermediate | Time: 45 minutes | Basis: From the README

Install the doc-chat extra and use DocChatAgent to answer questions over your files.

**Who it is for:** Analysts with a folder of PDFs or docs they query often.

**The problem:** Searching long documents by hand is slow and misses context.

**The outcome:** Answers drawn from your documents, retrieved with ranked chunks.

### Steps

1. Install with `pip install "langroid[doc-chat]"`
2. Set your LLM keys in a .env file
3. Create a DocChatAgent pointed at your documents
4. Ask questions in a Task loop

### Prompt to paste into your agent

```text
Using langroid/langroid, install `pip install "langroid[doc-chat]"`, build a DocChatAgent over <my documents folder>, and answer <my three questions> with the source passages.
```

### Caveat

Answer quality depends on chunking and the model; check answers against the source.

Risk, privacy: Document chunks are sent to the LLM you configure.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/langroid-langroid/chat-with-your-documents-using-langroid-docchatagent/

## How to run the Langroid examples in Docker with Langroid

Repo: [langroid/langroid](https://github.com/langroid/langroid) | Difficulty: Beginner | Time: 20 minutes | Basis: From the README

Pull the Langroid container with your .env file and run any script from the examples repo.

**Who it is for:** Someone who wants to try Langroid without a local Python setup.

**The problem:** Installing dependencies for every example takes time.

**The outcome:** A container where the Langroid example scripts run with your keys.

### Steps

1. Get the env template with `wget -O .env https://raw.githubusercontent.com/langroid/langroid/main/.env-template`
2. Edit it with `nano .env` and remove unused settings
3. Launch with `docker run -it --rm  -v ./.env:/langroid/.env langroid/langroid:latest`
4. Run an example script from the examples folder inside the container

### Prompt to paste into your agent

```text
Using langroid/langroid, create the .env from the template, run `docker run -it --rm  -v ./.env:/langroid/.env langroid/langroid:latest`, and run one document chat example.
```

### Caveat

Remove unused dummy values from .env or the container will fail.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/langroid-langroid/run-langroid-examples-in-docker/
