Philosopher Chatbot is an interactive web application that allows users to engage in conversations with simulations of famous historical philosophers in multiple languages (Spanish, English, and Catalan). The application uses the Anthropic API to generate responses based on the style and philosophical ideas of each thinker in the user's selected language.
- Features
- Technologies Used
- Installation
- Usage
- Project Structure
- API Endpoints
- Contributing
- License
- Contact
- Web-based user interface for easy interaction
- Multi-language support (Spanish, English, Catalan)
- Selection of historical philosophers
- Dynamic conversation using Anthropic's Claude API
- Personalized responses based on each philosopher's style and ideas
- Secure API key management
- Rate limiting to prevent abuse
- Python 3.6+
- Flask
- Flask-CORS
- Flask-Session
- Flask-Limiter
- Anthropic API
- Gunicorn (for production deployment)
- React 18.3.1
- TypeScript
- Axios for API requests
- Tailwind CSS for styling
-
Clone the repository:
git clone https://github.com/pma1999/philosopher_chatbot.git cd philosopher_chatbot
-
Set up the backend:
cd backend pip install -r requirements.txt
-
Set up the frontend:
cd ../frontend npm install
-
Configure the environment variables. You can do this by adding them to your development environment or by creating a .env file in the backend directory. Here is an example of what the .env file should look like:
ANTHROPIC_API_KEY=sk-ant-api03-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX SECRET_KEY=$(python -c "import secrets; print(secrets.token_urlsafe(32))")
-
Start the backend server:
cd backend python app.py
-
In a new terminal, start the frontend development server:
cd frontend npm start
-
Open your browser and navigate to
http://localhost:3000
-
Select your preferred language, enter your Anthropic API key, choose a philosopher, and start chatting!
philosopher_chatbot/
├── backend/
│ ├── app.py
│ ├── config.py
│ ├── philosophers.py
│ ├── translations.py
│ └── requirements.txt
├── frontend/
│ ├── public/
│ ├── src/
│ │ ├── components/
│ │ ├── contexts/
│ │ ├── services/
│ │ ├── App.tsx
│ │ └── index.tsx
│ ├── package.json
│ └── tsconfig.json
└── README.md
app.py
: Main Flask application with API endpointsconfig.py
: Configuration file for API keys and other settingsphilosophers.py
: Database of philosophers and their informationtranslations.py
: Translations for user interface text
components/
: React components for the user interfacecontexts/
: React context for managing application stateservices/
: API service for communicating with the backendApp.tsx
: Main application componentindex.tsx
: Entry point of the React application
GET /api/languages
: Get available languagesPOST /api/validate-api-key
: Validate the Anthropic API keyGET /api/philosophers
: Get list of available philosophersPOST /api/start-conversation
: Initialize a conversation with a philosopherPOST /api/send-message
: Send a message to the philosopher and get a response
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License. See the LICENSE file for details.
Pablo Miguel - [email protected]
Project Link: https://github.com/pma1999/philosopher_chatbot