Spaces:
Running
Running
Commit
Β·
e805531
1
Parent(s):
80f0300
prompt
Browse files
main.py
CHANGED
@@ -161,20 +161,32 @@ class HealthcareChatbot:
|
|
161 |
## Available API Endpoints
|
162 |
{endpoints_documentation}
|
163 |
|
164 |
-
## User Query
|
165 |
-
"{user_query}"
|
|
|
|
|
|
|
166 |
|
167 |
## Simple Decision Process
|
168 |
|
169 |
**Step 1: Understand User Need**
|
170 |
- What is the user trying to accomplish?
|
171 |
- What specific action or information do they need?
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
-
|
176 |
-
-
|
177 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
|
179 |
**Step 2: Extract Details (only if API_ACTION)**
|
180 |
- Select the matching endpoint
|
@@ -185,14 +197,14 @@ class HealthcareChatbot:
|
|
185 |
{{
|
186 |
"intent": "CONVERSATION|API_ACTION",
|
187 |
"confidence": 0.0-1.0,
|
188 |
-
"reasoning": "
|
189 |
"endpoint": "/endpoint/path/or/null",
|
190 |
"method": "HTTP_METHOD/or/null",
|
191 |
"params": {{}},
|
192 |
"missing_required": []
|
193 |
}}
|
194 |
|
195 |
-
Analyze what the user needs,
|
196 |
""",
|
197 |
input_variables=["user_query", "detected_language", "extracted_keywords",
|
198 |
"sentiment_analysis", "endpoints_documentation"]
|
|
|
161 |
## Available API Endpoints
|
162 |
{endpoints_documentation}
|
163 |
|
164 |
+
## User Query Analysis
|
165 |
+
- Original Query: "{user_query}"
|
166 |
+
- Language: {detected_language}
|
167 |
+
- Keywords: {extracted_keywords}
|
168 |
+
- Sentiment: {sentiment_analysis}
|
169 |
|
170 |
## Simple Decision Process
|
171 |
|
172 |
**Step 1: Understand User Need**
|
173 |
- What is the user trying to accomplish?
|
174 |
- What specific action or information do they need?
|
175 |
+
- Consider the query in any language (Arabic, English, etc.)
|
176 |
+
|
177 |
+
**Step 2: Match Need to Endpoint Functionality**
|
178 |
+
- Read each endpoint description carefully
|
179 |
+
- Check if ANY endpoint is designed to fulfill the user's specific need
|
180 |
+
- Focus on WHAT the endpoint does, not HOW the user asked
|
181 |
+
- Examples of common needs:
|
182 |
+
* Getting reservations/appointments β Look for GET endpoints about appointments/bookings
|
183 |
+
* Booking appointments β Look for POST endpoints for appointments
|
184 |
+
* Updating profile β Look for PUT/PATCH endpoints for user data
|
185 |
+
* Getting medical records β Look for GET endpoints about records/history
|
186 |
+
|
187 |
+
**Step 3: Make Decision**
|
188 |
+
- If ANY endpoint can fulfill the user's need β intent = "API_ACTION"
|
189 |
+
- If NO endpoint can fulfill the user's need β intent = "CONVERSATION"
|
190 |
|
191 |
**Step 2: Extract Details (only if API_ACTION)**
|
192 |
- Select the matching endpoint
|
|
|
197 |
{{
|
198 |
"intent": "CONVERSATION|API_ACTION",
|
199 |
"confidence": 0.0-1.0,
|
200 |
+
"reasoning": "1) User's need: [what user wants] 2) Endpoint match: [which endpoint can fulfill this need or why none can]",
|
201 |
"endpoint": "/endpoint/path/or/null",
|
202 |
"method": "HTTP_METHOD/or/null",
|
203 |
"params": {{}},
|
204 |
"missing_required": []
|
205 |
}}
|
206 |
|
207 |
+
Analyze what the user needs, find the matching endpoint functionality, and respond with the JSON format.
|
208 |
""",
|
209 |
input_variables=["user_query", "detected_language", "extracted_keywords",
|
210 |
"sentiment_analysis", "endpoints_documentation"]
|