Spaces:
Sleeping
Sleeping
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -8,39 +8,230 @@ app_file: app.py
|
|
| 8 |
pinned: false
|
| 9 |
suggested_hardware: cpu-basic
|
| 10 |
suggested_storage: small
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
-
# ChatCal.ai - AI-Powered Calendar Assistant
|
| 14 |
|
| 15 |
An intelligent AI scheduling assistant powered by Groq's Llama-3.1-8b-instant and LlamaIndex that helps users book appointments on Google Calendar with natural conversation and smart features.
|
| 16 |
|
| 17 |
-
##
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
##
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
-
##
|
| 33 |
|
|
|
|
| 34 |
```bash
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
SESSION_BACKEND=jwt
|
| 38 |
-
GOOGLE_CLIENT_ID=your_client_id.apps.googleusercontent.com
|
| 39 |
-
GOOGLE_CLIENT_SECRET=your_client_secret
|
| 40 |
-
GOOGLE_REFRESH_TOKEN=your_refresh_token
|
| 41 |
-
GOOGLE_CALENDAR_ID=pgits.job@gmail.com
|
| 42 |
```
|
| 43 |
|
| 44 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
-
|
|
|
|
| 8 |
pinned: false
|
| 9 |
suggested_hardware: cpu-basic
|
| 10 |
suggested_storage: small
|
| 11 |
+
startup_duration_timeout: 5m
|
| 12 |
---
|
| 13 |
|
| 14 |
+
# ChatCal.ai - AI-Powered Calendar Assistant
|
| 15 |
|
| 16 |
An intelligent AI scheduling assistant powered by Groq's Llama-3.1-8b-instant and LlamaIndex that helps users book appointments on Google Calendar with natural conversation and smart features.
|
| 17 |
|
| 18 |
+
## Features
|
| 19 |
|
| 20 |
+
- π€ **Groq-powered LLM**: Fast, efficient conversation using Llama-3.1-8b-instant
|
| 21 |
+
- π
**Smart Calendar Integration**: Seamless Google Calendar booking with conflict detection
|
| 22 |
+
- π§ **Conversation Memory**: Persistent context across multi-turn conversations
|
| 23 |
+
- π¨ **HTML-formatted Responses**: Rich, styled responses for better readability
|
| 24 |
+
- π **Custom Meeting IDs**: Human-readable meeting IDs (MMDD-HHMM-DURm format)
|
| 25 |
+
- ποΈ **Smart Cancellation**: Intelligent meeting matching with automatic email notifications
|
| 26 |
+
- π₯ **Google Meet Integration**: Automatic video conference setup for remote meetings
|
| 27 |
+
- π§ **Email Notifications**: Automated booking confirmations and cancellation notices
|
| 28 |
+
- π§ͺ **Testing Mode**: Configurable testing environment for development
|
| 29 |
+
- π **FastAPI Backend**: High-performance API with Redis session management
|
| 30 |
+
- π **Secure Authentication**: OAuth2 for Google Calendar access
|
| 31 |
+
- π **Timezone-aware**: Smart scheduling across time zones
|
| 32 |
|
| 33 |
+
## Prerequisites
|
| 34 |
|
| 35 |
+
- Python 3.11+
|
| 36 |
+
- Docker and Docker Compose
|
| 37 |
+
- Groq API key (primary LLM)
|
| 38 |
+
- Anthropic API key (optional fallback)
|
| 39 |
+
- Google Cloud Project with Calendar API enabled
|
| 40 |
+
- Google OAuth2 credentials
|
| 41 |
+
- SMTP credentials for email notifications
|
| 42 |
|
| 43 |
+
## Quick Start
|
| 44 |
|
| 45 |
+
### 1. Clone the repository
|
| 46 |
```bash
|
| 47 |
+
git clone <repository>
|
| 48 |
+
cd chatcal-ai
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
```
|
| 50 |
|
| 51 |
+
### 2. Set up environment variables
|
| 52 |
+
```bash
|
| 53 |
+
cp .env.example .env
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
Edit `.env` with your credentials:
|
| 57 |
+
- `GROQ_API_KEY`: Your Groq API key (primary)
|
| 58 |
+
- `ANTHROPIC_API_KEY`: Your Anthropic API key (optional fallback)
|
| 59 |
+
- `GOOGLE_CLIENT_ID` & `GOOGLE_CLIENT_SECRET`: From Google Cloud Console
|
| 60 |
+
- `SECRET_KEY`: Generate a secure secret key
|
| 61 |
+
- `MY_PHONE_NUMBER` & `MY_EMAIL_ADDRESS`: Contact information
|
| 62 |
+
- `SMTP_USERNAME` & `SMTP_PASSWORD`: Email service credentials
|
| 63 |
+
- `TESTING_MODE`: Set to true for development (ignores Peter's email validation)
|
| 64 |
+
|
| 65 |
+
### 3. Google Calendar Setup
|
| 66 |
+
|
| 67 |
+
1. Go to [Google Cloud Console](https://console.cloud.google.com)
|
| 68 |
+
2. Create a new project or select existing
|
| 69 |
+
3. Enable Google Calendar API:
|
| 70 |
+
- Navigate to "APIs & Services" > "Library"
|
| 71 |
+
- Search for "Google Calendar API"
|
| 72 |
+
- Click "Enable"
|
| 73 |
+
4. Create OAuth2 credentials:
|
| 74 |
+
- Go to "APIs & Services" > "Credentials"
|
| 75 |
+
- Click "Create Credentials" > "OAuth client ID"
|
| 76 |
+
- Choose "Web application"
|
| 77 |
+
- Add authorized redirect URIs:
|
| 78 |
+
- `http://localhost:8000/auth/callback`
|
| 79 |
+
- `https://yourdomain.com/auth/callback` (for production)
|
| 80 |
+
- Save and download the credentials
|
| 81 |
+
|
| 82 |
+
### 4. Run with Docker
|
| 83 |
+
|
| 84 |
+
```bash
|
| 85 |
+
# Build and start all services
|
| 86 |
+
docker-compose up -d
|
| 87 |
+
|
| 88 |
+
# View logs
|
| 89 |
+
docker-compose logs -f
|
| 90 |
+
|
| 91 |
+
# Stop services
|
| 92 |
+
docker-compose down
|
| 93 |
+
```
|
| 94 |
+
|
| 95 |
+
The application will be available at:
|
| 96 |
+
- API: http://localhost:8000
|
| 97 |
+
- API Docs: http://localhost:8000/docs
|
| 98 |
+
|
| 99 |
+
### 5. Development Setup (without Docker)
|
| 100 |
+
|
| 101 |
+
```bash
|
| 102 |
+
# Install Poetry
|
| 103 |
+
pip install poetry
|
| 104 |
+
|
| 105 |
+
# Install dependencies
|
| 106 |
+
poetry install
|
| 107 |
+
|
| 108 |
+
# Activate virtual environment
|
| 109 |
+
poetry shell
|
| 110 |
+
|
| 111 |
+
# Run the application
|
| 112 |
+
uvicorn app.api.main:app --reload
|
| 113 |
+
```
|
| 114 |
+
|
| 115 |
+
## Project Structure
|
| 116 |
+
|
| 117 |
+
```
|
| 118 |
+
chatcal-ai/
|
| 119 |
+
βββ app/
|
| 120 |
+
β βββ core/ # Agent, LLM (Groq), tools, and email service
|
| 121 |
+
β βββ calendar/ # Google Calendar integration
|
| 122 |
+
β βββ api/ # FastAPI endpoints (simple-chat, chat-widget)
|
| 123 |
+
β βββ personality/ # System prompts and response templates
|
| 124 |
+
βββ frontend/ # Web UI with HTML response rendering
|
| 125 |
+
βββ docker/ # Docker configurations
|
| 126 |
+
βββ tests/ # Test suite
|
| 127 |
+
βββ credentials/ # Google credentials (gitignored)
|
| 128 |
+
βββ docker-compose.yml
|
| 129 |
+
```
|
| 130 |
+
|
| 131 |
+
## API Endpoints
|
| 132 |
+
|
| 133 |
+
- `POST /chat` - Send a message to the chatbot (with HTML response support)
|
| 134 |
+
- `GET /simple-chat` - Simple chat interface for testing
|
| 135 |
+
- `GET /chat-widget` - Embeddable chat widget with HTML rendering
|
| 136 |
+
- `GET /health` - Health check endpoint
|
| 137 |
+
- `POST /sessions` - Create new session
|
| 138 |
+
- `GET /auth/login` - Initiate Google OAuth flow
|
| 139 |
+
- `GET /auth/callback` - OAuth callback handler
|
| 140 |
+
|
| 141 |
+
## Deployment
|
| 142 |
+
|
| 143 |
+
### Deploy to any platform with Docker:
|
| 144 |
+
|
| 145 |
+
1. Build the production image:
|
| 146 |
+
```bash
|
| 147 |
+
docker build -t chatcal-ai:latest .
|
| 148 |
+
```
|
| 149 |
+
|
| 150 |
+
2. Push to your container registry:
|
| 151 |
+
```bash
|
| 152 |
+
docker tag chatcal-ai:latest your-registry/chatcal-ai:latest
|
| 153 |
+
docker push your-registry/chatcal-ai:latest
|
| 154 |
+
```
|
| 155 |
+
|
| 156 |
+
3. Deploy using your platform's container service (ECS, GKE, Azure Container Instances, etc.)
|
| 157 |
+
|
| 158 |
+
### Embed in landing pages:
|
| 159 |
+
|
| 160 |
+
Add the chat widget to any webpage:
|
| 161 |
+
```html
|
| 162 |
+
<iframe
|
| 163 |
+
src="https://your-deployment.com/chat-widget"
|
| 164 |
+
width="400"
|
| 165 |
+
height="600"
|
| 166 |
+
frameborder="0">
|
| 167 |
+
</iframe>
|
| 168 |
+
```
|
| 169 |
+
|
| 170 |
+
## Key Features
|
| 171 |
+
|
| 172 |
+
### Conversation Memory
|
| 173 |
+
- Persistent conversation context using ChatMemoryBuffer
|
| 174 |
+
- Multi-turn dialog support for complex booking flows
|
| 175 |
+
- User information extraction and retention
|
| 176 |
+
|
| 177 |
+
### Smart Meeting Management
|
| 178 |
+
- **Custom Meeting IDs**: Format MMDD-HHMM-DURm (e.g., 0731-1400-60m)
|
| 179 |
+
- **Intelligent Cancellation**: Matches meetings by user name and date/time
|
| 180 |
+
- **Automatic Email Notifications**: Booking confirmations and cancellation notices
|
| 181 |
+
|
| 182 |
+
### HTML Response Formatting
|
| 183 |
+
- Rich, styled responses with proper formatting
|
| 184 |
+
- Color-coded status messages (confirmations, cancellations, errors)
|
| 185 |
+
- Easy-to-read meeting details and contact information
|
| 186 |
+
|
| 187 |
+
### Google Meet Integration
|
| 188 |
+
- Automatic detection of video meeting requests
|
| 189 |
+
- Google Meet link generation and embedding
|
| 190 |
+
- Support for both in-person and remote meetings
|
| 191 |
+
|
| 192 |
+
## Configuration
|
| 193 |
+
|
| 194 |
+
See `app/config.py` for all available settings. Key configurations:
|
| 195 |
+
|
| 196 |
+
- `MAX_CONVERSATION_HISTORY`: Number of messages to maintain in context
|
| 197 |
+
- `SESSION_TIMEOUT_MINUTES`: Session expiration time
|
| 198 |
+
- `DEFAULT_TIMEZONE`: Default timezone for appointments
|
| 199 |
+
- `TESTING_MODE`: Enable/disable testing features
|
| 200 |
+
|
| 201 |
+
## Testing
|
| 202 |
+
|
| 203 |
+
```bash
|
| 204 |
+
# Run tests
|
| 205 |
+
poetry run pytest
|
| 206 |
+
|
| 207 |
+
# Run with coverage
|
| 208 |
+
poetry run pytest --cov=app
|
| 209 |
+
|
| 210 |
+
# Run linting
|
| 211 |
+
poetry run black .
|
| 212 |
+
poetry run flake8
|
| 213 |
+
```
|
| 214 |
+
|
| 215 |
+
## Security Considerations
|
| 216 |
+
|
| 217 |
+
- Always use HTTPS in production
|
| 218 |
+
- Keep your API keys secure and never commit them
|
| 219 |
+
- Implement rate limiting for production deployments
|
| 220 |
+
- Use environment-specific configurations
|
| 221 |
+
- Regular security audits of dependencies
|
| 222 |
+
|
| 223 |
+
## Contributing
|
| 224 |
+
|
| 225 |
+
1. Fork the repository
|
| 226 |
+
2. Create a feature branch
|
| 227 |
+
3. Make your changes
|
| 228 |
+
4. Run tests and linting
|
| 229 |
+
5. Submit a pull request
|
| 230 |
+
|
| 231 |
+
## License
|
| 232 |
+
|
| 233 |
+
[Your chosen license]
|
| 234 |
+
|
| 235 |
+
## Support
|
| 236 |
|
| 237 |
+
For issues or questions, please open an issue on GitHub or contact pgits.job@gmail.com
|