Skip to content

A conversational AI chatbot for exploring thoughts and perspectives through structured dialogue. Built with Claude AI and Streamlit. Supports English/German languages with customizable communication styles. FOR TESTING AND EDUCATIONAL PURPOSES ONLY - not a replacement for professional mental health care.

License

Notifications You must be signed in to change notification settings

peterhaupt/mental-health-chatbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mental Health Chatbot

⚠️ IMPORTANT DISCLAIMER This application is for TESTING AND EDUCATIONAL PURPOSES ONLY. DO NOT use this chatbot for medical advice or treatment of any medical condition. If you are experiencing a mental health crisis or medical emergency, please contact emergency services or a qualified healthcare provider immediately.

A conversational AI chatbot designed to explore thoughts and perspectives through structured dialogue, built with Claude AI.

Overview

This mental health chatbot provides:

  • Multi-language support: English and German
  • Personalized interaction: Adaptable communication styles (formal/informal)
  • Structured conversation flow: Guided exploration of thoughts and beliefs
  • Clean interface: Simple, distraction-free chat experience

Key Features

  • Language selection (English/German)
  • Customizable communication style
  • Session-based conversation tracking
  • Built on Claude Sonnet 4.5 AI model

Important Limitations

This chatbot is:

  • NOT a replacement for professional mental health care
  • NOT suitable for crisis intervention or emergency situations
  • NOT intended for diagnosing or treating medical conditions
  • FOR TESTING and educational exploration only

If you need professional help, please contact:

  • Crisis hotline (US): 988 Suicide & Crisis Lifeline
  • Emergency services: 911 (US) or your local emergency number
  • Mental health professional: Therapist, counselor, or psychiatrist

Installation

Prerequisites

Setup

  1. Clone the repository:

    git clone https://github.com/yourusername/mental-health-chatbot.git
    cd mental-health-chatbot
  2. Install dependencies:

    pip install -r requirements.txt
  3. Configure your API key:

    Create a .env file in the project root:

    cp .env.example .env

    Edit .env and add your Anthropic API key:

    ANTHROPIC_API_KEY=your_api_key_here
    

Usage

Running the Application

  1. Start the app:

    streamlit run app.py
  2. Access the app in your browser (usually at http://localhost:8501)

  3. Select your language (English or German) from the sidebar

  4. Start chatting - The chatbot will:

    • Ask how you'd like to be addressed
    • Adapt to your preferred formality level
    • Guide you through a structured conversation

Interface Features

  • Language selection: Choose between English and German
  • Communication style:
    • German: Du (informal) or Sie (formal)
    • English: First name (informal) or Title + Last name (formal)
  • Session persistence: Conversation state maintained during your session
  • Reset option: Start a fresh conversation anytime

Project Structure

mental-health-chatbot/
├── app.py                    # Main Streamlit application
├── core/
│   ├── orchestrator.py      # Main conversation orchestrator
│   ├── state_manager.py     # Session state management
│   ├── llm_interface.py     # Claude API interface
│   ├── method_handler.py    # Method-specific handlers
│   ├── rule_engine.py       # Rule-based dimension tracking
│   └── config_loader.py     # Configuration loader
├── config/
│   ├── config_en.py         # English language configuration
│   └── config_de.py         # German language configuration
├── requirements.txt          # Python dependencies
├── .env.example             # API key template
├── LICENSE                  # MIT License
└── README.md                # This file

Configuration

API Key Management

Your API key should be stored in a .env file (see Setup above). Never commit your .env file to version control.

Customization

To modify the conversation experience:

  • Language prompts: Edit config/config_en.py (English) or config/config_de.py (German)
  • Conversation flow: Modify core/orchestrator.py and core/method_handler.py
  • UI appearance: Customize app.py

Technical Architecture

Component Overview

  • Orchestrator: Manages overall conversation flow and coordination
  • State Manager: Handles session state and conversation history
  • LLM Interface: Communicates with Claude API
  • Method Handler: Processes method-specific conversation logic
  • Rule Engine: Tracks conversation dimensions using rule-based approach
  • Config Loader: Manages language-specific configurations

Conversation Flow

The chatbot guides users through several structured phases:

  1. Introduction - Establish communication preferences
  2. Problem Capture - Understand the topic to explore
  3. Exploration - Ask clarifying questions
  4. Identify Thoughts - Examine specific beliefs or perspectives
  5. Behavioral Experiment - Design actions to test assumptions

AI Model

  • Model: Claude Sonnet 4.5 (Anthropic)
  • Approach: Two-layer architecture
    • Layer 1: Python-based control logic and validation
    • Layer 2: LLM-powered conversational responses

Troubleshooting

API Key Issues

Problem: API key not found or invalid

Solutions:

  • Ensure .env file exists in project root
  • Verify the file contains: ANTHROPIC_API_KEY=your_actual_key
  • Check for typos in the environment variable name
  • Verify your key at Anthropic Console
  • Confirm you have available API credits

Port Already in Use

streamlit run app.py --server.port 8502

Dependency Problems

pip install --upgrade -r requirements.txt

Application Won't Start

  1. Verify Python version: python --version (should be 3.8+)
  2. Check all dependencies are installed: pip list
  3. Review terminal error messages for specific issues

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Ethical Considerations

This project is intended for educational and research purposes. When working with mental health applications:

  • Always prioritize user safety and wellbeing
  • Be transparent about AI limitations
  • Never replace professional mental health care
  • Implement appropriate safeguards and disclaimers
  • Consider privacy and data protection carefully

Remember: This is a testing tool, not a medical device. Always seek professional help for mental health concerns.

About

A conversational AI chatbot for exploring thoughts and perspectives through structured dialogue. Built with Claude AI and Streamlit. Supports English/German languages with customizable communication styles. FOR TESTING AND EDUCATIONAL PURPOSES ONLY - not a replacement for professional mental health care.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages