Dudil is an emotion-aware chatbot that analyzes user input using a pre-trained emotion classification model and responds empathetically through Google’s Gemini AI. The application is designed to create contextual, emotionally intelligent conversations through a clean Streamlit-based interface.
- Emotion Detection: Classifies text into emotions such as joy, love, sadness, anger, fear, and surprise.
- Empathetic AI Responses: Dynamically adapts responses based on emotional state.
- Conversation History: Persists chats across sessions with support for browsing and management.
- Confidence & Intensity Scoring: Provides insight into how strongly emotions are detected.
- Streamlit UI: Modern web interface with expanders, metrics, and chat components.
- Frontend: Streamlit
- Emotion Model: Hugging Face Transformers (DistilBERT/DistilRoBERTa variants)
- Conversational Model: Google Gemini API
- Storage: JSON-based chat history
- Language: Python 3.7+
- Python 3.7 or higher
- Internet connection (for model/API)
- Google Gemini API Key
-
Clone the repository
git clone https://github.com/your-username/dudil.git cd dudil -
Install dependencies
pip install -r requirements.txt
-
Configure environment variables Create a
.envfile:GEMINI_API_KEY=your_gemini_api_key GEMINI_MODEL=gemini-pro DISTILBERT_MODEL=j-hartmann/emotion-english-distilroberta-base
-
Obtain Gemini API Key
- Visit Google AI Studio
- Generate a key and add it to
.env
-
Run the application
streamlit run app.py
-
Interact
- Go to
http://localhost:8501 - Enter your message
- View real-time emotion analysis and contextual replies
- Go to
- User input is analyzed using an emotion classification model.
- The detected emotion and intensity are used to construct a contextual prompt.
- Gemini AI generates a response tailored to the emotional context.
- Results are displayed with emotion metrics and stored in history.
| Emotion | Intensity | Description |
|---|---|---|
| Joy | 5/5 | Happiness and positive tone |
| Love | 5/5 | Affection and care |
| Surprise | 4/5 | Sudden or unexpected reaction |
| Anger | 2/5 | Frustration or irritation |
| Fear | 2/5 | Anxiety, nervousness |
| Sadness | 1/5 | Melancholy, disappointment |
| Key | Description |
|---|---|
GEMINI_API_KEY |
Required for accessing the Gemini API |
GEMINI_MODEL |
Gemini model name (e.g., gemini-pro) |
DISTILBERT_MODEL |
Hugging Face emotion classification model |
- Temperature: 0.7
- Top-p: 0.8
- Top-k: 40
- Max Tokens: 1024
- Create and manage new conversations
- View and delete previous chats
- Clear all chat history
- Auto-save on session exit
- Ensure stable internet for downloading models
- Check disk space (~500MB required)
- Verify that your API key is valid
- Ensure you have quota and correct permissions
- Ensure
chat_history.jsonis writable - Corrupted files are backed up automatically
- Fork this repository
- Create your branch:
git checkout -b feature/my-feature - Commit your changes:
git commit -m 'Add new feature' - Push to your branch:
git push origin feature/my-feature - Open a pull request
This project is licensed under the MIT License.
- Hugging Face
- Google AI
- Streamlit
- j-hartmann – Emotion Model