moazx commited on
Commit
5021fcb
·
1 Parent(s): 79e52d8

Update the Agent and the assessment responses

Browse files
Files changed (2) hide show
  1. core/agent.py +8 -9
  2. core/hbv_assessment.py +49 -32
core/agent.py CHANGED
@@ -103,15 +103,14 @@ When responding to eligibility-related questions, **always start the answer with
103
  - First-line: Entecavir (ETV), Tenofovir Disoproxil Fumarate (TDF), Tenofovir Alafenamide (TAF)
104
  - Alternative agents and PEG-IFN when indicated
105
 
106
- **RESPONSE STYLE:**
107
- - Start directly with clinical answers - NO procedural statements ("I will retrieve...", "Let me search...", "Please wait...")
108
- - Use structured, concise clinical format: brief introductory sentence organized data (tables, bullets, or structured lists) → clinical notes where relevant
109
- - Target 200-400 words (standard queries) or 400-600 words (complex questions)
110
- - Prioritize key information first, use hierarchical formatting (headers, bullets), include specific clinical parameters when relevant
111
- - Use precise medical terminology appropriate for experts
112
- - Answer only what's asked - no tangential information
113
 
114
- **STRUCTURED CLINICAL FORMAT (FOLLOW THESE EXAMPLES):**
115
 
116
  Example 1 - Tabular data with clinical notes:
117
  "Chronic HBV is classified into five phases using HBsAg/HBeAg status, HBV DNA, ALT, and liver inflammation.
@@ -261,7 +260,7 @@ For patient eligibility: Patient Profile (HBsAg, HBeAg, HBV DNA, ALT, Fibrosis)
261
  **IMPORTANT**: You may format the answer into structured sections (Eligibility, Treatment, Monitoring, etc.), but the content inside MUST remain strictly source-based. Do not add information from general knowledge to fill gaps in the structure.
262
 
263
  **FORMATTING:**
264
- Use **bold** for critical points/drugs, headers (###) for organization, bullets/numbered lists for sequences, tables for comparisons, blockquotes (>) for direct quotes. Include specific numeric values and thresholds.
265
 
266
  **SAFETY:**
267
  For emergencies (acute liver failure, hepatic encephalopathy, severe bleeding, loss of consciousness), respond: "This is an emergency! Call emergency services immediately and seek urgent medical help." Educational information only - not a substitute for clinical judgment. Always respond in English.
 
103
  - First-line: Entecavir (ETV), Tenofovir Disoproxil Fumarate (TDF), Tenofovir Alafenamide (TAF)
104
  - Alternative agents and PEG-IFN when indicated
105
 
106
+ **RESPONSE STYLE (Concise):**
107
+ - Start directly with the clinical answer. NO procedural preambles (no "I will retrieve...", "Let me search...", etc.).
108
+ - Prefer short bullet lists over paragraphs. Keep to the point and answer only what is asked.
109
+ - Target 120–220 words for most answers; up to 300 words only if essential. Avoid tables unless explicitly requested.
110
+ - Prioritize key facts and recommendations first; include only necessary citations and parameters.
111
+ - Use precise medical terminology appropriate for experts; omit tangential background.
 
112
 
113
+ **STRUCTURED CLINICAL FORMAT (Compact):**
114
 
115
  Example 1 - Tabular data with clinical notes:
116
  "Chronic HBV is classified into five phases using HBsAg/HBeAg status, HBV DNA, ALT, and liver inflammation.
 
260
  **IMPORTANT**: You may format the answer into structured sections (Eligibility, Treatment, Monitoring, etc.), but the content inside MUST remain strictly source-based. Do not add information from general knowledge to fill gaps in the structure.
261
 
262
  **FORMATTING:**
263
+ Use brief headers and bullet points. Bold only the most critical terms (e.g., drugs, thresholds). Avoid tables and long examples unless the user asks. Include exact numeric values and page citations as required.
264
 
265
  **SAFETY:**
266
  For emergencies (acute liver failure, hepatic encephalopathy, severe bleeding, loss of consciousness), respond: "This is an emergency! Call emergency services immediately and seek urgent medical help." Educational information only - not a substitute for clinical judgment. Always respond in English.
core/hbv_assessment.py CHANGED
@@ -75,6 +75,7 @@ def clean_json_string(json_str: str) -> str:
75
  SASLT_GUIDELINES = """
76
  ===== TREATMENT RECOMMENDATIONS =====
77
 
 
78
  ### 1. INITIATION OF TREATMENT [SASLT 2021, p. 6]
79
 
80
  • Treatment indications should also take into account patient's age, health status, risk of HBV transmission, family history of HCC or cirrhosis and extrahepatic manifestations
@@ -83,11 +84,12 @@ SASLT_GUIDELINES = """
83
 
84
  • Patients with cirrhosis (compensated or decompensated), with any detectable HBV DNA level and regardless of ALT levels (Grade A)
85
 
86
- Patients with HBV DNA > 20,000 IU/mL and ALT > 2xULN, regardless of the degree of fibrosis (Grade B)
 
87
 
88
- • Patients with HBeAg-positive chronic HBV infection (persistently normal ALT and high HBV DNA levels) may be treated if they are > 30 years, regardless of the severity of liver histological lesions (Grade D)
89
 
90
- • Patients with chronic HBV infection (HBV DNA > 2,000 IU/mL, ALT > ULN), regardless of HBeAg status, and a family history of HCC or cirrhosis and extrahepatic manifestations (Grade D)
91
 
92
 
93
  ### 2. MANAGEMENT ALGORITHM [SASLT 2021, p. 6]
@@ -249,36 +251,51 @@ You MUST respond with a valid JSON object in this exact format:
249
  }}
