codejedi commited on
Commit
df5a339
·
1 Parent(s): 315b403

Add Docker Hub deployment documentation and docker-compose configuration

Browse files
Files changed (3) hide show
  1. DOCKER.md +190 -0
  2. README.md +134 -22
  3. docker-compose.yml +30 -0
DOCKER.md ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Docker Deployment Guide
2
+
3
+ This guide explains how to deploy Digital Galatea using Docker.
4
+
5
+ ## Quick Start
6
+
7
+ ### Using Pre-built Image from Docker Hub
8
+
9
+ ```bash
10
+ docker run -d \
11
+ --name digital-galatea \
12
+ -p 7860:7860 \
13
+ -e DEEPSEEK_API_KEY=your_deepseek_api_key \
14
+ -e INFLECTION_AI_API_KEY=your_inflection_api_key \
15
+ codejedi/digital-galatea:latest
16
+ ```
17
+
18
+ ### Using Docker Compose
19
+
20
+ 1. Create a `.env` file with your API keys (see `.env.example`)
21
+ 2. Run:
22
+ ```bash
23
+ docker-compose up -d
24
+ ```
25
+
26
+ ## Building the Image
27
+
28
+ ### Build Locally
29
+
30
+ ```bash
31
+ docker build -t digital-galatea:latest .
32
+ ```
33
+
34
+ ### Build and Tag for Docker Hub
35
+
36
+ ```bash
37
+ docker build -t codejedi/digital-galatea:latest .
38
+ ```
39
+
40
+ ## Publishing to Docker Hub
41
+
42
+ 1. **Login to Docker Hub**
43
+ ```bash
44
+ docker login
45
+ ```
46
+
47
+ 2. **Tag the Image** (if not already tagged)
48
+ ```bash
49
+ docker tag digital-galatea:latest codejedi/digital-galatea:latest
50
+ ```
51
+
52
+ 3. **Push to Docker Hub**
53
+ ```bash
54
+ docker push codejedi/digital-galatea:latest
55
+ ```
56
+
57
+ 4. **Push with Version Tag** (optional)
58
+ ```bash
59
+ docker tag digital-galatea:latest codejedi/digital-galatea:v1.0.0
60
+ docker push codejedi/digital-galatea:v1.0.0
61
+ ```
62
+
63
+ ## Environment Variables
64
+
65
+ ### Required Variables
66
+
67
+ - `DEEPSEEK_API_KEY` - Your DeepSeek API key
68
+ - `INFLECTION_AI_API_KEY` - Your Inflection AI API key
69
+
70
+ ### Optional Variables
71
+
72
+ - `AZURE_TEXT_ANALYTICS_KEY` - Azure Text Analytics key
73
+ - `AZURE_TEXT_ANALYTICS_ENDPOINT` - Azure endpoint URL
74
+ - `ANU_QUANTUM_API_KEY` - Quantum randomness API key
75
+ - `PORT` - Server port (default: 7860)
76
+
77
+ ## Running the Container
78
+
79
+ ### Basic Run
80
+
81
+ ```bash
82
+ docker run -d \
83
+ --name digital-galatea \
84
+ -p 7860:7860 \
85
+ -e DEEPSEEK_API_KEY=your_key \
86
+ -e INFLECTION_AI_API_KEY=your_key \
87
+ codejedi/digital-galatea:latest
88
+ ```
89
+
90
+ ### With Environment File
91
+
92
+ ```bash
93
+ docker run -d \
94
+ --name digital-galatea \
95
+ -p 7860:7860 \
96
+ --env-file .env \
97
+ codejedi/digital-galatea:latest
98
+ ```
99
+
100
+ ### With Volume for Persistence
101
+
102
+ ```bash
103
+ docker run -d \
104
+ --name digital-galatea \
105
+ -p 7860:7860 \
106
+ -v $(pwd)/data:/app/data \
107
+ --env-file .env \
108
+ codejedi/digital-galatea:latest
109
+ ```
110
+
111
+ ## Container Management
112
+
113
+ ### View Logs
114
+
115
+ ```bash
116
+ docker logs digital-galatea
117
+ docker logs -f digital-galatea # Follow logs
118
+ ```
119
+
120
+ ### Stop Container
121
+
122
+ ```bash
123
+ docker stop digital-galatea
124
+ ```
125
+
126
+ ### Start Container
127
+
128
+ ```bash
129
+ docker start digital-galatea
130
+ ```
131
+
132
+ ### Remove Container
133
+
134
+ ```bash
135
+ docker rm digital-galatea
136
+ ```
137
+
138
+ ### Restart Container
139
+
140
+ ```bash
141
+ docker restart digital-galatea
142
+ ```
143
+
144
+ ## Health Checks
145
+
146
+ The container includes a health check endpoint. You can verify it's running:
147
+
148
+ ```bash
149
+ curl http://localhost:7860/health
150
+ ```
151
+
152
+ ## Troubleshooting
153
+
154
+ ### Container Won't Start
155
+
156
+ 1. Check logs: `docker logs digital-galatea`
157
+ 2. Verify environment variables are set correctly
158
+ 3. Ensure port 7860 is not already in use
159
+
160
+ ### API Errors
161
+
162
+ 1. Verify API keys are correct
163
+ 2. Check network connectivity
164
+ 3. Review application logs for specific error messages
165
+
166
+ ### NLTK Data Download
167
+
168
+ NLTK data is downloaded automatically on first container start. This may take a few minutes. Check logs to see progress.
169
+
170
+ ## Production Considerations
171
+
172
+ 1. **Use Environment Files**: Store sensitive keys in `.env` files (not in version control)
173
+ 2. **Resource Limits**: Set appropriate memory and CPU limits
174
+ 3. **Restart Policy**: Use `--restart unless-stopped` for automatic restarts
175
+ 4. **Health Checks**: Monitor the `/health` endpoint
176
+ 5. **Logging**: Configure log rotation and monitoring
177
+
178
+ Example production run:
179
+
180
+ ```bash
181
+ docker run -d \
182
+ --name digital-galatea \
183
+ --restart unless-stopped \
184
+ -p 7860:7860 \
185
+ --memory="2g" \
186
+ --cpus="2" \
187
+ --env-file .env \
188
+ codejedi/digital-galatea:latest
189
+ ```
190
+
README.md CHANGED
@@ -14,7 +14,7 @@ Digital Galatea is a conversational AI with a dynamic emotional model. It featur
14
 
