This project is an AI-powered DBT (Dialectical Behavior Therapy) skill recommender that suggests appropriate DBT techniques based on user emotions. It leverages Google Gemini AI and FastAPI to analyze emotional input and provide structured DBT skill recommendations.
This project came close to my heart. I have been attending Dialectical Behavioural Therapy (DBT) therapy for years now and it has been life-saving for me. Over the last few months, I've taken some genai development courses here and there but I knew that if I wanted to really learn and understand it I needed to build something. One day, I brought up to my therapist that I would love something where I can just type in how I'm feeling and have an app recommend to me a skill.
This idea isn't unique — there are multiple DBT apps out there — but it's hard to find motivation to code outside of my day job. The only way I was going to be excited about it was if I built something that was near to my heart and touched on a topic that I cared about deeply.
- Tech Stack:
- Backend: FastAPI for handling API requests.
- Frontend: React with Tailwind CSS.
- AI: Google Gemini API for generating DBT skill recommendations.
- The DBT skills were initially stored in a PDF.
- Wrote a Python script to:
- Convert PDF text into Markdown format.
- Extract structured DBT skills, descriptions, and examples.
- Transform it into a JSON file for easier processing.
- Key Technologies: Python, Regex, JSON handling.
- Created a FastAPI server to handle requests from the frontend.
- Implemented a CORS middleware to allow frontend-backend communication.
- Created an API endpoint (
/suggest-skill
) that:- Accepts user emotions as input.
- Calls Google Gemini AI for DBT skill recommendations.
- Returns a DBT skill with an explanation.
- Used Pydantic for input validation.
- Integrated Google Gemini API securely using
.env
variables.
- Configured few-shot prompting to guide AI responses.
- Chose few-shot because it is fast and easy, but in the future I could incorporate LangChain to enhance the quality of the responses.
- Initial problems:
- AI hallucinated new DBT skills that don’t exist.
- AI returned only the skill name without an explanation.
- Fixes:
- Modified the prompt to explicitly ask for known DBT skills.
- Required AI to explain how to use the skill.
- Problem: The AI sometimes invented DBT skills that don’t exist.
- Solution: Modified the prompt to only allow existing DBT skills and strictly follow known techniques.
- Problem: The AI initially only returned skill names without an explanation.
- Solution: Reworded the prompt to force a structured response (e.g.,
1️⃣ Skill Name: 2️⃣ Explanation:
).
- Problem: AI struggled when multiple emotions were selected (e.g., "anger, anxiety, sadness").
- Solution: Reformatted user input to make it clearer for AI (e.g.,
I feel anger and sadness. The best DBT skill is:
).
{
"emotions": ["anger", "anxiety"],
"details": "I feel overwhelmed and unsure how to handle things."
}
{
"selected_emotions": ["anger", "anxiety"],
"suggested_skill": "STOP: Stop, Take a Step Back, Observe, and Proceed Mindfully. When you feel overwhelmed, stop what you are doing, take a moment to breathe, and assess the situation before reacting."
}
✅ Incorporate LangChain for more accurate and structured responses.
✅ Expand the DBT dataset to cover more techniques.
✅ Add a text box for user input to allow the user to input more detailed feelings.
If you have questions or feedback, reach out on LinkedIn or GitHub!
🚀 Built with ❤️ using FastAPI, React, and AI!