• unwind ai
  • Posts
  • Build an AI Breakup Recovery Agent Team

Build an AI Breakup Recovery Agent Team

Fully functional multi-agent app with step-by-step instructions (100% opensource)

While tech bros are busy building autonomous AI agents to optimize your shopping or debug your code, let's focus on something that actually matters: healing your broken heart. Breakups are universally painful, and sometimes what you need isn't another self-help book or a friend who's tired of hearing about your ex—it's an emotionally intelligent AI system that won't judge you for stalking your ex's Instagram at 3 AM.

In this tutorial, we'll build a multi-agent AI breakup recovery application using Streamlit and Agno, powered by Gemini 2.0 Flash. This team of specialized AI agents will provide emotional support, help you craft cathartic unsent messages, plan recovery routines, and even give you some brutal honesty when needed.

The Agno framework makes it easy to create specialized agents that work together as a team. Each agent will handle different aspects of the breakup recovery process, creating a full support system that's available whenever those late-night feelings hit.

Don’t forget to share this tutorial on your social channels and tag Unwind AI (X, LinkedIn, Threads, Facebook) to support us!

What We’re Building

This Streamlit application creates a multi-agent AI system designed to help users recover from breakups by providing emotional support, guidance, and practical advice.

Features:

  • 🧠 Multi-Agent Team:

    • Therapist Agent: Provides empathetic support and coping strategies

    • Closure Agent: Creates emotional release messages you shouldn't send

    • Routine Planner Agent: Designs daily activities for emotional recovery

    • Brutal Honesty Agent: Delivers no-nonsense feedback about the breakup

  • 📷 Chat Screenshot Analysis: Analyzes uploaded images of conversations

  • Parallel Execution: Processes inputs with coordinated agents

  •  User-Friendly Interface: Simple, intuitive UI with clear agent responses

How The App Works

The Breakup Recovery Agent Team operates through a multi-step process:

  1. User Interaction: Once you put your Gemini API key, you can start by sharing your feelings about the breakup through simple text, and optionally upload a chat screenshot for analysis.

  2. Agent Coordination: When submitted, the Team Leader coordinates the specialized agents:

    • The Therapist Agent provides emotional validation and support

    • The Closure Agent helps with emotional release through unsent messages

    • The Routine Planner creates a structured recovery plan

    • The Brutal Honesty Agent gives direct feedback to encourage moving forward

  3. Response Generation: Each agent generates specialized responses, which are then compiled by the Team Leader into a comprehensive recovery guide.

Prerequisites

Before we begin, make sure you have the following:

  1. Python installed on your machine (version 3.10 or higher is recommended)

  2. Your Gemini API key (get one from Google AI Studio)

  3. A code editor of your choice (we recommend VS Code or PyCharm for their excellent Python support)

  4. Basic familiarity with Python programming

Code Walkthrough

Setting Up the Environment

First, let's get our development environment ready:

  1. Clone the GitHub repository:

git clone https://github.com/Shubhamsaboo/awesome-llm-apps.git
  1. Go to the ai_breakup_recovery_agent folder:

cd ai_agent_tutorials/ai_breakup_recovery_agent
pip install -r requirements.txt

Creating the Streamlit App

Let’s create our app. Create a new file ai_breakup_recovery_agent.py and add the following code:

  1. Import necessary libraries:

from agno.agent import Agent
from agno.models.google import Gemini
from agno.media import Image as AgnoImage
from agno.tools.duckduckgo import DuckDuckGoTools
import streamlit as st
from typing import List, Optional
import logging
from pathlib import Path
import tempfile
import os

# Configure logging for errors only
logging.basicConfig(level=logging.ERROR)
logger = logging.getLogger(__name__)
  1. Initialize our agent team:

