ans123 commited on
Commit
5bb7226
·
verified ·
1 Parent(s): 3b371eb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -61
app.py CHANGED
@@ -13,7 +13,7 @@ system_message = {
13
 
14
  # Function to reset the chat
15
  def reset_chat():
16
- return [], "New Chat"
17
 
18
  # Function to handle the questionnaire submission
19
  def submit_questionnaire(name, age, location, gender, ethnicity, height, weight,
@@ -39,22 +39,6 @@ def submit_questionnaire(name, age, location, gender, ethnicity, height, weight,
39
 
40
  return "Thank you for completing the questionnaire!"
41
 
42
- # Function to collect responses to additional fashion-related questions
43
- def collect_questionnaire_responses(style_preference, color_palette, everyday_style):
44
- # Store additional responses in a DataFrame
45
- additional_data = {
46
- "Style Preference": style_preference,
47
- "Color Palette": color_palette,
48
- "Everyday Style": everyday_style
49
- }
50
-
51
- df = pd.DataFrame([additional_data]) # Create DataFrame from dictionary
52
-
53
- # Append to CSV file
54
- df.to_csv("additional_questionnaire_responses.csv", mode='a', header=not pd.io.common.file_exists("additional_questionnaire_responses.csv"), index=False)
55
-
56
- return "Thank you for answering the additional questions!"
57
-
58
  # Function to handle chat
59
  def chat(user_input, messages):
60
  if user_input:
@@ -89,7 +73,7 @@ def chat(user_input, messages):
89
 
90
  # Gradio Interface
91
  with gr.Blocks() as demo:
92
- gr.Markdown("## FRIDAY")
93
 
94
  # Sidebar for user inputs
95
  with gr.Row():
@@ -103,7 +87,7 @@ with gr.Blocks() as demo:
103
  weight = gr.Number(label="Weight (kg)", value=70, minimum=20, maximum=200)
104
 
105
  with gr.Column():
106
- submit_btn = gr.Button("Submit User Inputs")
107
  reset_btn = gr.Button("Reset Chat")
108
 
109
  # Questionnaire with fashion-related questions
@@ -111,54 +95,16 @@ with gr.Blocks() as demo:
111
  color_palette = gr.Radio(label="What color palette do you wear often?", choices=["Neutrals", "Bright Colors", "Pastels", "Dark Shades"])
112
  everyday_style = gr.Radio(label="How would you describe your everyday style?", choices=["Relaxed", "Trendy", "Elegant", "Bold"])
113
 
114
- # Additional fashion-related questions
115
- fashion_questions = [
116
- ("What do you prioritize when choosing an outfit?", ["Comfort", "Style", "Affordability", "Brand"]),
117
- ("How often do you experiment with new trends?", ["Always", "Sometimes", "Rarely", "Never"]),
118
- ("What kind of accessories do you usually wear?", ["Watches", "Rings", "Necklaces", "Bracelets", "Earrings"]),
119
- ("Do you follow fashion trends?", ["Always", "Sometimes", "Never"]),
120
- ("How satisfied are you with your wardrobe?", ["Yes", "No"]),
121
- ("Do you consider your style unique?", ["Yes", "No"]),
122
- ("How confident do you feel in your style?", ["Very Confident", "Somewhat Confident", "Not Confident"]),
123
- ("Where do you look for fashion inspiration?", ["Social Media", "Fashion Magazines", "Friends", "Other"]),
124
- ("Do you have specific attire for special occasions?", ["Yes", "No"]),
125
- ("Do you wear gender-neutral clothing?", ["Yes", "No"]),
126
- ("What influences your fashion choices the most?", ["Celebrities", "Social Media", "Friends", "Personal Preference"]),
127
- ("Do you enjoy shopping for clothes?", ["Yes", "No"]),
128
- ("How often do you declutter your wardrobe?", ["Regularly", "Occasionally", "Rarely"]),
129
- ("Do you have a favorite fashion brand?", ["Yes", "No"]),
130
- ("How do you feel about thrift shopping?", ["Love it", "Neutral", "Dislike it"]),
131
- ]
132
-
133
- # Create a separate button for the questionnaire
134
- fill_questionnaire_btn = gr.Button("Fill Additional Questionnaire")
135
-
136
- # Adding additional questions
137
- additional_responses = []
138
- for question, choices in fashion_questions:
139
- additional_responses.append(gr.Radio(label=question, choices=choices))
140
-
141
  # Chat functionality
142
  chatbox = gr.Chatbot(type='messages')
143
  user_input = gr.Textbox(label="Your Message", placeholder="Type your message here...")
144
 
145
  # Connect the buttons to their respective functions
146
- submit_btn.click(
147
- submit_questionnaire,
148
- inputs=[name, age, location, gender, ethnicity, height, weight,
149
- style_preference, color_palette, everyday_style],
150
- outputs=gr.Textbox(label="Submission Response")
151
- )
152
-
153
- fill_questionnaire_btn.click(
154
- collect_questionnaire_responses,
155
- inputs=[style_preference, color_palette, everyday_style],
156
- outputs=gr.Textbox(label="Additional Questions Response")
157
- )
158
-
159
- # Corrected reset button output
160
- reset_btn.click(reset_chat, outputs=[chatbox, "title"])
161
 
 
162
  user_input.submit(chat, inputs=[user_input, chatbox], outputs=[chatbox, user_input])
163
 
164
  # Run the app
 
13
 
14
  # Function to reset the chat
15
  def reset_chat():
16
+ return [], "New Chat" # Returns an empty chat history and a new title
17
 
18
  # Function to handle the questionnaire submission
19
  def submit_questionnaire(name, age, location, gender, ethnicity, height, weight,
 
39
 
40
  return "Thank you for completing the questionnaire!"
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  # Function to handle chat
43
  def chat(user_input, messages):
44
  if user_input:
 
73
 
74
  # Gradio Interface
75
  with gr.Blocks() as demo:
76
+ gr.Markdown("## Fashion Assistant Chatbot")
77
 
78
  # Sidebar for user inputs
79
  with gr.Row():
 
87
  weight = gr.Number(label="Weight (kg)", value=70, minimum=20, maximum=200)
88
 
89
  with gr.Column():
90
+ submit_btn = gr.Button("Submit Questionnaire")
91
  reset_btn = gr.Button("Reset Chat")
92
 
93
  # Questionnaire with fashion-related questions
 
95
  color_palette = gr.Radio(label="What color palette do you wear often?", choices=["Neutrals", "Bright Colors", "Pastels", "Dark Shades"])
96
  everyday_style = gr.Radio(label="How would you describe your everyday style?", choices=["Relaxed", "Trendy", "Elegant", "Bold"])
97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  # Chat functionality
99
  chatbox = gr.Chatbot(type='messages')
100
  user_input = gr.Textbox(label="Your Message", placeholder="Type your message here...")
101
 
102
  # Connect the buttons to their respective functions
103
+ output_message = gr.Textbox(label="Output Message") # Define an output component
104
+ submit_btn.click(submit_questionnaire, inputs=[name, age, location, gender, ethnicity, height, weight,
105
+ style_preference, color_palette, everyday_style], outputs=output_message)
 
 
 
 
 
 
 
 
 
 
 
 
106
 
107
+ reset_btn.click(reset_chat, outputs=[chatbox, output_message]) # Corrected outputs
108
  user_input.submit(chat, inputs=[user_input, chatbox], outputs=[chatbox, user_input])
109
 
110
  # Run the app