Spaces:
Running
Running
adjusted session management
Browse files
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 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
---
|
130 |
|
131 |
-
|
132 |
|
133 |
-
|
134 |
|
135 |
-
|
136 |
|
137 |
-
|
138 |
|
139 |
-
|
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 |
-
|
|
|
|
|
|
|
145 |
|
146 |
-
|
147 |
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
|
|
|
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)
|