abdibrahem commited on
Commit
53125c7
·
1 Parent(s): 4ecff1b

Update the intent

Browse files
Files changed (1) hide show
  1. main.py +67 -25
main.py CHANGED
@@ -155,38 +155,80 @@ class HealthcareChatbot:
155
  self.json_parser = JsonOutputParser(pydantic_object=EndpointRequest)
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
 
 
155
  self.json_parser = JsonOutputParser(pydantic_object=EndpointRequest)
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
  self.intent_classifier_template = PromptTemplate(
191
+ template="""
192
+ You are an intent classifier. Your job is simple: understand what the user wants and check if any API endpoint can do that.
193
 
194
+ User Message: {user_query}
195
+ Language: {detected_language}
196
+ API Endpoints: {endpoints_documentation}
197
 
198
+ Think step by step:
199
 
200
+ 1. What does the user want from this message?
201
+ Read the user's message carefully. What is the user trying to say or accomplish? What would a human understand from this message?
202
 
203
+ 2. Can any API endpoint fulfill what the user wants?
204
+ 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.
205
 
206
+ Important rules:
207
+ - Focus ONLY on the current message, ignore conversation history for classification
208
+ - If the user is just talking, being social, or saying something casual, that's CONVERSATION
209
+ - Only choose API_ACTION if the user is clearly asking for something an API endpoint can do
210
+ - When you're not sure, choose CONVERSATION
211
+ - Your intent field MUST be exactly "API_ACTION" or "CONVERSATION" - nothing else
212
 
213
+ You MUST respond in exactly this JSON format (no other fields, no variations):
214
+ {{
215
+ "intent": "API_ACTION",
216
+ "confidence": 0.95,
217
+ "reasoning": "What does the user want? Can any API do this?",
218
+ "requires_backend": true
219
+ }}
220
+
221
+ OR
222
+
223
+ {{
224
+ "intent": "CONVERSATION",
225
+ "confidence": 0.85,
226
+ "reasoning": "What does the user want? Can any API do this?",
227
+ "requires_backend": false
228
+ }}
229
+ """,
230
+ input_variables=["user_query", "detected_language", "conversation_history", "endpoints_documentation"]
231
+ )
232
 
233
 
234