An AI microservice that implements the Multi-Agent Collaboration pattern. This system orchestrates a crew of specialized AI agents, each with a distinct role and set of tools, to collaboratively solve complex problems, such as writing a comprehensive blog post from a single topic.
This project represents the synthesis of multiple agentic design patterns (Tool Use, Reflection) into a distributed system architecture.
Instead of a single, monolithic "do-it-all" agent, this architecture is built on the principle of specialization, creating a digital team:
- Specialized Agents: Each
Agentis configured with a persona (role, goal, backstory) and tools specific to its function (e.g., a Researcher with access to search tools). - Defined Tasks: Each
Taskdefines a clear objective to be executed by an agent with the corresponding role. - Orchestration (The
Crew): TheCrewclass acts as a project manager. It executes tasks in a defined sequence, passing the output of one agent as the context for the next, ensuring a cohesive and collaborative workflow.
This model transforms problem-solving from a monolithic task into a pipeline of specialists, mirroring how high-performance human teams operate.
This project demonstrates the ability to design and build complex, distributed AI systems.
- Microservice Architecture for AI: The system is designed with a clear separation of concerns (
Agent,Task,Crew), making it modular, testable, and easily extensible. - Inter-Agent Data Pipeline: The
Crewmanages a data pipeline where the output of one agent becomes the input for the next, enabling the incremental construction of a complex solution. - Synthesis of Patterns: The project combines multiple patterns: the Researcher acts as a
ToolAgent, while the Critic applies principles from theReflectionAgent. - Infrastructure as a Pattern: The entire engineering foundation (
FastAPI,Docker,Pytest,GitHub Actions) was reused, proving the effectiveness of our "agent factory" and allowing for a singular focus on the AI logic.
This project implements the key phases of an MLOps pipeline for custom model creation:
graph TD
subgraph "Início do Processo"
A["User Input: Blog Topic"] --> B("FastAPI Endpoint /generate");
end
subgraph "Crew Orchestration"
B --> C{"Orchestrator Agent (Crew)"};
C -- "Assigns Task" --> D["Agent: Research Manager"];
D -- "Uses Tool" --> E["Tool: Internet Search"];
E --> D;
D -- Output --> F["Agent: Content Creator"];
F -- Output --> G["Agent: SEO Expert"];
G -- Output --> H["Agent: Critic/Editor"];
H -- "Feedback/Refines" --> F;
H -- "Final Output" --> I["Final Blog Post"];
end
subgraph "Fim do Processo"
I --> B;
B --> J["User Output: JSON Response"];
end
- Git
- Python 3.9+
- Docker Desktop (running)
- An OpenAI API Key (required for LLM calls and tool usage)
- A Serper API Key (for internet search tool, required for the Researcher Agent)
- Clone the repository:
git clone [https://github.com/PRYSKAS/multi_agent_pattern_agent.git](https://github.com/PRYSKAS/multi_agent_pattern_agent.git) cd multi_agent_pattern_agent - Install dependencies:
pip install -r requirements.txt
- Configure environment variables:
- Create a
.envfile from the example:copy .env.example .env(on Windows) orcp .env.example .env(on Unix/macOS). - Add your
OPENAI_API_KEYandSERPER_API_KEYto the new.envfile. These are crucial for the agents to function.
- Create a
-
Run locally using Uvicorn (for development):
uvicorn serving.main:app --reload --port 8001
Access the API documentation and interact with the service at
http://127.0.0.1:8001/docs. -
Run using Docker (Recommended for stable execution):
- Build the Docker image:
docker build -t multi-agent-crew-service . - Run the container:
docker run -d -p 8001:8001 --env-file .env --name multi-agent-crew multi-agent-crew-service
Access the API at
http://127.0.0.1:8001/docs. - Build the Docker image:
Initiates the multi-agent crew to generate content based on a given topic.
Request Body:
{
"topic": "The future of AI in content creation"
}
### Success Response (200 OK):
{
"blog_post": "..." // The complete blog post generated by the crew
}
---