Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -140,21 +140,28 @@ def respond(message, history, chatbot_topic_values, chatbot_mode_values, user_id
|
|
| 140 |
topic_chunks = get_top_chunks(message, finance_embeddings, cleaned_finance)
|
| 141 |
|
| 142 |
csv_advice = get_advice(user_id)
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
messages = [{"role": "assistant", "content": role_message}]
|
| 159 |
if history:
|
| 160 |
messages.extend(history)
|
|
@@ -221,15 +228,13 @@ with gr.Blocks(
|
|
| 221 |
) as demo:
|
| 222 |
with gr.Row(scale=1):
|
| 223 |
chatbot_topic=gr.CheckboxGroup(["Helping Charities", "Financial Aid"], label="What would you like advice about?")
|
| 224 |
-
|
| 225 |
-
chatbot_mode=gr.CheckboxGroup(["General Advice", "Personal Advice"], label="How would you like the chatbot to respond?")
|
| 226 |
-
|
| 227 |
gr.ChatInterface(
|
| 228 |
-
fn=lambda msg, hist, topic_vals
|
| 229 |
title="Finance Management Hub",
|
| 230 |
description="Ask about your personal finance",
|
| 231 |
type="messages",
|
| 232 |
-
additional_inputs=[chatbot_topic
|
| 233 |
)
|
| 234 |
#launching chatbot
|
| 235 |
demo.launch()
|
|
|
|
| 140 |
topic_chunks = get_top_chunks(message, finance_embeddings, cleaned_finance)
|
| 141 |
|
| 142 |
csv_advice = get_advice(user_id)
|
| 143 |
+
|
| 144 |
+
role_message = (
|
| 145 |
+
"You are a helpful and insightful chatbot who acts like a financial "
|
| 146 |
+
"advisor for university students. DO NOT ask the user for additional input. "
|
| 147 |
+
f"Use the following spending data from the CSV file to provide advice: {csv_advice}. "
|
| 148 |
+
f"Also consider this context: {topic_chunks}"
|
| 149 |
+
|
| 150 |
+
)
|
| 151 |
+
#if chatbot_mode_values and "General Advice" in chatbot_mode_values:
|
| 152 |
+
# role_message = (
|
| 153 |
+
# "You are a helpful and insightful chatbot who acts like a financial "
|
| 154 |
+
# "advisor of a university student. Respond in under five bullet points, "
|
| 155 |
+
# f"under 500 characters, using this context: {topic_chunks}"
|
| 156 |
+
#)
|
| 157 |
+
#elif chatbot_mode_values and "Personal Advice" in chatbot_mode_values:
|
| 158 |
+
# role_message = (
|
| 159 |
+
# "You are a helpful and insightful chatbot who acts like a financial "
|
| 160 |
+
# "DO NOT ask the user for additional numbers or input"
|
| 161 |
+
# f"Use the following spending data from the CSV file to provide advice {csv_advice}"
|
| 162 |
+
#)
|
| 163 |
+
#else:
|
| 164 |
+
# role_message = f"You are a helpful chatbot. Use this context: {topic_chunks}"
|
| 165 |
messages = [{"role": "assistant", "content": role_message}]
|
| 166 |
if history:
|
| 167 |
messages.extend(history)
|
|
|
|
| 228 |
) as demo:
|
| 229 |
with gr.Row(scale=1):
|
| 230 |
chatbot_topic=gr.CheckboxGroup(["Helping Charities", "Financial Aid"], label="What would you like advice about?")
|
| 231 |
+
|
|
|
|
|
|
|
| 232 |
gr.ChatInterface(
|
| 233 |
+
fn=lambda msg, hist, topic_vals: respond(msg, hist, topic_vals),
|
| 234 |
title="Finance Management Hub",
|
| 235 |
description="Ask about your personal finance",
|
| 236 |
type="messages",
|
| 237 |
+
additional_inputs=[chatbot_topic]
|
| 238 |
)
|
| 239 |
#launching chatbot
|
| 240 |
demo.launch()
|