Spaces:
Sleeping
Sleeping
Refine entity filtering and update prompt instructions.
Browse filesEnhanced entity filtering logic to focus on specific fields (age, location, postalCode) when no possible matches are found. Updated prompts to include "location" in user descriptions to improve clarity and context.
trauma/api/message/ai/engine.py
CHANGED
@@ -62,6 +62,8 @@ async def search_entities(
|
|
62 |
filter_entities_by_age_location(entity_data),
|
63 |
generate_search_request(user_messages_str, entity_data)
|
64 |
)
|
|
|
|
|
65 |
final_entities = await search_semantic_entities(search_request, entity_data, possible_entity_indexes)
|
66 |
final_entities_str = prepare_final_entities_str(final_entities)
|
67 |
if final_entities:
|
|
|
62 |
filter_entities_by_age_location(entity_data),
|
63 |
generate_search_request(user_messages_str, entity_data)
|
64 |
)
|
65 |
+
if not possible_entity_indexes and fields_changed_inst:
|
66 |
+
fields_changed_inst = {k: v for k, v in fields_changed_inst.items() if k in {'age', 'location', 'postalCode'}}
|
67 |
final_entities = await search_semantic_entities(search_request, entity_data, possible_entity_indexes)
|
68 |
final_entities_str = prepare_final_entities_str(final_entities)
|
69 |
if final_entities:
|
trauma/api/message/ai/prompts.py
CHANGED
@@ -186,7 +186,7 @@ You must determine whether the user's request pertains to the topic of medical f
|
|
186 |
## Instructions for Filling JSON
|
187 |
|
188 |
`User Request` pertains to the topic of medical facility recommendations (`is_valid = true`), if:
|
189 |
-
- The user describes the patient, for example, age, illness, treatment method, etc.
|
190 |
- The user describes the medical facility, for example, its location, postal code, treatment methods, supported age groups, etc.
|
191 |
|
192 |
[/INST]"""
|
|
|
186 |
## Instructions for Filling JSON
|
187 |
|
188 |
`User Request` pertains to the topic of medical facility recommendations (`is_valid = true`), if:
|
189 |
+
- The user describes the patient, for example, age, illness, treatment method, location, their case, etc.
|
190 |
- The user describes the medical facility, for example, its location, postal code, treatment methods, supported age groups, etc.
|
191 |
|
192 |
[/INST]"""
|