Skip to content

dsubject/danis-dbt-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

🧠 DBT Skill Recommender

📌 Overview

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.


🚀 How I Built This App

1️⃣ Planning

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.

2️⃣ Extracting DBT Skills Data

  • 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.

3️⃣ Building the Backend (FastAPI)

  • 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.

4️⃣ Implementing AI (Few-Shot Learning with Gemini)

  • 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.

🛠 Challenges & How I Solved Them

1️⃣ AI Hallucination (Fake DBT Skills)

  • 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.

2️⃣ AI Giving Vague Responses

  • 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:).

3️⃣ Handling Multiple Emotions Correctly

  • 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:).

🔍 Example API Usage

POST /suggest-skill

Request Body:

{
  "emotions": ["anger", "anxiety"],
  "details": "I feel overwhelmed and unsure how to handle things."
}

Response:

{
  "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."
}

🚀 Future Enhancements

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.


📢 Contact

If you have questions or feedback, reach out on LinkedIn or GitHub!

🚀 Built with ❤️ using FastAPI, React, and AI!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published