Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
# Load the Zephyr-7B-Beta model pipeline
|
7 |
-
pipe = pipeline(
|
8 |
-
"text-generation",
|
9 |
-
model="HuggingFaceH4/zephyr-7b-beta",
|
10 |
-
torch_dtype=torch.bfloat16,
|
11 |
-
device_map="auto"
|
12 |
-
)
|
13 |
|
14 |
# Define the initial system message
|
15 |
system_message = {
|
@@ -40,11 +32,7 @@ def submit_questionnaire(name, age, location, gender, ethnicity, height, weight,
|
|
40 |
"Everyday Style": everyday_style
|
41 |
}
|
42 |
|
43 |
-
|
44 |
-
|
45 |
-
# Append to CSV file
|
46 |
-
df.to_csv("questionnaire_responses.csv", mode='a', header=not pd.io.common.file_exists("questionnaire_responses.csv"), index=False)
|
47 |
-
|
48 |
return "Thank you for completing the questionnaire!"
|
49 |
|
50 |
# Function to handle chat
|
@@ -53,16 +41,15 @@ def chat(user_input, messages):
|
|
53 |
# Append user message to the conversation history
|
54 |
messages.append({"role": "user", "content": user_input})
|
55 |
|
56 |
-
# Prepare
|
57 |
input_text = "\n".join([f"{msg['role']}: {msg['content']}" for msg in messages])
|
58 |
|
59 |
-
# Generate a response using the
|
60 |
try:
|
61 |
-
response =
|
62 |
-
|
63 |
-
#
|
64 |
-
|
65 |
-
|
66 |
# Store assistant response in the chat history
|
67 |
messages.append({"role": "assistant", "content": response_content})
|
68 |
|
@@ -74,7 +61,7 @@ def chat(user_input, messages):
|
|
74 |
|
75 |
# Gradio Interface
|
76 |
with gr.Blocks() as demo:
|
77 |
-
gr.Markdown("##
|
78 |
|
79 |
# Sidebar for user inputs
|
80 |
with gr.Row():
|
|
|
1 |
import gradio as gr
|
2 |
+
|
3 |
+
# Load the Qwen2.5-72B-Instruct model
|
4 |
+
model = gr.load("models/Qwen/Qwen2.5-72B-Instruct")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
# Define the initial system message
|
7 |
system_message = {
|
|
|
32 |
"Everyday Style": everyday_style
|
33 |
}
|
34 |
|
35 |
+
# Here you can add logic to save the data as required, e.g., in a CSV
|
|
|
|
|
|
|
|
|
36 |
return "Thank you for completing the questionnaire!"
|
37 |
|
38 |
# Function to handle chat
|
|
|
41 |
# Append user message to the conversation history
|
42 |
messages.append({"role": "user", "content": user_input})
|
43 |
|
44 |
+
# Prepare input for the model
|
45 |
input_text = "\n".join([f"{msg['role']}: {msg['content']}" for msg in messages])
|
46 |
|
47 |
+
# Generate a response using the Qwen model
|
48 |
try:
|
49 |
+
response = model(input_text) # Call the model directly
|
50 |
+
# Assuming the response is a list with one dictionary containing 'generated_text'
|
51 |
+
response_content = response[0]['generated_text'].strip() # Access the generated text
|
52 |
+
|
|
|
53 |
# Store assistant response in the chat history
|
54 |
messages.append({"role": "assistant", "content": response_content})
|
55 |
|
|
|
61 |
|
62 |
# Gradio Interface
|
63 |
with gr.Blocks() as demo:
|
64 |
+
gr.Markdown("## Fashion Assistant Chatbot")
|
65 |
|
66 |
# Sidebar for user inputs
|
67 |
with gr.Row():
|