lagent  by InternLM

Framework for building LLM-based agents

created 1 year ago
2,173 stars

Top 21.2% on sourcepulse

GitHubView on GitHub
Project Summary

Lagent is a lightweight, PyTorch-inspired framework for building LLM-based agents, targeting developers and researchers who need to create complex multi-agent systems. It simplifies agent development by treating LLMs and their interactions as analogous to neural network layers, enabling intuitive message passing and state management.

How It Works

Lagent's core design emphasizes modularity and ease of use. Agents communicate via AgentMessage objects, which are stored in memory and passed through a pipeline including optional hooks, aggregators, and LLM calls. The framework supports custom aggregators for flexible message formatting and output parsing via ToolParser, enabling agents to interact with tools or execute code. This approach allows for clear separation of concerns and facilitates the creation of sophisticated agent behaviors, such as self-refinement or tool-assisted reasoning.

Quick Start & Requirements

  • Install from source: git clone https://github.com/InternLM/lagent.git && cd lagent && pip install -e .
  • Prerequisites: Python, vllm (for VllmModel), openai (for GPTAPI), bing-search (for WebBrowser). GPU and CUDA are recommended for LLM inference.
  • Documentation: https://lagent.readthedocs.io/en/latest/

Highlighted Details

  • Dual Interfaces: Provides both synchronous and asynchronous variants for LLMs, actions, and agents, optimizing for debugging and large-scale inference.
  • Tool Integration: Supports flexible tool calling and execution via ActionExecutor and custom ToolParser for code interpretation and web browsing.
  • Multi-Agent Workflows: Facilitates complex multi-agent interactions, including research, data collection, and visualization pipelines.
  • Memory Management: Automatically handles message history and provides methods to inspect or reset agent memory.

Maintenance & Community

The project is actively developed by the Lagent Developer Team. Community engagement channels are available via X (Twitter) and Discord.

Licensing & Compatibility

  • License: Apache 2.0.
  • Compatibility: Permissive license allows for commercial use and integration into closed-source projects.

Limitations & Caveats

The framework relies on external LLM providers and tools, whose availability and API changes could impact functionality. Some examples require specific API keys (e.g., OpenAI, Bing Search) which are not included.

Health Check
Last commit

1 month ago

Responsiveness

1 week

Pull Requests (30d)
0
Issues (30d)
0
Star History
69 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.