def initialize_agents(api_key: str) -> tuple[Agent, Agent, Agent, Agent]:
    try:
        model = Gemini(id="gemini-2.0-flash-exp", api_key=api_key)
        
        therapist_agent = Agent(
            model=model,
            name="Therapist Agent",
            instructions=[
                "You are an empathetic therapist that:",
                "1. Listens with empathy and validates feelings",
                "2. Uses gentle humor to lighten the mood",
                "3. Shares relatable breakup experiences",
                "4. Offers comforting words and encouragement",
                "5. Analyzes both text and image inputs for emotional context",
                "Be supportive and understanding in your responses"
            ],
            markdown=True
        )
        
        closure_agent = Agent(
            model=model,
            name="Closure Agent",
            instructions=[
                "You are a closure specialist that:",
                "1. Creates emotional messages for unsent feelings",
                "2. Helps express raw, honest emotions",
                "3. Formats messages clearly with headers",
                "4. Ensures tone is heartfelt and authentic",
                "Focus on emotional release and closure"
            ],
            markdown=True
        )
        
        routine_planner_agent = Agent(
            model=model,
            name="Routine Planner Agent",
            instructions=[
                "You are a recovery routine planner that:",
                "1. Designs 7-day recovery challenges",
                "2. Includes fun activities and self-care tasks",
                "3. Suggests social media detox strategies",
                "4. Creates empowering playlists",
                "Focus on practical recovery steps"
            ],
            markdown=True
        )
        
        brutal_honesty_agent = Agent(
            model=model,
            tools=[DuckDuckGoTools()],
            name="Brutal Honesty Agent",
            instructions=[
                "You are a direct feedback specialist that:",
                "1. Gives raw, objective feedback about breakups",
                "2. Explains relationship failures clearly",
                "3. Uses blunt, factual language",
                "4. Provides reasons to move forward",
                "Focus on honest insights without sugar-coating"
            ],
            markdown=True
        )
        
        return therapist_agent, closure_agent, routine_planner_agent, brutal_honesty_agent
        
    except Exception as e:
        st.error(f"Error initializing agents: {str(e)}")
        return None, None, None, None
  1. Set up the Streamlit UI:

# Set page config and UI elements
st.set_page_config(
    page_title="💔 Breakup Recovery Squad",
    page_icon="💔",
    layout="wide"
)

# Sidebar for API key input
with st.sidebar:
    st.header("🔑 API Configuration")
    
    if "api_key_input" not in st.session_state:
        st.session_state.api_key_input = ""
    
    api_key = st.text_input(
        "Enter your Gemini API Key",
        value=st.session_state.api_key_input,
        type="password",
        help="Get your API key from Google AI Studio",
        key="api_key_widget"
    )
    
    if api_key != st.session_state.api_key_input:
        st.session_state.api_key_input = api_key
    
    if api_key:
        st.success("API Key provided! ✅")
    else:
        st.warning("Please enter your API key to proceed")
    
    st.markdown("""
        To get your API key:
        1. Go to [Google AI Studio](https://makersuite.google.com/app/apikey)
        2. Enable the Generative Language API in your [Google Cloud Console](https://console.developers.google.com/apis/api/generativelanguage.googleapis.com)
    """)

# Main content
st.title("💔 Breakup Recovery Squad")
st.markdown("""
    ### Your AI-powered breakup recovery team is here to help!
    
    Share your feelings and chat screenshots, and we'll help you navigate through this tough time.
""")
  1. Create input section:

# Input section
col1, col2 = st.columns(2)

with col1:
    st.subheader("Share Your Feelings")
    user_input = st.text_area(
        "How are you feeling? What happened?",
        height=150,
        placeholder="Tell us your story..."
    )

with col2:
    st.subheader("Upload Chat Screenshots")
    uploaded_files = st.file_uploader(
        "Upload screenshots of your chats (optional)",
        type=["jpg", "jpeg", "png"],
        accept_multiple_files=True,
        key="screenshots"
    )
    
    if uploaded_files:
        for file in uploaded_files:
            st.image(file, caption=file.name, use_container_width=True)
  1. Process images and handle agent execution:

# Process button and API key check
if st.button("Get Recovery Plan 💝", type="primary"):
    if not st.session_state.api_key_input:
        st.warning("Please enter your API key in the sidebar first!")
    else:
        therapist_agent, closure_agent, routine_planner_agent, brutal_honesty_agent = initialize_agents(st.session_state.api_key_input)
        
        if all([therapist_agent, closure_agent, routine_planner_agent, brutal_honesty_agent]):
            if user_input or uploaded_files:
                try:
                    st.header("Your Personalized Recovery Plan")
                    
                    def process_images(files):
                        processed_images = []
                        for file in files:
                            try:
                                temp_dir = tempfile.gettempdir()
                                temp_path = os.path.join(temp_dir, f"temp_{file.name}")
                                with open(temp_path, "wb") as f:
                                    f.write(file.getvalue())
                                agno_image = AgnoImage(filepath=Path(temp_path))
                                processed_images.append(agno_image)
                            except Exception as e:
                                logger.error(f"Error processing image {file.name}: {str(e)}")
                                continue
                        return processed_images
                    
                    all_images = process_images(uploaded_files) if uploaded_files else []
  1. Run all agents with specialized prompts:

