ohlunlacassi commited on
Commit
e27479e
·
verified ·
1 Parent(s): e6a9c0c

change chat size and add response for sustainability

Browse files
Files changed (1) hide show
  1. app.py +53 -31
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
- background: url("data:image/png;base64,{encoded_string}") !important;
42
- background-size: cover !important;
43
- background-position: center !important;
44
- max-width: 100% !important;
45
- height: auto !important;
 
 
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 = ["outfit", "empfehlung", "style", "anziehen"]
59
- buy_new_phrases = ["neu kaufen", "buy new", "neues kaufen", "new outfit"]
60
-
61
- # Session flag for asking gender
62
- if not hasattr(response, "awaiting_gender"):
63
- response.awaiting_gender = False
64
- response.last_query = ""
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 not response.awaiting_gender: # First time asking
89
- response.awaiting_gender = True
90
- response.last_query = message
91
- yield "Cool! For whom are you looking for an outfit? For a man, a woman, or diverse?" if is_english else "Cool! Für wen suchst du ein Outfit? Für einen Mann, eine Frau oder diverse?"
92
- else: # Gender already asked, now processing answer
93
- if "mann" in message.lower() or "man" in message.lower():
94
- gender = "Mann" if not is_english else "man"
95
- elif "frau" in message.lower() or "woman" in message.lower():
96
- gender = "Frau" if not is_english else "woman"
97
- elif "diverse" in message.lower():
98
- gender = "diverse"
99
- else:
100
- yield "I didn’t quite understand. Please say 'man', 'woman', or 'diverse'." if is_english else "Ich habe dich nicht ganz verstanden. Bitte sag 'Mann', 'Frau' oder 'diverse'."
101
- return
102
-
103
- # Reset flag and give a response
104
- response.awaiting_gender = False
105
- yield f"Got it! I'll look for great outfit ideas for {gender}. Let's get started!" if is_english else f"Alles klar! Ich suche jetzt nach tollen Outfit-Ideen für {gender}. Lass uns starten!"
 
 
 
 
 
 
 
 
 
 
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