15
  ## Features
16
 
17
- - **Conversational AI**: Powered by the Google Gemini API for natural and engaging conversations.
18
  - **Dynamic Emotional Model**: Simulates five core emotions: Joy, Sadness, Anger, Fear, and Curiosity.
19
  - **Responsive Avatar**: The AI's visual avatar changes its shape and facial expression based on its dominant emotion.
20
  - **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.
@@ -24,33 +24,130 @@ Digital Galatea is a conversational AI with a dynamic emotional model. It featur
24
 
25
  - **Backend**: Python, Flask
26
  - **AI & Machine Learning**:
27
- - Google Gemini API
 
28
  - Azure Cognitive Service for Language (Text Analytics)
29
  - NLTK (VADER)
30
  - **Frontend**: HTML, CSS, JavaScript
31
  - **Environment Management**: `python-dotenv`
32
 
33
- ## Required Setup for Hugging Face Spaces
34
 
35
- To run this app on Hugging Face Spaces, you need to set the following **Secret** in your Space settings:
36
 
37
- ### Required Secret
38
- 1. Go to your Space Settings → Repository secrets
39
- 2. Add the following secret:
40
- - **Name**: `GEMINI_API_KEY`
41
- - **Value**: Your Google Gemini API key from [Google AI Studio](https://ai.google.dev/)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
 
43
- ### Optional Secrets (for enhanced sentiment analysis)
44
- - `AZURE_TEXT_ANALYTICS_KEY`: Your Azure Text Analytics key
45
- - `AZURE_TEXT_ANALYTICS_ENDPOINT`: Your Azure Text Analytics endpoint
46
 
47
- If Azure credentials are not provided, the app will automatically use the built-in NLTK VADER sentiment analyzer.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
 
49
  ## Local Development
50
 
51
  1. **Clone the Repository**
52
  ```bash
53
- git clone <repository-url>
54
  cd Digital-Galatea
55
  ```
56
 
@@ -72,10 +169,7 @@ If Azure credentials are not provided, the app will automatically use the built-
72
 
73
  4. **Configure Environment Variables**
74
  - Copy `.env.example` to `.env`
75
- - Add your Google Gemini API key:
76
- ```properties
77
- GEMINI_API_KEY=your_gemini_api_key_here
78
- ```
79
 
80
  5. **Run the Application**
81
  ```bash
@@ -86,6 +180,22 @@ If Azure credentials are not provided, the app will automatically use the built-
86
  - Open your browser and navigate to `http://127.0.0.1:7860`
87
  - The AI will initialize in the background. Once ready, you can start chatting.
88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  ## API Endpoints
90
 
91
  The application exposes the following endpoints:
@@ -93,15 +203,16 @@ The application exposes the following endpoints:
93
  - `GET /`: Serves the main chat interface.
94
  - `POST /api/chat`: Handles chat messages and returns the AI's response.
95
  - `GET /api/avatar`: Provides the current avatar shape, emotions, and sentiment for real-time frontend updates.
 
96
  - `GET /status`: Reports the initialization status of the AI components.
97
  - `GET /health`: A simple health check endpoint.
98
 
99
  ## How It Works
100
 
101
  1. **User Input**: You type a message in the chat interface
102
- 2. **Sentiment Analysis**: The system analyzes the emotional tone of your message
103
  3. **Emotional Processing**: Galatea's emotional state is updated based on the conversation
104
- 4. **AI Response**: Google Gemini generates a contextual response that reflects Galatea's emotional state
105
  5. **Avatar Update**: The visual avatar changes shape and expression based on the dominant emotion:
106
  - **Circle** → High Joy (happy, positive state)
107
  - **Triangle** → High Sadness (melancholic state)
@@ -110,8 +221,9 @@ The application exposes the following endpoints:
110
  ## Credits
111
 
112
  This project demonstrates the integration of:
113
- - Google's Gemini API for conversational AI
114
- - NLTK and Azure for sentiment analysis
 
115
  - Real-time emotional modeling
116
  - Dynamic visual representation of AI state
117
 
 
14
 
15
  ## Features
16
 
17
+ - **Conversational AI**: Powered by DeepSeek and Inflection AI for natural and engaging conversations.
18
  - **Dynamic Emotional Model**: Simulates five core emotions: Joy, Sadness, Anger, Fear, and Curiosity.
19
  - **Responsive Avatar**: The AI's visual avatar changes its shape and facial expression based on its dominant emotion.
20
  - **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.
 
24
 
25
  - **Backend**: Python, Flask
26
  - **AI & Machine Learning**:
27
+ - DeepSeek API (Reasoning/Analysis)
28
+ - Inflection AI (Response Generation)
29
  - Azure Cognitive Service for Language (Text Analytics)
30
  - NLTK (VADER)
31
  - **Frontend**: HTML, CSS, JavaScript
32
  - **Environment Management**: `python-dotenv`
33
 
34
+ ## Quick Start with Docker Hub
35
 
36
+ The easiest way to run Digital Galatea is using the pre-built Docker image from Docker Hub:
37
 
38
+ ```bash
39
+ docker pull codejedi/digital-galatea:latest
40
+ docker run -d \
41
+ --name digital-galatea \
42
+ -p 7860:7860 \
43
+ -e DEEPSEEK_API_KEY=your_deepseek_api_key \
44
+ -e INFLECTION_AI_API_KEY=your_inflection_api_key \
45
+ -e AZURE_TEXT_ANALYTICS_KEY=your_azure_key \
46
+ -e AZURE_TEXT_ANALYTICS_ENDPOINT=https://your-resource.cognitiveservices.azure.com/ \
47
+ codejedi/digital-galatea:latest
48
+ ```
49
+
50
+ Or using docker-compose (see `docker-compose.yml`):
51
+
52
+ ```bash
53
+ docker-compose up -d
54
+ ```
55
+
56
+ Access the application at `http://localhost:7860`
57
+
58
+ ## Environment Variables
59
+
60
+ ### Required Environment Variables
61
+
62
+ These environment variables **must** be set for the application to function:
63
+
64
+ | Variable | Description | Where to Get It |
65
+ |----------|-------------|-----------------|
66
+ | `DEEPSEEK_API_KEY` | Your DeepSeek API key for reasoning and analysis | [DeepSeek Platform](https://platform.deepseek.com/) |
67
+ | `INFLECTION_AI_API_KEY` | Your Inflection AI API key for response generation | [Inflection AI](https://inflection.ai/) |
68
+
69
+ ### Optional Environment Variables
70
+
71
+ These environment variables enhance functionality but are not required:
72
+
73
+ | Variable | Description | Default Behavior |
74
+ |----------|-------------|------------------|
75
+ | `AZURE_TEXT_ANALYTICS_KEY` | Azure Text Analytics API key for enhanced sentiment analysis | Falls back to NLTK VADER if not provided |
76
+ | `AZURE_TEXT_ANALYTICS_ENDPOINT` | Azure Text Analytics endpoint URL | Required if `AZURE_TEXT_ANALYTICS_KEY` is set |
77
+ | `ANU_QUANTUM_API_KEY` | ANU Quantum Random Numbers API key | Uses pseudo-random numbers if not provided |
78
+ | `PORT` | Port number for the Flask server | Defaults to `7860` |
79
+
80
+ ### Environment Variable Examples
81
+
82
+ #### Using Docker Run
83
+
84
+ ```bash
85
+ docker run -d \
86
+ --name digital-galatea \
87
+ -p 7860:7860 \
88
+ -e DEEPSEEK_API_KEY=sk-your-deepseek-key \
89
+ -e INFLECTION_AI_API_KEY=your-inflection-key \
90
+ -e AZURE_TEXT_ANALYTICS_KEY=your-azure-key \
91
+ -e AZURE_TEXT_ANALYTICS_ENDPOINT=https://your-resource.cognitiveservices.azure.com/ \
92
+ codejedi/digital-galatea:latest
93
+ ```
94
+
95
+ #### Using Environment File
96
+
97
+ Create a `.env` file:
98
+
99
+ ```properties
100
+ # Required
101
+ DEEPSEEK_API_KEY=sk-your-deepseek-key
102
+ INFLECTION_AI_API_KEY=your-inflection-key
103
+
104
+ # Optional - Enhanced Sentiment Analysis
105
+ AZURE_TEXT_ANALYTICS_KEY=your-azure-key
106
+ AZURE_TEXT_ANALYTICS_ENDPOINT=https://your-resource.cognitiveservices.azure.com/
107
+
108
+ # Optional - Quantum Randomness
109
+ ANU_QUANTUM_API_KEY=your-quantum-key
110
 
111
+ # Optional - Port Configuration
112
+ PORT=7860
113
+ ```
114
 
115
+ Then run with:
116
+
117
+ ```bash
118
+ docker run -d --name digital-galatea -p 7860:7860 --env-file .env codejedi/digital-galatea:latest
119
+ ```
120
+
121
+ ## Docker Hub
122
+
123
+ The image is available on Docker Hub:
124
+
125
+ **Image**: `codejedi/digital-galatea:latest`
126
+
127
+ ```bash
128
+ docker pull codejedi/digital-galatea:latest
129
+ ```
130
+
131
+ ### Building and Pushing to Docker Hub
132
+
133
+ If you want to build and push your own version:
134
+
135
+ ```bash
136
+ # Build the image
137
+ docker build -t codejedi/digital-galatea:latest .
138
+
139
+ # Login to Docker Hub
140
+ docker login
141
+
142
+ # Push to Docker Hub
143
+ docker push codejedi/digital-galatea:latest
144
+ ```
145
 
146
  ## Local Development
147
 
148
  1. **Clone the Repository**
149
  ```bash
150
+ git clone https://github.com/codejedi-ai/Digital-Galatea.git
151
  cd Digital-Galatea
152
  ```
153
 
 
169
 
170
  4. **Configure Environment Variables**
171
  - Copy `.env.example` to `.env`
172
+ - Add your API keys (see Environment Variables section above)
 
 
 
173
 
174
  5. **Run the Application**
175
  ```bash
 
180
  - Open your browser and navigate to `http://127.0.0.1:7860`
181
  - The AI will initialize in the background. Once ready, you can start chatting.
182
 
183
+ ## Deployment Options
184
+
185
+ ### Heroku
186
+
187
+ The repository includes Heroku configuration files (`Procfile`, `app.json`, `runtime.txt`).
188
+
189
+ 1. Connect your GitHub repository to Heroku
190
+ 2. Set environment variables in Heroku dashboard
191
+ 3. Deploy automatically on push to main branch
192
+
193
+ ### Hugging Face Spaces
194
+
195
+ 1. Go to your Space Settings → Repository secrets
196
+ 2. Add the required secrets (see Environment Variables section)
197
+ 3. The app will build and deploy automatically
198
+
199
  ## API Endpoints
200
 
201
  The application exposes the following endpoints:
 
203
  - `GET /`: Serves the main chat interface.
204
  - `POST /api/chat`: Handles chat messages and returns the AI's response.
205
  - `GET /api/avatar`: Provides the current avatar shape, emotions, and sentiment for real-time frontend updates.
206
+ - `GET /api/is_initialized`: Check if the system is initialized and ready.
207
  - `GET /status`: Reports the initialization status of the AI components.
208
  - `GET /health`: A simple health check endpoint.
209
 
210
  ## How It Works
211
 
212
  1. **User Input**: You type a message in the chat interface
213
+ 2. **Sentiment Analysis**: The system analyzes the emotional tone of your message using Azure Text Analytics or NLTK VADER
214
  3. **Emotional Processing**: Galatea's emotional state is updated based on the conversation
215
+ 4. **AI Response**: DeepSeek analyzes the context, and Inflection AI generates a contextual response that reflects Galatea's emotional state
216
  5. **Avatar Update**: The visual avatar changes shape and expression based on the dominant emotion:
217
  - **Circle** → High Joy (happy, positive state)
218
  - **Triangle** → High Sadness (melancholic state)
 
221
  ## Credits
222
 
223
  This project demonstrates the integration of:
224
+ - DeepSeek API for reasoning and analysis
225
+ - Inflection AI for response generation
226
+ - Azure Text Analytics and NLTK for sentiment analysis
227
  - Real-time emotional modeling
228
  - Dynamic visual representation of AI state
229
 
docker-compose.yml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: '3.8'
2
+
3
+ services:
4
+ digital-galatea:
5
+ image: codejedi/digital-galatea:latest
6
+ container_name: digital-galatea
7
+ ports:
8
+ - "7860:7860"
9
+ environment:
10
+ # Required - DeepSeek API Key
11
+ - DEEPSEEK_API_KEY=${DEEPSEEK_API_KEY}
12
+ # Required - Inflection AI API Key
13
+ - INFLECTION_AI_API_KEY=${INFLECTION_AI_API_KEY}
14
+ # Optional - Azure Text Analytics
15
+ - AZURE_TEXT_ANALYTICS_KEY=${AZURE_TEXT_ANALYTICS_KEY:-}
16
+ - AZURE_TEXT_ANALYTICS_ENDPOINT=${AZURE_TEXT_ANALYTICS_ENDPOINT:-}
17
+ # Optional - Quantum API
18
+ - ANU_QUANTUM_API_KEY=${ANU_QUANTUM_API_KEY:-}
19
+ # Optional - Port (defaults to 7860)
20
+ - PORT=${PORT:-7860}
21
+ env_file:
22
+ - .env
23
+ restart: unless-stopped
24
+ healthcheck:
25
+ test: ["CMD", "curl", "-f", "http://localhost:7860/health"]
26
+ interval: 30s
27
+ timeout: 10s
28
+ retries: 3
29
+ start_period: 60s
30
+