EmpathyAI is a full-stack web application that provides AI-powered therapeutic conversations. Built with React (frontend) and Python FastAPI (backend), it offers a clean, intuitive interface for users to interact with an AI therapist powered by Groq's LLaMA model.
empathyai/
βββ backend/
β βββ __pycache__/
β βββ app.py # FastAPI application entry point
β βββ main.py # Core chatbot processing logic
β βββ README.md
β βββ requirements.txt # Python dependencies
β βββ template.py # Prompt template handling
β βββ tools.yaml # Configuration for AI tools
β βββ venv/ # Python virtual environment
β βββ yaml_utils.py # YAML utility functions
βββ frontend/
βββ eslint.config.js
βββ index.html
βββ node_modules/
βββ package-lock.json
βββ package.json
βββ pnpm-lock.yaml
βββ postcss.config.js
βββ public/
βββ src/
β βββ tailwind.config.js
β βββ tsconfig.app.json
β βββ tsconfig.json
β βββ tsconfig.node.json
βββ vite.config.ts
Main chat interface with AI therapist
Example therapeutic conversation
- Real-time AI Conversations: Engage in therapeutic conversations with an AI powered by Groq's LLaMA model
- Memory Management: The AI maintains conversation context with a configurable memory buffer
- Modern UI: Clean, responsive React interface with Tailwind CSS styling
- TypeScript Support: Full TypeScript implementation for better development experience
- Error Handling: Comprehensive error handling on both frontend and backend
- Conversation History: Messages are timestamped and stored during the session
- Node.js (v16 or higher)
- Python (v3.8 or higher)
- npm, yarn, or pnpm package manager
- Groq API Key
-
Navigate to the backend directory:
cd backend -
Create and activate a virtual environment:
python -m venv venv # On Windows venv\Scripts\activate # On macOS/Linux source venv/bin/activate
-
Install Python dependencies:
pip install -r requirements.txt
-
Set up environment variables: Create a
.envfile in the backend directory:GROQ_API_KEY=your_groq_api_key_here CHAT_MODEL_NAME=llama-3.3-70b-versatile
-
Configure tools (optional): Modify
tools.yamlto customize the AI's behavior and available tools.
-
Navigate to the frontend directory:
cd frontend -
Install dependencies:
# Using npm npm install # Using yarn yarn install # Using pnpm pnpm install
-
Make sure you're in the backend directory with the virtual environment activated:
cd backend source venv/bin/activate # On Windows: venv\Scripts\activate
-
Run the FastAPI server:
python app.py
The backend server will start on
http://localhost:8000
-
Open a new terminal and navigate to the frontend directory:
cd frontend -
Start the development server:
# Using npm npm run dev # Using yarn yarn dev # Using pnpm pnpm dev
The frontend application will be available at
http://localhost:5173(or another port if 5173 is occupied)
You can also test the chatbot logic directly from the command line:
cd backend
python main.pyThis will start a simple command-line interface where you can chat with the AI directly.
The backend provides the following API endpoints:
POST /chat- Send a message to the AI therapist- Request body:
{ "message": "your message here" } - Response:
{ "response": "AI response" }
- Request body:
- Model Selection: Change the
CHAT_MODEL_NAMEin your.envfile to use different Groq models - Memory Length: Modify
conversational_memory_lengthinmain.pyto adjust conversation context length - System Prompt: Update the
system_promptinmain.pyto change the AI's personality and role
- API Endpoint: Update the API service URL in
src/services/api.tsif your backend runs on a different port - Styling: Modify Tailwind classes in the React components to customize the UI
- React 18 with TypeScript
- Vite for fast development and building
- Tailwind CSS for styling
- Lucide React for icons
- Python with FastAPI
- LangChain for AI conversation management
- Groq as the LLM provider
- YAML for configuration management
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is open source and available under the MIT License.
- API Keys: Never commit your
.envfile or expose your Groq API keys - Development Only: This setup is configured for development. For production, ensure proper security measures, HTTPS, and environment-specific configurations
- Rate Limits: Be aware of Groq API rate limits and implement appropriate throttling if needed
- Backend won't start: Ensure your virtual environment is activated and all dependencies are installed
- Frontend can't connect to backend: Check that the backend is running on the expected port and CORS is properly configured
- API errors: Verify your Groq API key is valid and has sufficient credits
If you encounter any issues, please check the console logs (both browser and terminal) for detailed error messages and create an issue in the repository with the relevant error information.