Skip to content

A curated collection of practical AI projects implementing OCR systems, RAG, AI agents, and other AI use cases.

audit: fix multi_agent_coding_assistant - rewrite em dashes, add docstrings, improve README

Tiioluwaniec4d10da716e
diff --git a/ai_agents/multi_agent_coding_assistant/.env.example b/ai_agents/multi_agent_coding_assistant/.env.example
index 08db593..adc00c7 100644
--- a/ai_agents/multi_agent_coding_assistant/.env.example
+++ b/ai_agents/multi_agent_coding_assistant/.env.example
@@ -1,2 +1,2 @@
-# Mistral AI API key — obtain one at https://platform.mistral.ai
+# Mistral AI API key. Get yours free at https://platform.mistral.ai
MISTRAL_API_KEY=your_mistral_api_key_here
diff --git a/ai_agents/multi_agent_coding_assistant/README.md b/ai_agents/multi_agent_coding_assistant/README.md
index 8cffb99..00f7bd5 100644
--- a/ai_agents/multi_agent_coding_assistant/README.md
+++ b/ai_agents/multi_agent_coding_assistant/README.md
@@ -20,10 +20,10 @@ Multi-Agent Coding Assistant orchestrates a four-stage pipeline powered by Mistr
## Features
-- **Planner Agent** — breaks any coding task into a numbered, step-by-step implementation plan
-- **Coder Agent (Draft)** — translates the plan into typed, documented Python code
-- **Reviewer Agent** — audits the draft for bugs, edge cases, PEP 8 compliance, performance, and security issues
-- **Coder Agent (Final)** — applies every piece of reviewer feedback to produce production-ready code
+- **Planner Agent**: breaks any coding task into a numbered, step-by-step implementation plan
+- **Coder Agent (Draft)**: translates the plan into typed, documented Python code
+- **Reviewer Agent**: audits the draft for bugs, edge cases, PEP 8 compliance, performance, and security issues
+- **Coder Agent (Final)**: applies every piece of reviewer feedback to produce production-ready code
- Expandable result sections so you can compare draft vs. final side by side
- Inline API key input as a fallback when no `.env` file is present
@@ -39,7 +39,7 @@ Multi-Agent Coding Assistant orchestrates a four-stage pipeline powered by Mistr
## Prerequisites
- Python 3.9 or higher
-- A [Mistral AI API key](https://platform.mistral.ai)
+- A [Mistral AI API key](https://platform.mistral.ai) (free tier available)
## Installation
@@ -90,10 +90,14 @@ Open `http://localhost:8501` in your browser, describe a coding task, and click
| Variable | Description |
|---|---|
-| `MISTRAL_API_KEY` | Your Mistral AI API key — obtain one at [platform.mistral.ai](https://platform.mistral.ai) |
+| `MISTRAL_API_KEY` | Your Mistral AI API key. Obtain one at [platform.mistral.ai](https://platform.mistral.ai) |
If `MISTRAL_API_KEY` is not set, the app will prompt you to paste it directly in the UI.
+---
+
+[⬆ Back to Top](#multi-agent-coding-assistant)
+
## Project Structure
```text
diff --git a/ai_agents/multi_agent_coding_assistant/agents.py b/ai_agents/multi_agent_coding_assistant/agents.py
index f3685df..520f503 100644
--- a/ai_agents/multi_agent_coding_assistant/agents.py
+++ b/ai_agents/multi_agent_coding_assistant/agents.py
@@ -73,6 +73,7 @@ Return ONLY the improved Python code. No explanations — just the final code.""
def create_llm(api_key: str) -> ChatMistralAI:
+ """Create and return a ChatMistralAI instance configured with the given API key."""
return ChatMistralAI(
model="mistral-small-latest",
api_key=api_key,
@@ -81,6 +82,7 @@ def create_llm(api_key: str) -> ChatMistralAI:
def run_planner(llm: ChatMistralAI, task: str) -> str:
+ """Send the coding task to the Planner Agent and return a structured implementation plan."""
messages = [
SystemMessage(content=PLANNER_SYSTEM_PROMPT),
HumanMessage(content=f"Coding task: {task}"),
@@ -90,6 +92,7 @@ def run_planner(llm: ChatMistralAI, task: str) -> str:
def run_coder(llm: ChatMistralAI, plan: str) -> str:
+ """Send the implementation plan to the Coder Agent and return a first-draft Python implementation."""
messages = [
SystemMessage(content=CODER_SYSTEM_PROMPT),
HumanMessage(content=f"Implementation plan:\n\n{plan}"),
@@ -99,6 +102,7 @@ def run_coder(llm: ChatMistralAI, plan: str) -> str:
def run_reviewer(llm: ChatMistralAI, code: str) -> str:
+ """Send the draft code to the Reviewer Agent and return actionable review feedback."""
messages = [
SystemMessage(content=REVIEWER_SYSTEM_PROMPT),
HumanMessage(content=f"Review this Python code:\n\n```python\n{code}\n```"),
@@ -108,6 +112,7 @@ def run_reviewer(llm: ChatMistralAI, code: str) -> str:
def run_final_coder(llm: ChatMistralAI, plan: str, draft_code: str, review: str) -> str:
+ """Send the plan, draft, and review feedback to the Coder Agent and return the polished final implementation."""
messages = [
SystemMessage(content=FINAL_CODER_SYSTEM_PROMPT),
HumanMessage(
diff --git a/ai_agents/multi_agent_coding_assistant/app.py b/ai_agents/multi_agent_coding_assistant/app.py
index 94b689c..2176340 100644
--- a/ai_agents/multi_agent_coding_assistant/app.py
+++ b/ai_agents/multi_agent_coding_assistant/app.py
@@ -1,3 +1,4 @@
+"""Streamlit app that runs a four-stage multi-agent pipeline using Mistral AI to plan, write, review, and refine Python code from a natural-language task description."""
import os
import streamlit as st
from dotenv import load_dotenv