Frontend (frontend/app.js): - Add textarea for improvement feedback - Add submit button with loading state - Handle API response and display improved content Backend (backend/copywriter.py): - Add improve_copy() method using Cohere API - Integrate retry mechanism for API calls Backend (backend/main.py): - Add /improve-content POST endpoint - Implement error handling and return improved content with metadata Testing: - Verified feedback submission flow - Confirmed improved content generation - Tested error scenarios and loading states
Marketing Assistant AI
A comprehensive AI-powered tool designed to streamline the process of ideation, copywriting, and marketing campaign creation for Adriana James. This system generates high-quality marketing content that maintains brand consistency while significantly reducing content creation time.
🌟 Features
- AI-Powered Content Generation: Create marketing content for various channels with customizable parameters
- Brand Voice Consistency: Ensure all content adheres to Adriana James' unique brand tone and style
- Vector Search: Find similar past content for reference and inspiration
- Content Improvement: Refine generated content based on specific feedback
- Brand Style Management: Configure and update brand guidelines through a user-friendly interface
- Training Data Management: Add successful marketing content to improve the AI over time
- Content Performance Analysis: Get insights into the potential effectiveness of your content
- History Tracking: Keep track of all generated content and user interactions
- Pagination Support: Efficiently browse through large datasets of historical content
- Error Handling: Robust error handling and user feedback systems
📋 Project Overview
The Marketing Assistant AI combines a powerful backend built with FastAPI and a clean, intuitive frontend interface. It leverages advanced AI models through the Cohere API for text generation, embeddings, and reranking.
Tech Stack
- Backend: Python with FastAPI
- Frontend: Vanilla HTML, CSS, and JavaScript
- AI Models: Cohere's generation and embedding models
- Vector Database: FAISS for efficient content similarity search
- Storage:
- JSON files for historical marketing data
- SQLite for training data
- FAISS vector store for content similarity search
🚀 Getting Started
Prerequisites
- Python 3.9+
- Node.js and npm (optional, for development tools)
- Cohere API key
Installation
- Clone the repository
git clone http://23.29.118.76:3000/michael/marketing-assistant-ai.git
cd marketing-assistant-ai
- Set up the backend
cd backend
pip install -r requirements.txt
- Configure environment variables
Create a .env file in the project root with the following variables:
# API Keys
COHERE_API_KEY=your-api-key-here
# LLM Configuration
LLM_MODEL=llm-model-name # e.g., command
LLM_API_KEY=your-api-key-here # if using a custom model
# Server Configuration
API_HOST=localhost
API_PORT=8000
# Database Configuration
DATABASE_URL=sqlite:///./data/training_data.db
# Brand Configuration
BRAND_NAME=Adriana James
- Start the backend server
cd backend
python main.py
The API will be available at http://localhost:8000
- Serve the frontend
You can use any static file server. For development, Python's built-in HTTP server works well:
cd frontend
python -m http.server 3000
The frontend will be available at http://localhost:3000
🔧 Usage
Generating Content
- Navigate to the "Generate" tab in the web interface
- Enter your content prompt (e.g., "Write a social media post about our new coaching program")
- Select optional parameters (content type, tone, length)
- Click "Generate" and wait for the AI to create your content
- Review, improve, and save the generated content
Managing Brand Style
- Go to the "Brand Style" tab
- Configure tone options and voice characteristics
- Add or remove taboo words
- Define preferred terminology
- Save the updated brand style
Adding Training Data
- Visit the "Training" tab
- Select the content type
- Enter your high-performing marketing content
- Add performance metrics if available
- Submit the training data to improve the AI over time
📁 Project Structure
Marketing_Assistant_AI/
│-- backend/
│ │-- main.py # FastAPI application
│ │-- copywriter.py # AI content generation
│ │-- vector_store.py # FAISS vector database
│ │-- embeddings.py # Cohere embeddings
│ │-- brand_style.py # Brand style management
│ │-- config.py # Configuration settings
│ │-- requirements.txt # Python dependencies
│
│-- data/
│ │-- past_campaigns/ # Stored marketing campaigns
│ │-- user_queries/ # Query history
│ │-- style_guidelines/ # Brand style config
│ │ │-- brand_style.json # Default style guidelines
│
│-- frontend/
│ │-- index.html # Main HTML page
│ │-- styles.css # CSS styles
│ │-- app.js # Frontend functionality
│
│-- docs/
│ │-- README.md # Developer documentation
│ │-- API_Documentation.md # API reference
│
│-- .env # Environment variables
│-- .gitignore # Git ignore rules
│-- LICENSE # License information
│-- README.md # This file
🔄 API Endpoints
The backend provides several RESTful API endpoints:
| Endpoint | Method | Description |
|---|---|---|
/generate-copy |
POST | Generate marketing content |
/brand-style |
GET | Retrieve brand style guidelines |
/brand-style |
PUT | Update brand style guidelines |
/training-data |
POST | Add new training data |
/training-data |
GET | List available training data |
/training-data/{id} |
GET | Get specific training document |
/training-data/{id} |
DELETE | Delete training document |
/improve-content |
POST | Improve content based on feedback |
/analyze-content |
POST | Analyze content performance |
For detailed API documentation, see API Documentation.
💡 How It Works
-
Content Generation Process
- User submits a content request
- System formats the prompt with brand style guidelines
- Similar past content is retrieved from the vector database
- The AI generates content using the formatted prompt and references
- The system checks alignment with brand guidelines
- Final content is returned with alignment score and suggestions
-
Brand Style Management
- Brand style guidelines are stored in JSON format
- The system uses these guidelines to format prompts for the AI
- Content is checked against taboo words and preferred terminology
- An alignment score is calculated based on adherence to guidelines
-
Vector Search
- Marketing content is converted to vector embeddings using Cohere
- FAISS enables efficient similarity search across thousands of documents
- Similar content is reranked based on relevance to the query
🛠️ Development
Backend Development
The backend is built with FastAPI and follows a modular architecture:
main.py: API endpoints and request handlingcopywriter.py: Core AI content generationvector_store.py: Vector database operationsembeddings.py: Embedding generation and rerankingbrand_style.py: Brand style managementconfig.py: Configuration settings
Frontend Development
The frontend is built with vanilla HTML, CSS, and JavaScript:
index.html: Main application structure and UI componentsstyles.css: Styling and responsive design rulesapp.js: User interactions and API integration
🔍 Future Enhancements
- User authentication and role-based access
- Content performance analytics dashboard
- A/B testing capabilities
- Integration with marketing platforms
- Custom model fine-tuning for even better results
- Mobile application
👥 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
👏 Acknowledgements
Made with ❤️ for Adriana James