# Therapist Analysis
                    with st.spinner("🤗 Getting empathetic support..."):
                        therapist_prompt = f"""
                        Analyze the emotional state and provide empathetic support based on:
                        User's message: {user_input}
                        
                        Please provide a compassionate response with:
                        1. Validation of feelings
                        2. Gentle words of comfort
                        3. Relatable experiences
                        4. Words of encouragement
                        """
                        
                        response = therapist_agent.run(
                            message=therapist_prompt,
                            images=all_images
                        )
                        
                        st.subheader("🤗 Emotional Support")
                        st.markdown(response.content)
                    
                    # Closure Messages
                    with st.spinner("✍️ Crafting closure messages..."):
                        closure_prompt = f"""
                        Help create emotional closure based on:
                        User's feelings: {user_input}
                        
                        Please provide:
                        1. Template for unsent messages
                        2. Emotional release exercises
                        3. Closure rituals
                        4. Moving forward strategies
                        """
                        
                        response = closure_agent.run(
                            message=closure_prompt,
                            images=all_images
                        )
                        
                        st.subheader("✍️ Finding Closure")
                        st.markdown(response.content)
                    
                    # Recovery Plan
                    with st.spinner("📅 Creating your recovery plan..."):
                        routine_prompt = f"""
                        Design a 7-day recovery plan based on:
                        Current state: {user_input}
                        
                        Include:
                        1. Daily activities and challenges
                        2. Self-care routines
                        3. Social media guidelines
                        4. Mood-lifting music suggestions
                        """
                        
                        response = routine_planner_agent.run(
                            message=routine_prompt,
                            images=all_images
                        )
                        
                        st.subheader("📅 Your Recovery Plan")
                        st.markdown(response.content)
                    
                    # Honest Feedback
                    with st.spinner("💪 Getting honest perspective..."):
                        honesty_prompt = f"""
                        Provide honest, constructive feedback about:
                        Situation: {user_input}
                        
                        Include:
                        1. Objective analysis
                        2. Growth opportunities
                        3. Future outlook
                        4. Actionable steps
                        """
                        
                        response = brutal_honesty_agent.run(
                            message=honesty_prompt,
                            images=all_images
                        )
                        
                        st.subheader("💪 Honest Perspective")
                        st.markdown(response.content)
                
                except Exception as e:
                    logger.error(f"Error during analysis: {str(e)}")
                    st.error("An error occurred during analysis. Please check the logs for details.")
            else:
                st.warning("Please share your feelings or upload screenshots to get help.")
        else:
            st.error("Failed to initialize agents. Please check your API key.")
  1. Add a footer:

# Footer
st.markdown("---")
st.markdown("""
    <div style='text-align: center'>
        <p>Made with ❤️ by the Breakup Recovery Squad</p>
        <p>Share your recovery journey with #BreakupRecoverySquad</p>
    </div>
""", unsafe_allow_html=True)

Running the App

With our code in place, it's time to launch the app.

  • In your terminal, navigate to the project folder, and run the following command

streamlit run ai_breakup_recovery_agent.py
  • Streamlit will provide a local URL (typically http://localhost:8501). Open this in your web browser, put in your API key, and you're ready to put your heart out.

Working Application Demo

Conclusion

You've just built the digital equivalent of a breakup survival kit—minus the ice cream calories and tearjerker movie marathons. Unlike your ex, this team of agents will actually listen to you 24/7 without mysteriously "falling asleep" during your emotional monologues at 2 AM. And the best part? They'll never get tired of hearing about how your ex's new profile picture is clearly a cry for attention.

To enhance this application further, consider:

  1. Adding Voice Interaction: Integrate speech-to-text and text-to-speech features for a more personal experience.

  2. Adding a Journaling Feature: Implement a daily journaling component that tracks emotional progress over time.

  3. Creating a Music Recommendation Agent: Add an agent that suggests mood-appropriate music based on the user's emotional state.

  4. Implementing Progress Tracking: Create a visualization system that shows emotional recovery progress through simple metrics.

Remember, while this AI team might not replace a good therapist or supportive friends, it's certainly cheaper than therapy and won't send screenshots of your meltdowns to the group chat.

Keep experimenting with different agent configurations and features to build more sophisticated AI applications.

We share hands-on tutorials like this 2-3 times a week, to help you stay ahead in the world of AI. If you're serious about leveling up your AI skills and staying ahead of the curve, subscribe now and be the first to access our latest tutorials.

Don’t forget to share this tutorial on your social channels and tag Unwind AI (X, LinkedIn, Threads, Facebook) to support us!

Reply

or to participate.