Spaces:
Running
Running
change chat size and add response for sustainability
Browse files
app.py
CHANGED
|
@@ -38,12 +38,21 @@ with open("background/closet.png", "rb") as image_file:
|
|
| 38 |
encoded_string = base64.b64encode(image_file.read()).decode()
|
| 39 |
custom_css = f"""
|
| 40 |
.gradio-container {{
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
| 46 |
}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
"""
|
| 48 |
|
| 49 |
|
|
@@ -55,14 +64,17 @@ def response(message, history):
|
|
| 55 |
"nicht gut", "nicht schön", "grässlich", "furchtbar", "katastrophe"]
|
| 56 |
|
| 57 |
# Keywords indicating interest in new outfits
|
| 58 |
-
outfit_request_phrases = [
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
| 66 |
# Detect language (simple check for English or German based on keywords)
|
| 67 |
is_english = any(word in message.lower()
|
| 68 |
for word in ["outfit", "wear", "style", "buy", "new", "ugly"])
|
|
@@ -85,24 +97,34 @@ def response(message, history):
|
|
| 85 |
yield random.choice(uplifting_responses_en if is_english else uplifting_responses_de)
|
| 86 |
|
| 87 |
elif any(phrase in message.lower() for phrase in outfit_request_phrases):
|
| 88 |
-
if
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
else:
|
| 108 |
# Standard query engine response
|
|
|
|
| 38 |
encoded_string = base64.b64encode(image_file.read()).decode()
|
| 39 |
custom_css = f"""
|
| 40 |
.gradio-container {{
|
| 41 |
+
background: url("data:image/png;base64,{encoded_string}") !important;
|
| 42 |
+
background-size: cover !important;
|
| 43 |
+
background-position: center !important;
|
| 44 |
+
width: 100% !important;
|
| 45 |
+
height: 100vh !important; /* Full screen height */
|
| 46 |
+
display: flex;
|
| 47 |
+
flex-direction: column;
|
| 48 |
}}
|
| 49 |
+
|
| 50 |
+
#CHATBOT {{
|
| 51 |
+
flex-grow: 1; /* Ensures the chatbot grows to fill available space */
|
| 52 |
+
overflow-y: auto; /* Allows scrolling if content exceeds screen height */
|
| 53 |
+
}}
|
| 54 |
+
|
| 55 |
+
|
| 56 |
"""
|
| 57 |
|
| 58 |
|
|
|
|
| 64 |
"nicht gut", "nicht schön", "grässlich", "furchtbar", "katastrophe"]
|
| 65 |
|
| 66 |
# Keywords indicating interest in new outfits
|
| 67 |
+
outfit_request_phrases = [
|
| 68 |
+
"outfit", "empfehlung", "style", "anziehen", "kombination", "kleidung",
|
| 69 |
+
"modetipps", "styling", "look", "neu kombinieren", "outfit ideen", "kleiderideen",
|
| 70 |
+
"outfit ideas", "clothing suggestions", "style ideas", "fashion tips", "mix and match",
|
| 71 |
+
"wardrobe suggestions", "what to wear", "fashion styling"
|
| 72 |
+
]
|
| 73 |
+
buy_new_phrases = [
|
| 74 |
+
"neu kaufen", "buy new", "neues kaufen", "new outfit", "neue kleidung kaufen",
|
| 75 |
+
"kaufen", "shoppen", "shopping", "neue sachen kaufen", "mode kaufen", "neues kleidungsstück",
|
| 76 |
+
"neue mode", "buy clothes", "buy fashion", "new clothes", "shopping spree", "buy a new look"
|
| 77 |
+
]
|
| 78 |
# Detect language (simple check for English or German based on keywords)
|
| 79 |
is_english = any(word in message.lower()
|
| 80 |
for word in ["outfit", "wear", "style", "buy", "new", "ugly"])
|
|
|
|
| 97 |
yield random.choice(uplifting_responses_en if is_english else uplifting_responses_de)
|
| 98 |
|
| 99 |
elif any(phrase in message.lower() for phrase in outfit_request_phrases):
|
| 100 |
+
# Check if the user is requesting to buy new items
|
| 101 |
+
if any(phrase in message.lower() for phrase in buy_new_phrases):
|
| 102 |
+
# Proceed with suggesting new outfits
|
| 103 |
+
new_outfit_responses_de = [
|
| 104 |
+
"Verstehe, du möchtest also etwas Neues kaufen! Ich kann dir helfen, das perfekte Outfit zu finden. Was hast du im Kopf?",
|
| 105 |
+
"Wenn du etwas Neues kaufen möchtest, lass uns schauen, was aktuell im Trend ist. Ich helfe dir, das perfekte Teil zu finden!",
|
| 106 |
+
"Klar, neue Outfits sind immer spannend! Lass uns herausfinden, was du suchst und was zu deinem Stil passt."
|
| 107 |
+
]
|
| 108 |
+
new_outfit_responses_en = [
|
| 109 |
+
"Got it, you'd like to buy something new! I can help you find the perfect outfit. What do you have in mind?",
|
| 110 |
+
"If you're looking to buy something new, let's see what's trending. I'll help you find the perfect piece!",
|
| 111 |
+
"Sure, new outfits are always exciting! Let's figure out what you're looking for and what fits your style."
|
| 112 |
+
]
|
| 113 |
+
yield random.choice(new_outfit_responses_en if is_english else new_outfit_responses_de)
|
| 114 |
+
|
| 115 |
+
else:
|
| 116 |
+
# Ask the user about their current wardrobe
|
| 117 |
+
wardrobe_responses_de = [
|
| 118 |
+
"Bevor wir etwas Neues kaufen, was hast du bereits in deinem Kleiderschrank? Vielleicht können wir damit ein tolles Outfit zusammenstellen!",
|
| 119 |
+
"Ich schlag vor, wir schauen zuerst in deinem Kleiderschrank nach. Was hast du schon, mit dem wir etwas zusammenstellen können?",
|
| 120 |
+
"Es ist immer gut, zuerst zu schauen, was du schon hast. Hast du vielleicht ein Lieblingsstück, mit dem wir beginnen können?"
|
| 121 |
+
]
|
| 122 |
+
wardrobe_responses_en = [
|
| 123 |
+
"Before we buy anything new, what do you already have in your wardrobe? Maybe we can put together a great outfit with that!",
|
| 124 |
+
"I suggest we take a look at what you already have in your wardrobe first. What do you have that we can work with?",
|
| 125 |
+
"It's always good to check what you already own first. Do you have a favorite piece we could start with?"
|
| 126 |
+
]
|
| 127 |
+
yield random.choice(wardrobe_responses_en if is_english else wardrobe_responses_de)
|
| 128 |
|
| 129 |
else:
|
| 130 |
# Standard query engine response
|