Spaces:
Sleeping
Sleeping
frabbani commited on
Commit ·
b02426b
1
Parent(s): 6f2136f
context added .....
Browse files- agent_v2.py +21 -10
agent_v2.py
CHANGED
|
@@ -1047,7 +1047,7 @@ SKIN ANALYSIS SYNTHESIS GUIDE (from SCIN Classifier):
|
|
| 1047 |
|
| 1048 |
Use the above analysis to inform your response about the skin condition."""
|
| 1049 |
elif state.skin_analysis_result and state.skin_analysis_result.get("status") == "success":
|
| 1050 |
-
# Even without an LLM prompt, if skin analysis was done, note it
|
| 1051 |
skin_synthesis_context = """
|
| 1052 |
IMPORTANT: The user uploaded a skin image for analysis. The skin analysis results are included
|
| 1053 |
in the collected information above. Your response should primarily focus on the skin analysis
|
|
@@ -1060,7 +1060,25 @@ findings, as the image upload indicates this is the user's primary concern."""
|
|
| 1060 |
NOTE: The user uploaded a skin image with this question. Even if the question seems generic
|
| 1061 |
(like "what are my conditions?"), they are asking about the SKIN CONDITION shown in the image.
|
| 1062 |
Prioritize the skin analysis results in your response."""
|
| 1063 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1064 |
# Format conversation history
|
| 1065 |
history_text = format_conversation_history(state.conversation_history)
|
| 1066 |
|
|
@@ -1094,14 +1112,7 @@ CRITICAL INSTRUCTIONS:
|
|
| 1094 |
- Be warm and supportive
|
| 1095 |
- Keep the response concise - the chart is already displayed visually
|
| 1096 |
|
| 1097 |
-
|
| 1098 |
-
- If skin analysis was performed, use the SKIN ANALYSIS SYNTHESIS GUIDE above to inform your response
|
| 1099 |
-
- Report the possible conditions with their likelihood levels (high/moderate/possible)
|
| 1100 |
-
- Mention if the user's reported symptoms match what the image analysis detected
|
| 1101 |
-
- ALWAYS emphasize this is FOR RESEARCH USE ONLY - NOT A DIAGNOSTIC TOOL
|
| 1102 |
-
- NEVER attempt to definitively diagnose any skin condition
|
| 1103 |
-
- ALWAYS recommend the patient consult a dermatologist for proper evaluation
|
| 1104 |
-
- Be supportive but clear that AI cannot replace professional dermatological evaluation
|
| 1105 |
|
| 1106 |
Answer:
|
| 1107 |
<end_of_turn>
|
|
|
|
| 1047 |
|
| 1048 |
Use the above analysis to inform your response about the skin condition."""
|
| 1049 |
elif state.skin_analysis_result and state.skin_analysis_result.get("status") == "success":
|
| 1050 |
+
# Even without an LLM prompt, if skin analysis was done successfully, note it
|
| 1051 |
skin_synthesis_context = """
|
| 1052 |
IMPORTANT: The user uploaded a skin image for analysis. The skin analysis results are included
|
| 1053 |
in the collected information above. Your response should primarily focus on the skin analysis
|
|
|
|
| 1060 |
NOTE: The user uploaded a skin image with this question. Even if the question seems generic
|
| 1061 |
(like "what are my conditions?"), they are asking about the SKIN CONDITION shown in the image.
|
| 1062 |
Prioritize the skin analysis results in your response."""
|
| 1063 |
+
|
| 1064 |
+
# Build skin instructions conditionally to prevent hallucination
|
| 1065 |
+
if state.skin_image_data and state.skin_analysis_result and state.skin_analysis_result.get("status") == "success":
|
| 1066 |
+
skin_instructions = """FOR SKIN-RELATED QUESTIONS:
|
| 1067 |
+
- Use the SKIN ANALYSIS SYNTHESIS GUIDE above to inform your response
|
| 1068 |
+
- Report the possible conditions with their likelihood levels (high/moderate/possible)
|
| 1069 |
+
- Mention if the user's reported symptoms match what the image analysis detected
|
| 1070 |
+
- ALWAYS emphasize this is FOR RESEARCH USE ONLY - NOT A DIAGNOSTIC TOOL
|
| 1071 |
+
- NEVER attempt to definitively diagnose any skin condition
|
| 1072 |
+
- ALWAYS recommend the patient consult a dermatologist for proper evaluation
|
| 1073 |
+
- Be supportive but clear that AI cannot replace professional dermatological evaluation"""
|
| 1074 |
+
else:
|
| 1075 |
+
skin_instructions = """IF THE USER IS ASKING ABOUT SKIN:
|
| 1076 |
+
- No skin image was uploaded and no skin analysis was performed.
|
| 1077 |
+
- Do NOT fabricate, assume, or describe any skin analysis results.
|
| 1078 |
+
- Do NOT say "the image analysis detected" or reference any conditions from an image.
|
| 1079 |
+
- Politely let the user know they need to upload a skin image using the 🔬 Skin Analysis button for analysis.
|
| 1080 |
+
- Do not describe what the analysis "would" show or speculate about conditions."""
|
| 1081 |
+
|
| 1082 |
# Format conversation history
|
| 1083 |
history_text = format_conversation_history(state.conversation_history)
|
| 1084 |
|
|
|
|
| 1112 |
- Be warm and supportive
|
| 1113 |
- Keep the response concise - the chart is already displayed visually
|
| 1114 |
|
| 1115 |
+
{skin_instructions}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1116 |
|
| 1117 |
Answer:
|
| 1118 |
<end_of_turn>
|