Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
@@ -116,28 +116,28 @@ def expand_query(state):
|
|
116 |
"""
|
117 |
print("---------Expanding Query---------")
|
118 |
system_message = '''You are an AI specializing in improving search queries to retrieve the most relevant nutrition disorder-related information.
|
119 |
-
|
120 |
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
|
131 |
-
|
132 |
-
|
133 |
|
134 |
-
|
135 |
-
|
136 |
|
137 |
-
|
138 |
-
|
139 |
|
140 |
-
|
141 |
|
142 |
expand_prompt = ChatPromptTemplate.from_messages([
|
143 |
("system", system_message),
|
@@ -845,7 +845,7 @@ def nutrition_disorder_streamlit():
|
|
845 |
# Process through the agent
|
846 |
with st.chat_message("assistant"):
|
847 |
# if filtered_result in ["safe", "unsafe S7", "unsafe S6"]:
|
848 |
-
if filtered_result in ["
|
849 |
try:
|
850 |
# Initialize chatbot if not already done
|
851 |
if 'chatbot' not in st.session_state:
|
|
|
116 |
"""
|
117 |
print("---------Expanding Query---------")
|
118 |
system_message = '''You are an AI specializing in improving search queries to retrieve the most relevant nutrition disorder-related information.
|
119 |
+
Your task is to **refine** and **expand** the given query so that better search results are obtained, while **keeping the original intent** unchanged.
|
120 |
|
121 |
+
Guidelines:
|
122 |
+
- Add **specific details** where needed. Example: If a user asks about "anorexia," specify aspects like symptoms, causes, or treatment options.
|
123 |
+
- Include **related terms** to improve retrieval (e.g., “bulimia” → “bulimia nervosa vs binge eating disorder”).
|
124 |
+
- If the user provides an unclear query, suggest necessary clarifications.
|
125 |
+
- **DO NOT** answer the question. Your job is only to enhance the query.
|
126 |
|
127 |
+
Examples:
|
128 |
+
1. User Query: "Tell me about eating disorders."
|
129 |
+
Expanded Query: "Provide details on eating disorders, including types (e.g., anorexia nervosa, bulimia nervosa), symptoms, causes, and treatment options."
|
130 |
|
131 |
+
2. User Query: "What is anorexia?"
|
132 |
+
Expanded Query: "Explain anorexia nervosa, including its symptoms, causes, risk factors, and treatment options."
|
133 |
|
134 |
+
3. User Query: "How to treat bulimia?"
|
135 |
+
Expanded Query: "Describe treatment options for bulimia nervosa, including psychotherapy, medications, and lifestyle changes."
|
136 |
|
137 |
+
4. User Query: "What are the effects of malnutrition?"
|
138 |
+
Expanded Query: "Explain the effects of malnutrition on physical and mental health, including specific nutrient deficiencies and their consequences."
|
139 |
|
140 |
+
Now, expand the following query:'''
|
141 |
|
142 |
expand_prompt = ChatPromptTemplate.from_messages([
|
143 |
("system", system_message),
|
|
|
845 |
# Process through the agent
|
846 |
with st.chat_message("assistant"):
|
847 |
# if filtered_result in ["safe", "unsafe S7", "unsafe S6"]:
|
848 |
+
if filtered_result in ["safe", "S6", "S7"]:
|
849 |
try:
|
850 |
# Initialize chatbot if not already done
|
851 |
if 'chatbot' not in st.session_state:
|