Skip to content

jonuar/ContentAgentOS

Repository files navigation

ContentAgentOS

Multi-agent content pipeline with human-in-the-loop validation. Planner → Researcher → Writer → Editor → Human Checkpoint → Publisher.

Built with LangGraph · LangChain · Streamlit · LinkedIn API · DuckDuckGo / Tavily

Features

  • Multi-Agent Orchestration: Planner → Researcher → Writer → Editor → Publisher
  • Intelligent Revision Loop: Automatic rewriting when content scores below quality threshold
  • Human Checkpoint: Pause execution for review, approval, or custom edits before publishing
  • Dataset Export (JSONL): Automatically save approved content with full context (metadata, research, scores, feedback) for LLM training and RAG pipelines
  • Multi-Provider LLM Support: DeepSeek (default), OpenAI, Anthropic, Google Gemini (free tier)
  • Web Research Integration: DuckDuckGo (free) and Tavily (premium) search providers
  • Platform-Aware Content: Optimize for LinkedIn, Twitter, YouTube with platform-specific formatting
  • Run Resumption: SQLite-backed checkpointing — resume interrupted runs without losing progress
  • Dual Interface: CLI for scripting, Streamlit UI for interactive review

Tech Stack

  • Orchestration: LangGraph (state machine-based agentic workflows)
  • LLM Integration: LangChain with multi-provider support
  • Persistence: SQLite with LangGraph checkpointer
  • UI: Streamlit (human-in-the-loop interface)
  • Monitoring: Loguru (structured logging)

Pipeline

Agentic System Description

  1. Planner Agent — topic → specific content brief (angle, audience, key points)
  2. Research Agent — web search, trends, data synthesis
  3. Writer Agent — draft adapted to platform and format
  4. Editor + Fact-Checker — quality score (0–1), feedback, triggers rewrite if below threshold
  5. Human Checkpoint — review, edit, approve, or reject with feedback
  6. Publisher Agent — posts to LinkedIn (or dry-runs in dev mode)
  7. Dataset Export — approved content saved to JSONL (training_data.jsonl) with full audit trail

Quick start

# 1. Install
pip install -r requirements.txt

# 2. Configure
cp .env.example .env
# Edit .env with your LLM provider key

# 3. Run (CLI)
python -m src.main --topic "Why RAG systems fail in production" --platform linkedin

# Or run (UI)
streamlit run ui/app.py

Examples

CLI: Generate LinkedIn post

python -m src.main \
  --topic "LangGraph patterns for AI agents" \
  --platform linkedin \
  --language en \
  --context "Target senior engineers. Focus on production patterns, not toy examples."

CLI: Resume an interrupted run

python -m src.main --thread-id <thread-id-from-previous-run>

UI: Interactive review

streamlit run ui/app.py
# Opens at http://localhost:8501
# Tab 1: Start new content pipeline
# Tab 2: Review, edit, approve, or request revision
# Tab 3: View run history

Project structure

ContentAgentOS/
├── src/
│   ├── core/
│   │   ├── config.py          # Settings & environment variables
│   │   └── state.py            # ContentState TypedDict + factory
│   ├── agents/
│   │   ├── llm.py              # LLM factory (4 providers)
│   │   ├── planner.py          # Topic → brief
│   │   ├── researcher.py       # Web search + synthesis
│   │   ├── writer.py           # Brief + research → draft
│   │   ├── editor.py           # Draft → quality score + feedback
│   │   └── publisher.py        # Draft → LinkedIn (+ dataset export)
│   ├── graph/
│   │   └── builder.py          # LangGraph orchestration
│   ├── tools/
│   │   ├── search.py           # Web search (DuckDuckGo / Tavily)
│   │   └── dataset_exporter.py # JSONL export for LLM training
│   └── main.py                 # CLI entrypoint
├── ui/
│   └── app.py                  # Streamlit UI
├── docs/
│   ├── ARCHITECTURE.md         # System design & patterns
│   ├── SETUP.md                # Installation & configuration
│   └── DATASET_EXPORT.md       # Dataset format & usage guide
├── datasets/                   # Generated training data (JSONL)
├── requirements.txt
├── .env.example
└── README.md

Development

Run tests:

pytest tests/

Check logs:

tail -f /tmp/contentagentos.log

Dataset Export (JSONL)

After human approval, content is automatically exported to datasets/training_data.jsonl with full context:

  • Topic, angle, target audience, key points
  • Research notes and sources
  • Draft versions and editor scores
  • Human feedback and final edits
  • Publishing status

Perfect for:

  • LLM Fine-tuning: Train custom models on your approved content
  • RAG Pipelines: Use approved content as reference material
  • Quality Analysis: Track trends and scoring patterns
  • Compliance Audits: Maintain audit trail of approvals

See DATASET_EXPORT.md for usage examples.

Configuration

See SETUP.md for detailed configuration options.

Key environment variables:

LLM_PROVIDER: Which LLM to use (deepseek | openai | anthropic | gemini)
QUALITY_THRESHOLD: Auto-rewrite threshold (0.0–1.0, default 0.7)
MAX_RETRIES: Max automatic rewrite attempts (default 2)
DRY_RUN: Log instead of publish to LinkedIn (default true)

Key config (.env)

Variable Default Description
LLM_PROVIDER deepseek deepseek | openai | anthropic | gemini
SEARCH_PROVIDER duckduckgo duckduckgo (free) | tavily (premium)
QUALITY_THRESHOLD 0.7 Editor score gate (0.0–1.0)
MAX_RETRIES 2 Max automatic rewrite attempts
DRY_RUN true Log instead of publish to LinkedIn

Documentation

  • ARCHITECTURE.md — System design, module responsibilities, data flow, patterns
  • SETUP.md — Installation, configuration, troubleshooting, running the pipeline
  • DATASET_EXPORT.md — Dataset format (JSONL), schema, usage examples, fine-tuning guide

Roadmap

  • Batch content generation from CSV
  • More platform integrations (Medium, Substack, Dev.to)
  • Prompt optimization via LangSmith
  • Evaluation framework (benchmark against competitors)
  • Async agent execution for parallel processing
  • Database persistence (runs analytics, trending topics)

About

AI-powered content pipeline with human-in-the-loop validation. Orchestrates specialized agents (planner, researcher, writer, editor, publisher) using LangGraph to generate production-grade technical content.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages