|
| 1 | +# GraphNews: A Multi-Agent Self-Correcting Editorial Team |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | +**GraphNews** is a sophisticated multi-agent system built with **LangGraph** that automates the end-to-end process of news research, curation, and newsletter drafting. Unlike standard linear AI chains, this project utilizes a **Cyclic Graph** architecture to implement a "Self-Correction" loop, ensuring high-quality, factual output through autonomous peer review. |
| 7 | + |
| 8 | +## Workflow Architecture |
| 9 | +The system treats the editorial process as a state machine. Data flows through specialized nodes, maintaining a shared state to ensure context is preserved across the entire lifecycle: |
| 10 | + |
| 11 | +1. **RESEARCHER:** Scours the web using **Tavily** for the top 10 . |
| 12 | +2. **CURATOR:** Filters research results to select the top 5 most relevant sources. |
| 13 | +3. **WRITER:** Generates a structured Markdown draft based on curated items. |
| 14 | +4. **CRITIC:** Evaluates the draft. If the score is **< 8/10**, the draft is sent back to the **WRITER** with specific feedback for revision. |
| 15 | +5. **FINALIZE:** Once the quality threshold is met, or we reach the 3rd draft (to avoid infinite loops), the final newsletter is saved to disk. |
| 16 | + |
| 17 | +```mermaid |
| 18 | +graph TD |
| 19 | + Start((Start)) --> Researcher[Researcher Node] |
| 20 | + Researcher --> Curator[Curator Node] |
| 21 | + Curator --> Writer[Writer Node] |
| 22 | + Writer --> Critic[Critic Node] |
| 23 | + |
| 24 | + Critic --> Decision{Score >= 8?} |
| 25 | + |
| 26 | + Decision -- "No (Score < 8 and draft number < 3)" --> Writer |
| 27 | + Decision -- "Yes (Approved)" --> End((Save Markdown)) |
| 28 | +
|
| 29 | + subgraph "The Agentic Loop" |
| 30 | + Writer |
| 31 | + Critic |
| 32 | + Decision |
| 33 | + end |
| 34 | +
|
| 35 | + style Researcher fill:#f9f,stroke:#333,stroke-width:2px |
| 36 | + style Curator fill:#bbf,stroke:#333,stroke-width:2px |
| 37 | + style Writer fill:#dfd,stroke:#333,stroke-width:2px |
| 38 | + style Critic fill:#fdd,stroke:#333,stroke-width:2px |
| 39 | + style Decision fill:#fff,stroke:#333,stroke-width:2px |
| 40 | +``` |
| 41 | + |
| 42 | +## Tech Stack |
| 43 | +* **Orchestration:** LangGraph (Stateful Multi-Agent Workflows) |
| 44 | +* **LLM:** DeepSeek-V3.2 |
| 45 | +* **Search Engine:** Tavily AI (Search API for LLMs) |
| 46 | +* **Language:** Python |
| 47 | + |
| 48 | +## Quick Start |
| 49 | + |
| 50 | +### 1. Clone & Install |
| 51 | +```bash |
| 52 | +git clone https://github.com/simonsl07/InsightLoop.git |
| 53 | +cd InsightLoop |
| 54 | +pip install -r requirements.txt |
| 55 | +``` |
| 56 | +### 2. Create a .env file following the .env.example file |
| 57 | +``` |
| 58 | +DEEPSEEK_API_KEY=your_key_here |
| 59 | +TAVILY_API_KEY=your_key_here |
| 60 | +``` |
| 61 | + |
| 62 | +### 3. Run the system |
| 63 | +```bash |
| 64 | +python main.py |
| 65 | +``` |
| 66 | + |
| 67 | +## Technical Challenges & Solutions |
| 68 | +- The "Hallucination" Brake: Implemented a max revision counter within the Critic node logic to prevent infinite loops and runaway API costs. |
| 69 | +- Deterministic State Control: Used LangGraph's TypedDict state to maintain a single source of truth, preventing context drift. |
| 70 | + |
| 71 | +## Roadmap |
| 72 | + - Add CLI arguments to control news topic and source count. |
| 73 | + - Integrate LangSmith for full-trace agent debugging and cost monitoring. |
| 74 | + - Human-in-the-Loop: Add a LangGraph Checkpointer to pause for human approval before final output. |
| 75 | + |
0 commit comments