250
  IMPORTANT JSON FORMATTING:
251
  - Return ONLY valid JSON without markdown code blocks
252
- - Use spaces instead of literal newlines within the "recommendations" string
253
- - Separate paragraphs with double spaces or use \\n for line breaks
254
- - Do NOT include literal newline characters in the JSON string values
255
- CRITICAL CITATION REQUIREMENTS:
256
- 1. The "recommendations" field must be a comprehensive narrative that includes:
257
- - Eligibility determination with rationale
258
- - Specific criteria met or not met from the guidelines
259
- - Treatment options if eligible (ETV, TDF, TAF as first-line agents)
260
- - Special considerations (pregnancy, immunosuppression, coinfections, etc.)
261
- - Any additional clinical notes
262
- - **References** section at the end listing all cited pages
263
- 2. EVERY statement in recommendations MUST include inline citations in this format:
264
- "[SASLT 2021, Page X]" where X is the specific page number
265
-
266
- 3. Example format:
267
- "Patient meets treatment criteria based on HBV DNA > 2,000 IU/mL, ALT > ULN, and moderate fibrosis (Grade A) [SASLT 2021, Page 12]. First-line antiviral agents including entecavir (ETV), tenofovir disoproxil fumarate (TDF), or tenofovir alafenamide (TAF) are recommended [SASLT 2021, Page 15]. Patient should be monitored for treatment response [SASLT 2021, Page 18].
268
-
269
- **References**
270
- SASLT 2021 Guidelines - Pages: 12, 15, 18
271
- (Treatment Eligibility Criteria, First-Line Antiviral Agents, Monitoring Protocols)"
272
- 4. ALWAYS cite the specific page number from the [Source: ..., Page: X] markers in the guidelines above
273
- 5. Include evidence grade (Grade A, B, C, D) when available in the guidelines
274
- 6. END the recommendations with a **References** section that lists all cited pages in ascending order with brief description of topics covered
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
275
  IMPORTANT:
276
- 1. Base your assessment ONLY on the SASLT 2021 guidelines provided
277
- 2. Make recommendations comprehensive and detailed
278
- 3. Cite page numbers after EVERY clinical statement or recommendation
279
- 4. Use the format [SASLT 2021, Page X] for all citations
280
- 5. Include a **References** section at the end listing all pages cited
281
- 6. Return ONLY the JSON object, no additional text
282
  """
283
 
284
 
 
75
  SASLT_GUIDELINES = """
76
  ===== TREATMENT RECOMMENDATIONS =====
77
 
78
+
79
  ### 1. INITIATION OF TREATMENT [SASLT 2021, p. 6]
80
 
81
  • Treatment indications should also take into account patient's age, health status, risk of HBV transmission, family history of HCC or cirrhosis and extrahepatic manifestations
 
84
 
85
  • Patients with cirrhosis (compensated or decompensated), with any detectable HBV DNA level and regardless of ALT levels (Grade A)
86
 
87
+ • HBV Eligibility Criteria:
88
+ •Patients with HBV DNA > 20,000 IU/mL and ALT > 2xULN, regardless of the degree of fibrosis (Grade B)
89
 
90
+ • Patients with HBeAg-positive chronic HBV infection (persistently normal ALT and high HBV DNA levels) may be treated if they are > 30 years, regardless of the severity of liver histological lesions (Grade D)
91
 
92
+ • Patients with chronic HBV infection (HBV DNA > 2,000 IU/mL, ALT > ULN), regardless of HBeAg status, and a family history of HCC or cirrhosis and extrahepatic manifestations (Grade D)
93
 
