




AI Character Examples (more on Design page)

Image Prompting Example

Redesign Example
Favorite AI Characters

Duolingo

QKids English
Character API Design
Project Title: Character-Based Comedy API with Context-Aware Joke Generation
Description:
Developed a Python API to generate jokes based on character traits—Blind Spot, Flaw, Attitude, and Agenda—and dynamically place characters in ironic situations to maximize comedic impact. Leveraged prompt engineering techniques to ensure jokes remained consistent with each character’s voice and backstory.
Key Features:
-
Dynamic context selection for ironic humor.
-
Context-specific joke generation based on character flaws and blind spots.
-
Character consistency through trait-driven prompts.
Results:
-
Generated over 50 jokes with context-specific humor.
-
Enhanced character-driven storytelling and narrative depth.
API:
import random
# Define a character with key traits
queen = {
"name": "Queen Margaret",
"blind_spot": "Oblivious to her own privilege",
"flaw": "Neurotic and indecisive",
"attitude": "Overly polite but secretly manipulative",
"agenda": "Maintain power at all costs",
"catchphrases": ["Oh dear!", "Surely, you jest!"]
}
# Define potential ironic situations
situations = [
"at a funeral",
"during a peasant uprising",
"hosting a charity event for the poor",
"in disguise among the villagers",
"at a royal ball with foreign dignitaries",
"judging a pie-eating contest",
"leading a self-care seminar",
"giving a motivational speech to rebels"
]
# Function to pick the most ironic situation based on character traits
def get_ironic_situation(character):
# For example, if they're oblivious to their own privilege, place them among the poor
if character["blind_spot"] == "Oblivious to her own privilege":
return "hosting a charity event for the poor"
elif character["agenda"] == "Maintain power at all costs":
return "during a peasant uprising"
elif character["flaw"] == "Neurotic and indecisive":
return "judging a pie-eating contest"
else:
return random.choice(situations)
# Function to generate context-specific jokes
def generate_joke(character):
situation = get_ironic_situation(character)
if situation == "hosting a charity event for the poor":
return f"{character['name']} smiles nervously and says, '{character['catchphrases'][0]}—I do hope they don’t notice the diamond-encrusted donation box!'"
elif situation == "during a peasant uprising":
return f"{character['name']} clears her throat and declares, '{character['catchphrases'][1]} Can’t we settle this with a tea party instead?'"
elif situation == "judging a pie-eating contest":
return f"{character['name']} looks at the pies, bites her lip, and whispers, '{character['catchphrases'][0]}—Are any of these gluten-free?'"
elif situation == "at a funeral":
return f"{character['name']} whispers, '{character['catchphrases'][0]}—Do you think the casket clashes with the drapes?'"
else:
return f"{character['name']} nervously adjusts her crown and says, '{character['catchphrases'][0]} I wasn’t expecting this at all!'"
# Generate a joke based on the character and an ironic situation
joke = generate_joke(queen)
print("Ironic Situation:", get_ironic_situation(queen))
print("Generated Joke:", joke)
Example Output:
Ironic Situation: hosting a charity event for the poor
Generated Joke: Queen Margaret smiles nervously and says, 'Oh dear!—I do hope they don’t notice the diamond-encrusted donation box!'
Explanation: This is a Python-based API that doesn’t just store character traits but also generates ironic situations based on their blind spot, flaw, attitude, and agenda. For example, Queen Margaret, who is oblivious to her own privilege, might end up hosting a charity event for the poor. The API then generates jokes tailored to both the character’s traits and the situation, ensuring the humor feels natural and consistent. This approach aligns directly with the role’s focus on AI character consistency and prompt engineering.