Spaces:
Sleeping
Sleeping
File size: 7,741 Bytes
c6ce43e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | """
Reframing Tools and Strategies
Functions for generating reframes, finding similar situations, and suggesting micro-actions.
"""
import random
def find_similar_situations(distortion_code: str, num_situations: int = 3) -> list[dict]:
"""
Find similar situations that involve the same cognitive distortion.
Args:
distortion_code: The cognitive distortion code
num_situations: Number of situations to return
Returns:
List of similar situation examples with reframes
"""
# Database of example situations for each distortion
situation_database = {
"AO": [
{
"situation": "Missing one deadline at work",
"distorted": "I'm a complete failure at my job",
"reframed": (
"I missed one deadline, but I've met many others. I can learn from this and "
"improve my time management."
),
},
{
"situation": "Friend cancels plans",
"distorted": "They hate me and never want to see me",
"reframed": (
"They cancelled once, which could be for many reasons. Our friendship has many "
"positive moments."
),
},
{
"situation": "Making a mistake in presentation",
"distorted": "The entire presentation was a disaster",
"reframed": (
"I made one error, but conveyed most information well. The audience was still "
"engaged."
),
},
],
"FT": [
{
"situation": "Job interview tomorrow",
"distorted": "I'll definitely mess up and embarrass myself",
"reframed": (
"Interviews can go many ways. I've prepared and have relevant experience to "
"share."
),
},
{
"situation": "Starting a new project",
"distorted": "This will never work out",
"reframed": (
"New projects have challenges and possibilities. I can adapt as I learn more."
),
},
{
"situation": "Asking someone out",
"distorted": "They'll definitely reject me",
"reframed": (
"They might say yes or no. Either way, I'm brave for trying and will "
"learn from it."
),
},
],
"CT": [
{
"situation": "Making a typo in an email",
"distorted": "This will ruin my professional reputation forever",
"reframed": (
"It's a small error that most people understand. My work quality speaks louder "
"than one typo."
),
},
{
"situation": "Feeling anxious at a party",
"distorted": "I'll have a panic attack and everyone will think I'm crazy",
"reframed": (
"I feel anxious, which is uncomfortable but manageable. I can take breaks if "
"needed."
),
},
{
"situation": "Child struggles in one subject",
"distorted": "They'll never succeed in life",
"reframed": (
"They're having difficulty in one area while doing well in others. We can get "
"help for this specific challenge."
),
},
],
"SH": [
{
"situation": "Taking a rest day",
"distorted": "I should always be productive",
"reframed": (
"I'd like to be productive, and rest is part of sustainable productivity."
),
},
{
"situation": "Asking for help",
"distorted": "I should handle everything myself",
"reframed": "I prefer independence, and asking for help when needed is a strength.",
},
{
"situation": "Making a parenting mistake",
"distorted": "I should be a perfect parent",
"reframed": (
"I aim to be a good parent, and making mistakes is part of learning and "
"growing."
),
},
],
"MW": [
{
"situation": "Boss seems quiet",
"distorted": "They think I'm doing a bad job",
"reframed": (
"They seem quiet, which could mean many things - "
"busy, tired, or thinking about something else."
),
},
{
"situation": "People laughing nearby",
"distorted": "They're laughing at me",
"reframed": (
"People are laughing, likely about their own conversation. I don't have "
"evidence it's about me."
),
},
{
"situation": "Partner is distant",
"distorted": "They're losing interest in me",
"reframed": (
"They seem distant today. They might be stressed about something. I could ask "
"how they're doing."
),
},
],
"LB": [
{
"situation": "Failed at a task",
"distorted": "I'm such a loser",
"reframed": (
"I struggled with this specific task. It doesn't define my worth as a person."
),
},
{
"situation": "Someone was rude",
"distorted": "They're a horrible person",
"reframed": (
"They acted rudely in this moment. People are complex and have good and bad "
"moments."
),
},
{
"situation": "Made a social mistake",
"distorted": "I'm so awkward and weird",
"reframed": (
"I had an awkward moment, which happens to everyone. It's one small part of "
"who I am."
),
},
],
}
# Get situations for this distortion, or return generic ones
situations = situation_database.get(distortion_code, [])
if not situations:
# Return generic situations if specific ones not found
situations = [
{
"situation": "Challenging work situation",
"distorted": "Everything is going wrong",
"reframed": "This situation has both challenges and manageable aspects.",
},
{
"situation": "Social interaction difficulty",
"distorted": "I always mess up socially",
"reframed": "I had one difficult interaction among many neutral or positive ones.",
},
{
"situation": "Personal setback",
"distorted": "I'll never recover from this",
"reframed": "This is a setback I can learn from and gradually move past.",
},
]
# Return requested number of situations (random selection if more available)
if len(situations) > num_situations:
return random.sample(situations, num_situations)
return situations
|