94
 
95
  ### 2. MANAGEMENT ALGORITHM [SASLT 2021, p. 6]
 
251
  }}
252
  IMPORTANT JSON FORMATTING:
253
  - Return ONLY valid JSON without markdown code blocks
254
+ - You MUST use "\\n" to indicate line breaks inside the "recommendations" string and format the content as clear bullet lists prefixed with "- ".
255
+ - Do NOT include literal newline characters. Use \\n for every new bullet or line.
256
+
257
+ STRUCTURE AND CONTENT OF "recommendations":
258
+ - Start with a section title: "Eligibility and Rationale:" followed by bullets.
259
+ - Then sections in this order, each as a header line and bulleted items below (all within the same string, separated by \\n):
260
+ - "Criteria Met/Not Met:"
261
+ - "First-line Treatment Options:"
262
+ - "Monitoring and Follow-up:"
263
+ - "Special Considerations:"
264
+ - "Additional Notes:"
265
+ - "References:"
266
+
267
+ BULLETING AND CITATIONS RULES:
268
+ - Put citations at the end of each bullet, not after every clause, using "[SASLT 2021, Page X]".
269
+ - Include evidence grade in the bullet when available (e.g., "(Grade A)") if present in the guideline text.
270
+ - Only cite pages present in the provided context (6–10). Cite the page that actually contains the information.
271
+
272
+ STRICT ACCURACY AND CONSISTENCY RULES:
273
+ - Do NOT contradict yourself. Ensure eligibility conclusion and rationale are consistent with all bullets.
274
+ - Use ONLY the provided SASLT 2021 content; do NOT add external knowledge.
275
+ - Numeric thresholds and wording must match the guideline text exactly when quoted or summarized.
276
+ - If info is not present in the provided pages, do not state it or cite it.
277
+
278
+ PAGE-TO-TOPIC MAPPING GUIDANCE (for correct citations):
279
+ - Page 6: Initiation of treatment, management algorithm, start of monitoring of untreated patients.
280
+ - Page 7: Monitoring of untreated patients (continuation), CHB treatment principles.
281
+ - Page 8: Treatment drugs/regimens (ETV, TDF, TAF), agents not recommended.
282
+ - Page 9: Special populations (HBV-HCV, HBV-HDV, HBV-HIV, immunocompromised).
283
+ - Page 10: Pregnancy-related recommendations (late pregnancy prophylaxis, breastfeeding, switching).
284
+
285
+ EXAMPLE OUTPUT STYLE (illustrative only; adapt to patient data):
286
+ - Eligibility and Rationale:\n- Eligible due to HBV DNA > 2,000 IU/mL with ALT > ULN and/or moderate fibrosis (Grade A) [SASLT 2021, Page 6]\n- Cirrhosis with any detectable HBV DNA warrants treatment regardless of ALT (Grade A) [SASLT 2021, Page 6]
287
+ - Criteria Met/Not Met:\n- HBV DNA level criterion: met (> 2,000 IU/mL) [SASLT 2021, Page 6]\n- ALT criterion: met (> ULN) [SASLT 2021, Page 6]\n- HBeAg-positive >30 years with high DNA and normal ALT (if applicable): met/not met (Grade D) [SASLT 2021, Page 6]
288
+ - First-line Treatment Options:\n- Start monotherapy with ETV, TDF, or TAF (Grade A) [SASLT 2021, Page 8]
289
+ - Monitoring and Follow-up:\n- If untreated, monitor per HBeAg status and DNA thresholds as specified [SASLT 2021, Pages 6–7]
290
+ - Special Considerations:\n- If coinfected with HCV and meeting HBV criteria, treat concurrently or before DAAs (Grade A) [SASLT 2021, Page 8]\n- If immunocompromised, initiate prophylaxis before immunosuppression (Grade A) [SASLT 2021, Page 9]\n- Pregnancy-specific actions per DNA threshold and timing (if applicable) [SASLT 2021, Page 10]
291
+ - References:\n- List all cited pages in ascending order with brief topic labels
292
+
293
  IMPORTANT:
294
+ 1. Base your assessment ONLY on the SASLT 2021 guidelines provided.
295
+ 2. Make recommendations concise, bulleted, and free of contradictions.
296
+ 3. Put a proper citation at the end of each bullet using the exact page that contains the information.
297
+ 4. End with a "References:" section listing the pages cited in ascending order with short topic labels.
298
+ 5. Return ONLY the JSON object, no additional text.
 
299
  """
300
 
301