Transform casual emails into professional, context-appropriate communication powered by AI
Features โข Demo โข Installation โข Usage โข API Documentation โข Contributing
The backend exposes a simple health endpoint you can use to check whether the server and (optionally) the local model are ready:
GET /health
Example response (JSON):
{
"status": "healthy",
"model": "google/flan-t5-base"
}If you're using a large local model, the first run will download weights and the endpoint may show the server as running while the model is still loading. Monitor the server logs or use this endpoint [...]
The AI Email Rewriter is an intelligent tool that leverages Large Language Models (LLMs) to automatically convert informal or poorly structured emails into professional, business-appropriate commu[...]
| Before | After (Formal Tone) |
|---|---|
| "Hey, can you send me the file?" | "Could you please share the document at your earliest convenience?" |
- Formal: Professional and polite, suitable for business or official communication
- Friendly: Warm yet professional, ideal for colleagues or informal business settings
- Assertive: Direct and confident, useful for urgent or firm requests
- โก Real-Time Processing: Instant email rewriting with efficient LLM inference
- ๐ One-Click Copy: Seamless clipboard integration for quick email drafting
- ๐ฏ Context-Aware: Intelligent tone adjustment based on communication needs
- ๐ฑ Responsive Design: Works flawlessly on desktop and mobile devices
- ๐ Secure: Input sanitization and HTTPS-enabled communication
| Layer | Technology | Purpose |
|---|---|---|
| Frontend | HTML/CSS/JavaScript + Bootstrap 5 | User interface and interaction handling (responsive Tone Lab UI) |
| Backend | Flask (Python) | RESTful API and business logic |
| AI Model | Hugging Face Transformers | Email rewriting using LLMs (T5/BART) |
- T5 (Text-to-Text Transfer Transformer) - Ideal for paraphrasing and tone adjustment
- BART - Excellent for text generation and rewriting tasks
- DistilBART - Lightweight version for faster inference
Before you begin, ensure you have the following installed:
- Python 3.8 or higher
- pip (Python package manager)
- Node.js (optional, for frontend development)
- Git
git clone https://github.com/CipherSingularity/ai-email-refiner.git
cd ai-email-refiner# Create virtual environment
python -m venv venv
# Activate virtual environment
# On Windows
venv\Scripts\activate
# On macOS/Linux
source venv/bin/activate# Install backend dependencies
pip install -r requirements.txt
# Install frontend dependencies (if applicable)
npm installCreate a .env file in the root directory:
# Backend entrypoint (this project uses `backend.py`)
HF_TOKEN= # (optional) Hugging Face inference API token (e.g. hf_xxx)
HF_MODEL=google/flan-t5-base # optional default HF model
USE_LOCAL_MODEL=1 # 1 to prefer local model, 0 to prefer HF API
LOCAL_MODEL=google/flan-t5-small # local model name (small for dev, base for higher quality)
SECRET_KEY=your_secret_key_hereThis project uses `backend.py` as the Flask entrypoint. You can run it directly.
# On Windows PowerShell (recommended for development)
$env:USE_LOCAL_MODEL='1'
$env:LOCAL_MODEL='google/flan-t5-small' # or google/flan-t5-base
python backend.py
# To prefer the Hugging Face hosted inference API instead of a local model:
$env:USE_LOCAL_MODEL='0'
$env:HF_TOKEN='hf_YourTokenHere'
python backend.py
# For production, use a WSGI server such as Gunicorn (on Linux/macOS) or a process manager on Windows.
gunicorn -w 4 -b 0.0.0.0:5000 backend:appThe application will be available at http://localhost:5000
- Navigate to the application URL
- Enter your casual email text in the input area
- Select your desired tone (Formal, Friendly, or Assertive)
- Click "Rewrite Email"
- Copy the professional output with one click
Input: "Can you get this done?"
| Tone | Output |
|---|---|
| Formal | "Would you kindly complete this task at your earliest opportunity?" |
| Friendly | "Could you help get this done soon? Thanks!" |
| Assertive | "Please ensure this task is completed promptly." |
POST /rewrite
{
"text": "Hey, can you send me the file?",
"tone": "formal"
}| Parameter | Type | Required | Description |
|---|---|---|---|
text |
string | Yes | The casual email text to rewrite |
tone |
string | Yes | Desired tone: formal, friendly, or assertive |
{
"rewritten": "Could you please share the document at your earliest convenience?"
}{
"error": "Invalid tone specified",
"status": "error"
}curl -X POST http://localhost:5000/rewrite \
-H "Content-Type: application/json" \
-d '{"text": "Hey, send me the file", "tone": "formal"}'โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ Frontend โ โโHTTPโโโ Flask API โ โโAPIโโโโ Hugging Face โ
โ (HTML/CSS/ โ โ (Python) โ โ LLM (T5/BART) โ
โ JS) โ โโJSONโโโ โ โโTextโโโ โ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
- User Input: User enters email and selects tone
- API Request: Frontend sends POST request to Flask backend
- Prompt Engineering: Backend formats prompt for LLM
- AI Processing: Hugging Face LLM generates rewritten email
- Response: Backend returns professional email to frontend
- Display: Frontend shows result with copy functionality
- โ Corporate Communication: Convert casual messages to business-appropriate emails
- โ Non-Native Speakers: Craft professional English emails with confidence
- โ Freelancers: Maintain professionalism with clients
- โ Follow-ups: Streamline repetitive email drafting tasks
- โ Urgent Requests: Switch to assertive tone when needed
- Additional Tones: Apologetic, persuasive, neutral
- Context Awareness: Specify recipient type (client, manager, colleague)
- Multilingual Support: Support for multiple languages using mT5
- Email Templates: Pre-built templates for common scenarios
- Rich Text Editor: Format output with bold, italics, bullet points
- Batch Processing: Bulk email rewriting via CSV upload
- Analytics Dashboard: Usage metrics and insights
- Email Client Integration: Gmail and Outlook plugins
- Feedback Loop: User ratings to improve model performance
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Write clear commit messages
- Add tests for new features
- Update documentation as needed
- Follow PEP 8 style guide for Python code
- Ensure all tests pass before submitting PR
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
- ARUNAGIRINATHAN K - Initial work - MyGitHub
- Issues: GitHub Issues
โญ Star this repo if you find it helpful!
Made by ARUNAGIRINATHAN
