Spaces:
Sleeping
Sleeping
Pramish Pandey
commited on
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Digital Galatea AI
|
| 2 |
+
|
| 3 |
+
Digital Galatea is a conversational AI with a dynamic emotional model. It features a web-based interface where an avatar's shape and expression change in real-time to reflect the AI's feelings, which are influenced by the conversation.
|
| 4 |
+
|
| 5 |
+
## Features
|
| 6 |
+
|
| 7 |
+
- **Conversational AI**: Powered by the Google Gemini API for natural and engaging conversations.
|
| 8 |
+
- **Dynamic Emotional Model**: Simulates five core emotions: Joy, Sadness, Anger, Fear, and Curiosity.
|
| 9 |
+
- **Responsive Avatar**: The AI's visual avatar changes its shape and facial expression based on its dominant emotion.
|
| 10 |
+
- **Sentiment Analysis**: Analyzes user input to dynamically update the AI's emotional state. It uses Azure Text Analytics for high accuracy when configured, with a seamless fallback to a local NLTK VADER model.
|
| 11 |
+
- **Real-time Web Interface**: Built with Flask and JavaScript, the interface polls for updates to keep the avatar and emotion bars synchronized with the AI's state.
|
| 12 |
+
|
| 13 |
+
## Tech Stack
|
| 14 |
+
|
| 15 |
+
- **Backend**: Python, Flask
|
| 16 |
+
- **AI & Machine Learning**:
|
| 17 |
+
- Google Gemini API
|
| 18 |
+
- Azure Cognitive Service for Language (Text Analytics)
|
| 19 |
+
- NLTK (VADER)
|
| 20 |
+
- **Frontend**: HTML, CSS, JavaScript
|
| 21 |
+
- **Environment Management**: `python-dotenv`
|
| 22 |
+
|
| 23 |
+
## Project Structure
|
| 24 |
+
|
| 25 |
+
```
|
| 26 |
+
.
|
| 27 |
+
βββ app.py # Main Flask application, API endpoints
|
| 28 |
+
βββ import_random.py # Core AI logic (GalateaAI, DialogueEngine, AvatarEngine)
|
| 29 |
+
βββ requirements.txt # Python dependencies
|
| 30 |
+
βββ .env # Environment variables (API keys)
|
| 31 |
+
βββ static/
|
| 32 |
+
β βββ css/style.css # Styles for the web interface
|
| 33 |
+
β βββ js/script.js # Frontend JavaScript for interactivity
|
| 34 |
+
βββ templates/
|
| 35 |
+
βββ index.html # Main HTML file for the web interface
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
## Setup and Installation
|
| 39 |
+
|
| 40 |
+
1. **Clone the Repository**
|
| 41 |
+
```bash
|
| 42 |
+
git clone <repository-url>
|
| 43 |
+
cd Digital-Galatea
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
2. **Create and Activate a Virtual Environment**
|
| 47 |
+
```bash
|
| 48 |
+
# For Windows
|
| 49 |
+
python -m venv venv
|
| 50 |
+
.\venv\Scripts\activate
|
| 51 |
+
|
| 52 |
+
# For macOS/Linux
|
| 53 |
+
python3 -m venv venv
|
| 54 |
+
source venv/bin/activate
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
3. **Install Dependencies**
|
| 58 |
+
```bash
|
| 59 |
+
pip install -r requirements.txt
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
4. **Configure Environment Variables**
|
| 63 |
+
- Create a file named `.env` in the project root.
|
| 64 |
+
- Add your Google Gemini API key to it. You can get a key from the [Google AI Studio](https://ai.google.dev/).
|
| 65 |
+
|
| 66 |
+
```properties
|
| 67 |
+
# .env
|
| 68 |
+
GEMINI_API_KEY=your_gemini_api_key_here
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
5. **(Optional) Configure Azure Text Analytics**
|
| 72 |
+
- For more accurate sentiment analysis, you can use Azure.
|
| 73 |
+
- Get your key and endpoint from the Azure Portal after creating a "Language service" resource.
|
| 74 |
+
- Add them to your `.env` file:
|
| 75 |
+
```properties
|
| 76 |
+
# .env
|
| 77 |
+
AZURE_TEXT_ANALYTICS_KEY=your_azure_key_here
|
| 78 |
+
AZURE_TEXT_ANALYTICS_ENDPOINT=your_azure_endpoint_here
|
| 79 |
+
```
|
| 80 |
+
If these are not provided, the application will automatically use the built-in NLTK sentiment analyzer.
|
| 81 |
+
|
| 82 |
+
## How to Run
|
| 83 |
+
|
| 84 |
+
1. **Start the Flask Application**
|
| 85 |
+
```bash
|
| 86 |
+
python app.py
|
| 87 |
+
```
|
| 88 |
+
|
| 89 |
+
2. **Access the Web Interface**
|
| 90 |
+
- Open your web browser and navigate to `http://127.0.0.1:5000`.
|
| 91 |
+
- The AI will initialize in the background. Once ready, you can start chatting.
|
| 92 |
+
|
| 93 |
+
## API Endpoints
|
| 94 |
+
|
| 95 |
+
The application exposes the following endpoints:
|
| 96 |
+
|
| 97 |
+
- `GET /`: Serves the main chat interface.
|
| 98 |
+
- `POST /api/chat`: Handles chat messages and returns the AI's response.
|
| 99 |
+
- `GET /api/avatar`: Provides the current avatar shape, emotions, and sentiment for real-time frontend updates.
|
| 100 |
+
- `GET /status`: Reports the initialization status of the AI components.
|
| 101 |
+
- `GET /health`: A simple health check endpoint.
|