CoolFace
Apppublic

dacircuitsage/AnyThingAiv1

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
App README
╔══════════════════════════════════════════════════════════════════╗
║                                                                  ║
║             🧠 AI MOOD CHAT — Multi-Personality AI             ║
║                                                                  ║
║        Streamlit + LangChain + Mistral AI                       ║
║        Switch between Sad, Angry, Intelligent & Flirty modes   ║
║                                                                  ║
╚══════════════════════════════════════════════════════════════════╝

<div align="center">

Python Streamlit LangChain Mistral License Status

A revolutionary conversational AI with dynamic personality modes. Every chat feels different.

FeaturesInstallationUsageDeploymentContributing

</div>


🎭 What is AI Mood Chat?

AI Mood Chat is an interactive conversational AI that adapts its personality based on your chosen mood. Unlike traditional chatbots, this one truly feels different in each mode:

  • 😔 Sad Mode — A melancholic companion that understands your pain
  • 😡 Angry Mode — Direct, unfiltered, brutally honest responses
  • 🧠 Intelligent Mode — Deep analytical insights with precision
  • 😏 Horny Mode — Charming, teasing, and playful energy

Powered by Mistral AI's LLM and built with Streamlit for lightning-fast deployment.


✨ Features

🎨 Dynamic UI/UX

  • Per-mode styling — Each personality has custom colors, fonts, and animations
  • Real-time mode switching — Instantly change AI personality mid-conversation
  • Beautiful gradients — Background themes that match the vibe
  • Smooth animations — Typewriter effects, bouncing indicators, fade transitions
  • Responsive design — Works seamlessly on desktop and mobile

🤖 Smart AI Engine

  • Mistral AI integration — State-of-the-art language model
  • Temperature control — Each mode has optimized temperature for authenticity:
  • Sad: 0.8 (more creative)
  • Angry: 0.9 (unpredictable energy)
  • Intelligent: 0.4 (precise)
  • Flirty: 0.85 (playful)
  • Context-aware conversations — Maintains chat history per session
  • System prompts — Custom instructions per personality

⚡ Performance

  • Fast responses — Sub-second chat latency
  • Streamlit caching — Optimized for performance
  • Lightweight — Minimal dependencies
  • Free tier compatible — Works on HF Spaces free tier

🔒 Security

  • Environment variables — Secure API key management
  • No data persistence — Conversations don't leave your session
  • .env support — Easy local configuration

🚀 Quick Start

Prerequisites

  • Python 3.10+
  • Mistral AI API Key (Get one free)
  • Virtual environment (recommended)

Installation

1️⃣ Clone the Repository
bash
git clone https://github.com/YOUR_USERNAME/ai-mood-chat.git
cd ai-mood-chat
2️⃣ Create & Activate Virtual Environment
bash
# Windows
python -m venv EnvAnything
EnvAnything\Scripts\activate

# macOS/Linux
python3 -m venv EnvAnything
source EnvAnything/bin/activate
3️⃣ Install Dependencies
bash
pip install -r requirements.txt
4️⃣ Configure Environment

Create a .env file in the root directory:

bash
MISTRAL_API_KEY="your_mistral_api_key_here"

Get your free Mistral API key:

  1. 1.Go to console.mistral.ai
  2. 2.Sign up or login
  3. 3.Navigate to API Keys
  4. 4.Create a new key
  5. 5.Copy it to .env
5️⃣ Run the App
bash
streamlit run app.py

🎉 Visit http://localhost:8501 in your browser


💬 Usage

Getting Started

  1. 1.Open the app — Launch in your browser
  2. 2.Choose a mood — Select from the sidebar:
  3. 3.😔 Sad Mode
  4. 4.😡 Angry Mode
  5. 5.🧠 Intelligent Mode
  6. 6.😏 Flirty Mode
  7. 7.Type your message — Chat naturally with the AI
  8. 8.Switch modes — Change personality anytime mid-conversation

Example Interactions

😔 Sad Mode
You: "I'm feeling really down today"
AI: "I feel that heaviness with you... sometimes life weighs us down like stones.
Tell me, what's making your heart ache?"
😡 Angry Mode
You: "Why do people waste my time?"
AI: "Because they're selfish and don't respect your minutes. 
Cut them loose. You don't owe anyone your time."
🧠 Intelligent Mode
You: "Explain quantum computing"
AI: "Quantum computing leverages superposition and entanglement 
to perform parallel computations... [detailed technical explanation]"
😏 Flirty Mode
You: "Hey there"
AI: "Well hello yourself... did you come here just to see me? 
Because I was definitely hoping you would... 😉"

🛠️ Tech Stack

LayerTechnologyVersion
FrontendStreamlit1.56.0
LLM FrameworkLangChain1.2.15
AI ModelMistral AILatest
API Clientlangchain-mistralai1.1.2
Configurationpython-dotenv1.2.2
RuntimePython3.11

📁 Project Structure

