Update app.py
Browse files
app.py
CHANGED
@@ -25,22 +25,25 @@ def reset_chat():
|
|
25 |
# Function to handle questionnaire submission
|
26 |
def submit_questionnaire(name, age, location, gender, ethnicity, height, weight,
|
27 |
style_preference, color_palette, everyday_style):
|
28 |
-
# Store questionnaire responses
|
29 |
-
#
|
30 |
return "Thank you for completing the questionnaire!"
|
31 |
|
32 |
# Function to handle chat
|
33 |
-
def chat(user_input
|
|
|
34 |
if user_input:
|
35 |
# Append user message to the conversation history
|
36 |
messages.append({"role": "user", "content": user_input})
|
37 |
|
38 |
# Prepare input for the model
|
39 |
-
|
|
|
|
|
40 |
|
41 |
# Generate a response using the model
|
42 |
try:
|
43 |
-
response = pipe(
|
44 |
|
45 |
# Check if response is valid and structured correctly
|
46 |
if isinstance(response, list) and len(response) > 0:
|
@@ -91,7 +94,7 @@ with gr.Blocks() as demo:
|
|
91 |
style_preference, color_palette, everyday_style], outputs=output_message)
|
92 |
|
93 |
reset_btn.click(reset_chat, outputs=[chatbox, output_message]) # Corrected outputs
|
94 |
-
user_input.submit(chat, inputs=
|
95 |
|
96 |
# Run the app
|
97 |
demo.launch()
|
|
|
25 |
# Function to handle questionnaire submission
|
26 |
def submit_questionnaire(name, age, location, gender, ethnicity, height, weight,
|
27 |
style_preference, color_palette, everyday_style):
|
28 |
+
# Store questionnaire responses as needed
|
29 |
+
# Placeholder logic for storing responses
|
30 |
return "Thank you for completing the questionnaire!"
|
31 |
|
32 |
# Function to handle chat
|
33 |
+
def chat(user_input):
|
34 |
+
global messages
|
35 |
if user_input:
|
36 |
# Append user message to the conversation history
|
37 |
messages.append({"role": "user", "content": user_input})
|
38 |
|
39 |
# Prepare input for the model
|
40 |
+
chat_input = "The assistant is a fashion designer. Respond to the user based on the following messages:\n"
|
41 |
+
for msg in messages:
|
42 |
+
chat_input += f"{msg['role']}: {msg['content']}\n"
|
43 |
|
44 |
# Generate a response using the model
|
45 |
try:
|
46 |
+
response = pipe(chat_input, max_new_tokens=256) # Using the pipeline
|
47 |
|
48 |
# Check if response is valid and structured correctly
|
49 |
if isinstance(response, list) and len(response) > 0:
|
|
|
94 |
style_preference, color_palette, everyday_style], outputs=output_message)
|
95 |
|
96 |
reset_btn.click(reset_chat, outputs=[chatbox, output_message]) # Corrected outputs
|
97 |
+
user_input.submit(chat, inputs=user_input, outputs=[chatbox, user_input])
|
98 |
|
99 |
# Run the app
|
100 |
demo.launch()
|