Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,7 @@ client = Groq(api_key="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"
|
|
8 |
# Define the system message for the model
|
9 |
system_message = {
|
10 |
"role": "system",
|
11 |
-
"content": "You are an experienced
|
12 |
}
|
13 |
|
14 |
# Function to reset the chat
|
@@ -16,73 +16,15 @@ def reset_chat():
|
|
16 |
return [], "New Chat"
|
17 |
|
18 |
# Function to handle the questionnaire submission
|
19 |
-
def submit_questionnaire(name, age, location, gender,
|
20 |
-
|
21 |
-
preferred_prints, season_preference, outfit_priority,
|
22 |
-
experiment_with_trends, accessories, fit_preference,
|
23 |
-
material_preference, top_preference, bottom_preference,
|
24 |
-
outerwear_preference, footwear_preference, dress_frequency,
|
25 |
-
layering_preference, jeans_fit, formal_wear_frequency,
|
26 |
-
sportswear_preference, party_outfit, confidence_in_style,
|
27 |
-
follow_fashion_trends, look_for_inspiration,
|
28 |
-
wardrobe_satisfaction, unique_style, outfit_struggle,
|
29 |
-
fashion_preference, gender_neutral_clothing,
|
30 |
-
special_occasion_attire, trendsetter,
|
31 |
-
ai_usefulness, trust_in_ai, ai_preference,
|
32 |
-
ai_usage_frequency, ai_match_preferences,
|
33 |
-
ai_recommendation, ai_understanding_style,
|
34 |
-
more_personalized_recommendations, event_suggestions,
|
35 |
-
ai_improvements):
|
36 |
-
|
37 |
-
# Store questionnaire responses in a DataFrame
|
38 |
questionnaire_data = {
|
39 |
"Name": name,
|
40 |
"Age": age,
|
41 |
"Location": location,
|
42 |
"Gender": gender,
|
43 |
-
"Ethnicity": ethnicity,
|
44 |
"Height": height,
|
45 |
-
"Weight": weight
|
46 |
-
"Style Preference": style_preference,
|
47 |
-
"Color Palette": color_palette,
|
48 |
-
"Everyday Style": everyday_style,
|
49 |
-
"Preferred Prints": preferred_prints,
|
50 |
-
"Season Preference": season_preference,
|
51 |
-
"Outfit Priority": outfit_priority,
|
52 |
-
"Experiment with Trends": experiment_with_trends,
|
53 |
-
"Accessories": accessories,
|
54 |
-
"Fit Preference": fit_preference,
|
55 |
-
"Material Preference": material_preference,
|
56 |
-
"Top Preference": top_preference,
|
57 |
-
"Bottom Preference": bottom_preference,
|
58 |
-
"Outerwear Preference": outerwear_preference,
|
59 |
-
"Footwear Preference": footwear_preference,
|
60 |
-
"Dress Frequency": dress_frequency,
|
61 |
-
"Layering Preference": layering_preference,
|
62 |
-
"Jeans Fit": jeans_fit,
|
63 |
-
"Formal Wear Frequency": formal_wear_frequency,
|
64 |
-
"Sportswear Preference": sportswear_preference,
|
65 |
-
"Party Outfit": party_outfit,
|
66 |
-
"Confidence in Style": confidence_in_style,
|
67 |
-
"Follow Fashion Trends": follow_fashion_trends,
|
68 |
-
"Look for Inspiration": look_for_inspiration,
|
69 |
-
"Wardrobe Satisfaction": wardrobe_satisfaction,
|
70 |
-
"Unique Style": unique_style,
|
71 |
-
"Outfit Struggle": outfit_struggle,
|
72 |
-
"Fashion Preference": fashion_preference,
|
73 |
-
"Gender Neutral Clothing": gender_neutral_clothing,
|
74 |
-
"Special Occasion Attire": special_occasion_attire,
|
75 |
-
"Trendsetter": trendsetter,
|
76 |
-
"AI Usefulness": ai_usefulness,
|
77 |
-
"Trust in AI": trust_in_ai,
|
78 |
-
"AI Preference": ai_preference,
|
79 |
-
"AI Usage Frequency": ai_usage_frequency,
|
80 |
-
"AI Match Preferences": ai_match_preferences,
|
81 |
-
"AI Recommendation": ai_recommendation,
|
82 |
-
"AI Understanding Style": ai_understanding_style,
|
83 |
-
"More Personalized Recommendations": more_personalized_recommendations,
|
84 |
-
"Event Suggestions": event_suggestions,
|
85 |
-
"AI Improvements": ai_improvements
|
86 |
}
|
87 |
|
88 |
df = pd.DataFrame([questionnaire_data]) # Create DataFrame from dictionary
|
@@ -93,12 +35,12 @@ def submit_questionnaire(name, age, location, gender, ethnicity, height, weight,
|
|
93 |
return "Thank you for completing the questionnaire!"
|
94 |
|
95 |
# Function to handle chat
|
96 |
-
def chat(user_input, messages, name, age, location, gender,
|
97 |
if user_input:
|
98 |
# Create a user profile string
|
99 |
user_profile_string = (
|
100 |
f"User profile: Name: {name}, Age: {age}, Location: {location}, "
|
101 |
-
f"Gender: {gender},
|
102 |
)
|
103 |
|
104 |
# Prepare messages for the API call, including the profile and the conversation history
|
@@ -143,7 +85,6 @@ with gr.Blocks() as demo:
|
|
143 |
age = gr.Number(label="Age", value=25, minimum=1, maximum=100)
|
144 |
location = gr.Textbox(label="Location")
|
145 |
gender = gr.Radio(label="Gender", choices=["Male", "Female", "Other"])
|
146 |
-
ethnicity = gr.Radio(label="Ethnicity", choices=["Asian", "Black", "Hispanic", "White", "Other"])
|
147 |
height = gr.Number(label="Height (cm)", value=170, minimum=50, maximum=250)
|
148 |
weight = gr.Number(label="Weight (kg)", value=70, minimum=20, maximum=200)
|
149 |
|
@@ -151,76 +92,16 @@ with gr.Blocks() as demo:
|
|
151 |
submit_btn = gr.Button("Submit Questionnaire")
|
152 |
reset_btn = gr.Button("Reset Chat")
|
153 |
|
154 |
-
# Questionnaire responses
|
155 |
-
style_preference = gr.Radio(label="Which style do you prefer the most?", choices=["Casual", "Formal", "Streetwear", "Athleisure", "Baggy"])
|
156 |
-
color_palette = gr.Radio(label="What color palette do you wear often?", choices=["Neutrals", "Bright Colors", "Pastels", "Dark Shades"])
|
157 |
-
everyday_style = gr.Radio(label="How would you describe your everyday style?", choices=["Relaxed", "Trendy", "Elegant", "Bold"])
|
158 |
-
preferred_prints = gr.Radio(label="What type of prints do you like?", choices=["Solid", "Stripes", "Floral", "Geometric", "Animal Print"])
|
159 |
-
season_preference = gr.Radio(label="Which season influences your wardrobe the most?", choices=["Spring", "Summer", "Fall", "Winter"])
|
160 |
-
outfit_priority = gr.Radio(label="What do you prioritize when choosing an outfit?", choices=["Comfort", "Style", "Affordability", "Brand"])
|
161 |
-
experiment_with_trends = gr.Radio(label="How often do you experiment with new trends?", choices=["Always", "Sometimes", "Rarely", "Never"])
|
162 |
-
accessories = gr.Radio(label="What kind of accessories do you usually wear?", choices=["Watches", "Rings", "Necklaces", "Bracelets", "Earrings"])
|
163 |
-
fit_preference = gr.Radio(label="What fit do you prefer in clothes?", choices=["Loose", "Tailored", "Fitted", "Oversized"])
|
164 |
-
material_preference = gr.Radio(label="Which material do you prefer?", choices=["Cotton", "Linen", "Silk", "Denim", "Wool"])
|
165 |
-
|
166 |
-
# More preferences
|
167 |
-
top_preference = gr.Radio(label="Preferred Top Styles", choices=["T-shirts", "Shirts", "Sweaters", "Blouses"])
|
168 |
-
bottom_preference = gr.Radio(label="Preferred Bottom Styles", choices=["Jeans", "Shorts", "Skirts", "Trousers"])
|
169 |
-
outerwear_preference = gr.Radio(label="Preferred Outerwear", choices=["Jackets", "Coats", "Hoodies"])
|
170 |
-
footwear_preference = gr.Radio(label="Preferred Footwear", choices=["Sneakers", "Boots", "Sandals"])
|
171 |
-
dress_frequency = gr.Radio(label="How often do you wear dresses?", choices=["Daily", "Weekly", "Occasionally", "Rarely"])
|
172 |
-
layering_preference = gr.Radio(label="Do you like layering?", choices=["Yes", "No"])
|
173 |
-
jeans_fit = gr.Radio(label="Preferred Jeans Fit", choices=["Skinny", "Straight", "Baggy"])
|
174 |
-
formal_wear_frequency = gr.Radio(label="How often do you wear formal attire?", choices=["Daily", "Weekly", "Occasionally", "Rarely"])
|
175 |
-
sportswear_preference = gr.Radio(label="Preferred Sportswear Style", choices=["Athletic", "Casual", "Fashionable"])
|
176 |
-
party_outfit = gr.Radio(label="Preferred Outfit for Parties", choices=["Dresses", "Suits", "Casual Wear"])
|
177 |
-
confidence_in_style = gr.Radio(label="How confident do you feel in your style?", choices=["Very Confident", "Somewhat Confident", "Not Confident"])
|
178 |
-
follow_fashion_trends = gr.Radio(label="Do you follow fashion trends?", choices=["Always", "Sometimes", "Never"])
|
179 |
-
look_for_inspiration = gr.Radio(label="Where do you look for fashion inspiration?", choices=["Social Media", "Fashion Magazines", "Friends", "Other"])
|
180 |
-
wardrobe_satisfaction = gr.Radio(label="Are you satisfied with your wardrobe?", choices=["Yes", "No"])
|
181 |
-
unique_style = gr.Radio(label="Do you consider your style unique?", choices=["Yes", "No"])
|
182 |
-
outfit_struggle = gr.Radio(label="Do you struggle to put outfits together?", choices=["Yes", "No"])
|
183 |
-
fashion_preference = gr.Radio(label="What is your fashion preference?", choices=["Trendy", "Classic", "Bohemian", "Minimalist"])
|
184 |
-
gender_neutral_clothing = gr.Radio(label="Do you wear gender-neutral clothing?", choices=["Yes", "No"])
|
185 |
-
special_occasion_attire = gr.Radio(label="Do you have specific attire for special occasions?", choices=["Yes", "No"])
|
186 |
-
trendsetter = gr.Radio(label="Do you consider yourself a trendsetter?", choices=["Yes", "No"])
|
187 |
-
ai_usefulness = gr.Radio(label="How useful do you find AI in fashion?", choices=["Very Useful", "Somewhat Useful", "Not Useful"])
|
188 |
-
trust_in_ai = gr.Radio(label="Do you trust AI fashion recommendations?", choices=["Yes", "No"])
|
189 |
-
ai_preference = gr.Radio(label="Do you prefer AI recommendations?", choices=["Yes", "No"])
|
190 |
-
ai_usage_frequency = gr.Radio(label="How often do you use AI for fashion?", choices=["Daily", "Weekly", "Rarely", "Never"])
|
191 |
-
ai_match_preferences = gr.Radio(label="Does AI match your preferences?", choices=["Always", "Sometimes", "Rarely", "Never"])
|
192 |
-
ai_recommendation = gr.Radio(label="How satisfied are you with AI recommendations?", choices=["Very Satisfied", "Satisfied", "Dissatisfied"])
|
193 |
-
ai_understanding_style = gr.Radio(label="Does AI understand your style?", choices=["Very Well", "Somewhat", "Not Well"])
|
194 |
-
more_personalized_recommendations = gr.Radio(label="Do you want more personalized recommendations?", choices=["Yes", "No"])
|
195 |
-
event_suggestions = gr.Radio(label="Would you like event-specific suggestions?", choices=["Yes", "No"])
|
196 |
-
ai_improvements = gr.Radio(label="How can AI improve?", choices=["More Options", "Better Quality", "Faster Suggestions"])
|
197 |
-
|
198 |
# Chat functionality
|
199 |
chatbox = gr.Chatbot()
|
200 |
user_input = gr.Textbox(label="Your Message", placeholder="Type your message here...")
|
201 |
|
202 |
# Connect the buttons to their respective functions
|
203 |
output_message = gr.Textbox(label="Output Message") # Define an output component
|
204 |
-
submit_btn.click(submit_questionnaire, inputs=[name, age, location, gender,
|
205 |
-
style_preference, color_palette, everyday_style,
|
206 |
-
preferred_prints, season_preference, outfit_priority,
|
207 |
-
experiment_with_trends, accessories, fit_preference,
|
208 |
-
material_preference, top_preference, bottom_preference,
|
209 |
-
outerwear_preference, footwear_preference, dress_frequency,
|
210 |
-
layering_preference, jeans_fit, formal_wear_frequency,
|
211 |
-
sportswear_preference, party_outfit, confidence_in_style,
|
212 |
-
follow_fashion_trends, look_for_inspiration,
|
213 |
-
wardrobe_satisfaction, unique_style, outfit_struggle,
|
214 |
-
fashion_preference, gender_neutral_clothing,
|
215 |
-
special_occasion_attire, trendsetter,
|
216 |
-
ai_usefulness, trust_in_ai, ai_preference,
|
217 |
-
ai_usage_frequency, ai_match_preferences,
|
218 |
-
ai_recommendation, ai_understanding_style,
|
219 |
-
more_personalized_recommendations, event_suggestions,
|
220 |
-
ai_improvements], outputs=output_message)
|
221 |
|
222 |
reset_btn.click(reset_chat, outputs=[chatbox, "title"])
|
223 |
-
user_input.submit(chat, inputs=[user_input, chatbox, name, age, location, gender,
|
224 |
|
225 |
# Run the app
|
226 |
demo.launch()
|
|
|
8 |
# Define the system message for the model
|
9 |
system_message = {
|
10 |
"role": "system",
|
11 |
+
"content": "You are an experienced fashion designer. Start the conversation with a greeting, provide valuable fashion advice, and only ask questions if the user has concerns. Gather basic inputs: name, age, gender, location, height, and weight."
|
12 |
}
|
13 |
|
14 |
# Function to reset the chat
|
|
|
16 |
return [], "New Chat"
|
17 |
|
18 |
# Function to handle the questionnaire submission
|
19 |
+
def submit_questionnaire(name, age, location, gender, height, weight):
|
20 |
+
# Store basic responses in a DataFrame
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
questionnaire_data = {
|
22 |
"Name": name,
|
23 |
"Age": age,
|
24 |
"Location": location,
|
25 |
"Gender": gender,
|
|
|
26 |
"Height": height,
|
27 |
+
"Weight": weight
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
}
|
29 |
|
30 |
df = pd.DataFrame([questionnaire_data]) # Create DataFrame from dictionary
|
|
|
35 |
return "Thank you for completing the questionnaire!"
|
36 |
|
37 |
# Function to handle chat
|
38 |
+
def chat(user_input, messages, name, age, location, gender, height, weight):
|
39 |
if user_input:
|
40 |
# Create a user profile string
|
41 |
user_profile_string = (
|
42 |
f"User profile: Name: {name}, Age: {age}, Location: {location}, "
|
43 |
+
f"Gender: {gender}, Height: {height}, Weight: {weight}"
|
44 |
)
|
45 |
|
46 |
# Prepare messages for the API call, including the profile and the conversation history
|
|
|
85 |
age = gr.Number(label="Age", value=25, minimum=1, maximum=100)
|
86 |
location = gr.Textbox(label="Location")
|
87 |
gender = gr.Radio(label="Gender", choices=["Male", "Female", "Other"])
|
|
|
88 |
height = gr.Number(label="Height (cm)", value=170, minimum=50, maximum=250)
|
89 |
weight = gr.Number(label="Weight (kg)", value=70, minimum=20, maximum=200)
|
90 |
|
|
|
92 |
submit_btn = gr.Button("Submit Questionnaire")
|
93 |
reset_btn = gr.Button("Reset Chat")
|
94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
# Chat functionality
|
96 |
chatbox = gr.Chatbot()
|
97 |
user_input = gr.Textbox(label="Your Message", placeholder="Type your message here...")
|
98 |
|
99 |
# Connect the buttons to their respective functions
|
100 |
output_message = gr.Textbox(label="Output Message") # Define an output component
|
101 |
+
submit_btn.click(submit_questionnaire, inputs=[name, age, location, gender, height, weight], outputs=output_message)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
|
103 |
reset_btn.click(reset_chat, outputs=[chatbox, "title"])
|
104 |
+
user_input.submit(chat, inputs=[user_input, chatbox, name, age, location, gender, height, weight], outputs=[chatbox, user_input])
|
105 |
|
106 |
# Run the app
|
107 |
demo.launch()
|