jacktol commited on
Commit
b31be1a
·
1 Parent(s): cfcd618

adjusted session management

Browse files
Files changed (1) hide show
  1. app.py +19 -19
app.py CHANGED
@@ -122,30 +122,30 @@ async def handle_message(message: cl.Message):
122
 
123
  @cl.on_chat_start
124
  async def handle_chat_start():
125
- welcome_message = """
126
-
127
- ## Welcome to the USDA Food Assistant!
128
-
129
- ---
130
 
131
- ### Platform Overview
132
 
133
- This platform is natively connected to the USDA's FoodData Central (FDC) Dataset, which includes comprehensive details about the ingredient and nutrient profiling of all foods available on US shelves. Whether you're looking for information on a specific branded food item or general ingedient, we've got the data you need to make informed choices.
134
 
135
- ---
136
 
137
- ### How It Works
138
 
139
- - **Step 1:** To begin, simply provide the name of the food item you're interested in.
140
- - **Step 2:** Once the food data is retrieved, you can ask more detailed questions regarding the nutrients, ingredients, or potential allergens specific to that food.
141
-
142
- **Note:** Nutrient values are provided per 100 grams of the edible portion of food. If you need serving size data, we can provide that as well, with clear explanations on how the nutrient values apply.
143
 
144
- Feel free to ask about any food or nutrient details, and we'll provide the most accurate information available!
 
 
 
145
 
146
- ---
147
 
148
- """
149
-
150
- msg = cl.Message(content=welcome_message)
151
- await msg.send()
 
 
122
 
123
  @cl.on_chat_start
124
  async def handle_chat_start():
125
+ message_history = cl.user_session.get("message_history", [])
126
+ if not message_history:
127
+ welcome_message = """
128
+ ## Welcome to the USDA Food Assistant!
 
129
 
130
+ ---
131
 
132
+ ### Platform Overview
133
 
134
+ This platform is natively connected to the USDA's FoodData Central (FDC) Dataset, which includes comprehensive details about the ingredient and nutrient profiling of all foods available on US shelves. Whether you're looking for information on a specific branded food item or general ingredient, we've got the data you need to make informed choices.
135
 
136
+ ---
137
 
138
+ ### How It Works
 
 
 
139
 
140
+ - **Step 1:** To begin, simply provide the name of the food item you're interested in.
141
+ - **Step 2:** Once the food data is retrieved, you can ask more detailed questions regarding the nutrients, ingredients, or potential allergens specific to that food.
142
+
143
+ **Note:** Nutrient values are provided per 100 grams of the edible portion of food. If you need serving size data, we can provide that as well, with clear explanations on how the nutrient values apply.
144
 
145
+ Feel free to ask about any food or nutrient details, and we'll provide the most accurate information available!
146
 
147
+ ---
148
+ """
149
+ msg = cl.Message(content=welcome_message)
150
+ await msg.send()
151
+ cl.user_session.set("message_history", message_history)