This project implements a simple multi-agent system using LangGraph and LangChain with Groq's API. The system consists of two main nodes: a planner node that decomposes user input into individual, achievable tasks, and an executor node that processes these tasks into a formatted output.
The application creates a state graph where:
- The Planner Node acts as a software architect, using an LLM to break down user input into measurable steps
- The Executor Node generates detailed, actionable implementation guidance for each planned task using the LLM, producing a structured markdown implementation plan
- The workflow demonstrates multi-agent orchestration using LangGraph's state management, with enhanced logging, error handling, and state tracking
- Task decomposition using LLM-based planning with JSON parsing and fallback handling
- Detailed execution guidance generating actionable implementation steps for each task
- Stateful agent orchestration with comprehensive logging and error handling
- Integration with Groq's fast inference API and automatic primary/fallback model selection
- Simple and extensible architecture with modular prompts and state management
- LangGraph: Framework for building multi-agent workflows and state machines
- LangChain Groq: Integration for using Groq's models with LangChain
- python-dotenv: Environment variable management
- Python 3.x
- Groq API key
- Clone or download the project files
- Install dependencies:
pip install -r requirements.txt- Create a
.envfile in the project root and add your Groq API key:
GROQ_API_KEY=your_groq_api_key_here
Run the main script:
python multi_agent_langgraph.pyThe script processes a predefined sample input, generates a detailed implementation plan, and saves the final output to output.md.
To customize the input, modify the user_input variable in the if __name__ == "__main__": block.
With the default input "Help me with MVP for a new simple tool which creates documents with diagrams for given github repository", the system generates a structured markdown implementation plan and saves it to output.md. The output includes detailed, actionable steps for each planned task, formatted as follows:
# Implementation Plan
## Task 1: [Task Description]
1. [Detailed actionable step]
2. [Another step with code snippet if relevant]
3. ...
## Task 2: [Task Description]
...multi_agent_langgraph.py: Main application script containing the agent graph definition, state management, and execution logicrequirements.txt: Python dependencies.env: Environment configuration (not included in repository)output.md: Generated output file containing the implementation plan (created after running the script)
The application primarily uses the llama-3.1-8b-instant model via Groq's API, with automatic fallback to llama-3.1-70b-versatile if the primary model fails. Ensure your Groq API key has access to these models.
The executor node is implemented to generate detailed, actionable implementation steps for each planned task using the LLM. To customize the execution guidance, modify the EXECUTOR_PROMPT_TEMPLATE in the script.