Spaces:
Sleeping
Sleeping
Commit
·
5bc59c9
1
Parent(s):
53125c7
rolback
Browse files
main.py
CHANGED
@@ -155,80 +155,38 @@ 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 |
self.intent_classifier_template = PromptTemplate(
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
User Message: {user_query}
|
195 |
-
Language: {detected_language}
|
196 |
-
API Endpoints: {endpoints_documentation}
|
197 |
-
|
198 |
-
Think step by step:
|
199 |
|
200 |
-
|
201 |
-
|
|
|
202 |
|
203 |
-
|
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 |
-
|
207 |
-
|
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 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
222 |
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
|
|
232 |
|
233 |
|
234 |
|
|
|
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 |
|