ai-mood-chat/
├── app.py                          # Main Streamlit application
├── requirements.txt                # Python dependencies
├── .env                            # API keys (NOT in git)
├── .gitignore                      # Git ignore rules
├── README.md                       # This file
└── DEPLOY_TO_HF_SPACES.md         # Deployment guide

Key Components in app.py

python
# 1. MODE DEFINITIONS
MODES = {
    "😔 Sad Mode": {...},
    "😡 Angry Mode": {...},
    "🧠 Intelligent Mode": {...},
    "😏 Horny Mode": {...}
}

# 2. DYNAMIC CSS INJECTION
def inject_css(mode_cfg): # Per-mode styling

# 3. SESSION STATE MANAGEMENT
# Maintains conversation history per session

# 4. CHAT INTERACTION LOOP
# LangChain integration with Mistral AI

🚀 Deployment

Deploy to Hugging Face Spaces (FREE!)

The easiest way to deploy. Full guide: See DEPLOY_TO_HF_SPACES.md

Quick Deploy (30 seconds):
  1. 1.Create account at huggingface.co
  2. 2.Create a new Streamlit Space
  3. 3.Add MISTRAL_API_KEY to Space Secrets
  4. 4.Push code: git push space main
  5. 5.Done! 🎉

Live Demo: AI Mood Chat on HF Spaces (update with your link)

Other Deployment Options


⚡ Performance Benchmarks

Running on HF Spaces Free Tier (2vCPU, 16GB RAM):

MetricValue
Cold start~45 seconds
Warm response~2-5 seconds
Time to first byte~3 seconds
Concurrent users1-5 (free tier)

💡 Tip: Response time depends on Mistral API. Longer prompts take more time.


🔒 Security & Best Practices

✅ Do's

  • ✓ Keep API keys in .env (never commit)
  • ✓ Add .env to .gitignore
  • ✓ Use HF Space Secrets for production
  • ✓ Rotate API keys regularly
  • ✓ Monitor usage and quota

❌ Don'ts

  • ✗ Don't hardcode API keys in code
  • ✗ Don't push .env file
  • ✗ Don't share API keys publicly
  • ✗ Don't ignore quota warnings

🤝 Contributing

We love contributions! Here's how to help:

Steps

  1. 1.Fork this repository
  2. 2.Create feature branch: git checkout -b feature/amazing-feature
  3. 3.Make changes and test locally
  4. 4.Commit: git commit -m 'Add amazing feature'
  5. 5.Push: git push origin feature/amazing-feature
  6. 6.Open Pull Request with description

Ideas for Contributions

  • 🎨 New mood/personality modes
  • 🚀 Performance optimizations
  • 🐛 Bug fixes
  • 📚 Documentation improvements
  • 🧪 More test coverage
  • 🌐 Multi-language support

Development Guidelines

  • Follow PEP 8 style guide
  • Add comments for complex logic
  • Test locally before pushing
  • Use descriptive commit messages

📦 Dependencies

Core dependencies (see requirements.txt for full list):

streamlit==1.56.0
langchain==1.2.15
langchain-mistralai==1.1.2
langchain-core==1.2.26
python-dotenv==1.2.2

For production, consider removing heavy packages (torch, transformers, faiss-cpu) to speed up cold starts.


🐛 Troubleshooting

Issue: "MISTRALAPIKEY not configured"

Solution:

  • Check .env file exists
  • Verify key is correct
  • For HF Spaces: Add to Space Secrets (Settings → Secrets)

Issue: App is slow

Solution:

  • Cold start is normal (30-60 seconds)
  • Check Mistral API status
  • Reduce model size if possible
  • Consider upgrading HF Space tier

Issue: API quota exceeded

Solution:

  • Check Mistral dashboard
  • Upgrade to paid plan
  • Implement rate limiting
  • Contact Mistral support

📊 Usage Statistics

Track your app's performance:

bash
# View HF Space logs
# Settings → Activity Logs

# Local development
streamlit logger level=info

🎓 Learning Resources


📝 License

This project is licensed under the MIT License — feel free to use it for anything!

MIT License
Copyright (c) 2024 [Your Name]
Permission is hereby granted, free of charge...

See LICENSE file for details.


🙋 FAQ

Q: Is this free to run?

A: Yes! Uses free Mistral tier. HF Spaces is also free (with limitations).

Q: Can I modify the personalities?

A: Absolutely! Edit the MODES dictionary in app.py to customize system prompts.

Q: How many users can it handle?

A: Free HF Spaces supports ~1-5 concurrent users. Upgrade for more.

Q: Is my chat data saved?

A: No. Conversations are session-only and deleted after closing.

Q: Can I use a different LLM?

A: Yes! LangChain supports OpenAI, Anthropic, Hugging Face, etc. Modify the LLM initialization.


🌟 Show Your Support

If you find this project helpful:

  • ⭐ Star the repository
  • 🔁 Share with friends
  • 🐛 Report bugs
  • 💡 Suggest features
  • 🤝 Contribute code

👨‍💻 Author

Your Name @GitHub

Built with ❤️ for AI enthusiasts everywhere.


📧 Contact & Support


<div align="center">

Made with 🧠 and ✨

Back to Top

</div>