An LLM-driven agent that converts campaign briefs into structured ad campaign plans.
- Converts natural language campaign briefs into machine-readable JSON plans
- Generates multiple ad creative variants with justifications
- Performs automated consistency checks
- Supports mock LLM responses for testing
- Includes example briefs and outputs
- 
Clone the repository git clone https://github.com/yourusername/campaign-agent.git cd campaign-agent
- 
Create a virtual environment python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate 
- 
Install dependencies pip install -r requirements.txt 
- 
Configure environment variables cp .env.example .env Then add your OpenAI API key and model settings inside .env.
Run the web interface:
streamlit run ui/app.pyThe UI provides a user-friendly interface for:
- Creating and editing campaign briefs
- Generating campaign plans
- Viewing detailed results
- Downloading campaign plans as JSON
Process a campaign brief:
python -m src.agent examples/brief1.jsonfrom src.agent import CampaignAgent
# Initialize agent
agent = CampaignAgent()
# Process brief from file
campaign = agent.process_brief_from_file("examples/brief1.json")
# Or process brief directly
brief = {
    "campaign_id": "cmp_2025_09_01",
    "goal": "increase trial signups",
    # ... rest of brief ...
}
campaign = agent.process_brief(brief)Run tests with mock LLM responses:
pytest tests/campaign-agent/
├── src/                     # Main source code
│   ├── agent.py             # Campaign agent implementation
│   ├── models/              # Data models
│   ├── prompts/             # LLM prompts
│   ├── validators/          # Validation logic
│   └── utils/               # Utility functions
├── tests/                   # Test files
├── examples/                # Example briefs and outputs
├── requirements.txt         # Python dependencies
└── .env.example             # Environment variables template
| Variable | Description | Default | 
|---|---|---|
| OPENAI_API_KEY | Your OpenAI API key | — | 
| LLM_MODEL | Model to use | gpt-4 | 
| TEMPERATURE | Model temperature | 0.7 | 
| MAX_TOKENS | Maximum tokens per response | 2000 | 
| MOCK_LLM | Use mock responses for testing | false | 
- Limited grounding: Currently doesn’t use a knowledge base for product facts or past metrics
- Basic validation: Could add more sophisticated checks for ad copy quality
- No performance prediction: Future versions could include ML-based creative scoring
MIT License
Project: radiac.ai_assignment