Spaces:
Running
Running
Commit
·
ab198d6
1
Parent(s):
1f20eeb
Fix the intent issue
Browse files
main.py
CHANGED
@@ -156,55 +156,37 @@ class HealthcareChatbot:
|
|
156 |
|
157 |
# Intent classification prompt
|
158 |
self.intent_classifier_template = PromptTemplate(
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
- Scheduling, canceling, or managing appointments
|
191 |
-
- Requesting or viewing test results, prescriptions, or medical records
|
192 |
-
- Any interaction described in the API documentation
|
193 |
-
|
194 |
-
Choose **CONVERSATION** if the query:
|
195 |
-
- Is a greeting or casual message
|
196 |
-
- Asks about general health advice or medical definitions
|
197 |
-
- Mentions something unrelated to the provided API functionality
|
198 |
-
- Cannot be fulfilled by any described endpoint
|
199 |
-
|
200 |
-
=== IMPORTANT NOTE ===
|
201 |
-
DO NOT guess. Only return "API_ACTION" if the user message CLEARLY maps to a specific endpoint. Otherwise, return "CONVERSATION".
|
202 |
-
|
203 |
-
=== CLASSIFICATION START ===
|
204 |
-
Begin classification based on the above rules:
|
205 |
-
""",
|
206 |
-
input_variables=["user_query", "detected_language", "conversation_history", "endpoints_documentation"]
|
207 |
-
)
|
208 |
|
209 |
|
210 |
|
|
|
156 |
|
157 |
# Intent classification prompt
|
158 |
self.intent_classifier_template = PromptTemplate(
|
159 |
+
template="""
|
160 |
+
You are an intent classifier. Your job is simple: understand what the user wants and check if any API endpoint can do that.
|
161 |
+
|
162 |
+
User Message: {user_query}
|
163 |
+
Language: {detected_language}
|
164 |
+
API Endpoints: {endpoints_documentation}
|
165 |
+
|
166 |
+
Think step by step:
|
167 |
+
|
168 |
+
1. What does the user want from this message?
|
169 |
+
Read the user's message carefully. What is the user trying to say or accomplish? What would a human understand from this message?
|
170 |
+
|
171 |
+
2. Can any API endpoint fulfill what the user wants?
|
172 |
+
Look at each API endpoint. Does any endpoint do what the user is asking for? Be very precise - only say yes if there's a clear match.
|
173 |
+
|
174 |
+
Important rules:
|
175 |
+
- Focus ONLY on the current message, ignore conversation history for classification
|
176 |
+
- If the user is just talking, being social, or saying something casual, that's CONVERSATION
|
177 |
+
- Only choose API_ACTION if the user is clearly asking for something an API endpoint can do
|
178 |
+
- When you're not sure, choose CONVERSATION
|
179 |
+
|
180 |
+
Answer in this format:
|
181 |
+
{{
|
182 |
+
"intent": "API_ACTION" or "CONVERSATION",
|
183 |
+
"confidence": [0.0 to 1.0],
|
184 |
+
"reasoning": "What does the user want? Can any API do this?",
|
185 |
+
"requires_backend": true or false
|
186 |
+
}}
|
187 |
+
""",
|
188 |
+
input_variables=["user_query", "detected_language", "conversation_history", "endpoints_documentation"]
|
189 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
|
191 |
|
192 |
|