College Project - AI-Powered Text Analysis
A simple web application that detects toxic messages and rewrites them politely using Google's Gemini AI.
This is a college project demonstrating:
- AI-powered text analysis
- Toxicity detection in social media content
- Automatic text rewriting for better communication
- Web application development with Streamlit
- Toxicity Detection: Identifies harmful content in text messages
- Smart Rewriting: Converts toxic messages to polite alternatives
- Real-time Analysis: Instant feedback on message safety
- Multiple Tone Options: Professional, Friendly, Polite, Formal styles
- Clean, simple design suitable for all users
- Interactive examples to test the system
- Analysis history tracking
- Adjustable sensitivity settings
- Python 3.7 or higher
- Google API key (free from Google AI Studio)
-
Download the project files
# Download all files: safechat.py, requirements.txt, .env -
Install required packages
pip install -r requirements.txt
-
Set up your API key
- Get a free API key from Google AI Studio
- Add it to the
.envfile:
GOOGLE_API_KEY=your_api_key_here -
Run the application
streamlit run safechat.py
-
Open in browser
- The app will open at
http://localhost:8501
- The app will open at
- Enter Text: Type or paste any message in the text area
- Choose Analysis Type:
- "Analyze Message" - Check if text is toxic
- "Analyze & Rewrite" - Get a polite version if needed
- Review Results: See toxicity score and explanation
- Try Examples: Use provided sample texts to test the system
- Harassment: Bullying and intimidation
- Hate Speech: Discriminatory language
- Threats: Violent or threatening content
- Profanity: Inappropriate language
- Personal Attacks: Direct insults
This project demonstrates:
- AI Integration: Using Google's Gemini API
- Web Development: Building interactive apps with Streamlit
- Natural Language Processing: Text analysis and generation
- User Experience Design: Creating intuitive interfaces
- API Management: Handling external services securely
- Frontend: Streamlit (Python web framework)
- AI Model: Google Gemini 2.5 Flash
- Language: Python 3.7+
- Response Time: ~2 seconds per analysis
- Accuracy: ~85% for clear cases
- No Data Storage: Messages are not saved permanently
- Local Processing: Analysis happens in real-time
- Educational Use: Designed for learning purposes
- Human Oversight: Results should be reviewed by humans
safechat-project/
├── safechat.py # Main application file
├── requirements.txt # Python dependencies
├── .env # API key configuration
├── README.md # This documentation
└── demo_texts.txt # Sample texts for testing
- Add more languages support
- Implement batch text processing
- Create mobile-friendly interface
- Add user feedback system
- Integrate with social media APIs
- AI detection is not 100% accurate
- May miss context-dependent sarcasm
- Requires internet connection
- Limited to supported languages
- Google Gemini AI for text analysis
- Streamlit for web framework
- Python Community for open-source libraries
Made with ❤️ for educational purposes
This project is designed for learning and demonstration. Please use responsibly and always review AI-generated content.