goelak commited on
Commit
0bd8e80
·
1 Parent(s): bcd6275

Fix cache, resize, examples

Browse files
Files changed (5) hide show
  1. app.py +2 -1
  2. prompt_instruction.py +8 -0
  3. report_examples.py +3 -3
  4. static/script.js +10 -5
  5. static/style.css +1 -0
app.py CHANGED
@@ -253,7 +253,8 @@ def predict():
253
  )
254
  result = model.predict(processed_data, model_id=model_id)
255
 
256
- if use_cache:
 
257
  cache_manager.cache_result(processed_data, result, sample_id)
258
 
259
  result["sanitized_input"] = processed_data
 
253
  )
254
  result = model.predict(processed_data, model_id=model_id)
255
 
256
+ # Cache if it's a predefined sample
257
+ if use_cache and sample_id:
258
  cache_manager.cache_result(processed_data, result, sample_id)
259
 
260
  result["sanitized_input"] = processed_data
prompt_instruction.py CHANGED
@@ -107,6 +107,14 @@ PROMPT_INSTRUCTION = textwrap.dedent(
107
  ```
108
 
109
  Within "attributes" each attribute should be a key-value pair as shown in the examples below. The attribute **"clinical_significance"** MUST be included for findings_body extractions and should be one of: **"normal"**, **"minor"**, **"significant"**, or **"not_applicable"** to indicate the importance of the finding.
 
 
 
 
 
 
 
 
110
 
111
  ---
112
 
 
107
  ```
108
 
109
  Within "attributes" each attribute should be a key-value pair as shown in the examples below. The attribute **"clinical_significance"** MUST be included for findings_body extractions and should be one of: **"normal"**, **"minor"**, **"significant"**, or **"not_applicable"** to indicate the importance of the finding.
110
+
111
+ Clinical significance levels:
112
+ - **"significant"**: Findings requiring medical attention, follow-up, or intervention. Any finding that would typically require follow-up imaging or clinical correlation should be marked as significant.
113
+ - **"minor"**: Benign or incidental findings without immediate clinical impact that do not require follow-up
114
+ - **"normal"**: No abnormality detected
115
+ - **"not_applicable"**: When significance cannot be determined
116
+
117
+ **Important**: Clinical significance must be based solely on medical content, not text quality or grammar. Minor typos or grammatical errors in the input should not affect significance classification.
118
 
119
  ---
120
 
report_examples.py CHANGED
@@ -466,7 +466,7 @@ def get_examples_for_model() -> list[lx.data.ExampleData]:
466
 
467
  The ventricular system is normal in size and configuration.
468
 
469
- No abnormal enhancement is seen.
470
 
471
  IMPRESSION:
472
  Normal brain MRI.
@@ -503,10 +503,10 @@ def get_examples_for_model() -> list[lx.data.ExampleData]:
503
  },
504
  ),
505
  lx.data.Extraction(
506
- extraction_text="No abnormal enhancement is seen.",
507
  extraction_class="findings_body",
508
  attributes={
509
- "section": "Enhancement",
510
  "clinical_significance": "normal",
511
  },
512
  ),
 
466
 
467
  The ventricular system is normal in size and configuration.
468
 
469
+ No midline shift is present.
470
 
471
  IMPRESSION:
472
  Normal brain MRI.
 
503
  },
504
  ),
505
  lx.data.Extraction(
506
+ extraction_text="No midline shift is present.",
507
  extraction_class="findings_body",
508
  attributes={
509
+ "section": "Brain Parenchyma",
510
  "clinical_significance": "normal",
511
  },
512
  ),
static/script.js CHANGED
@@ -86,7 +86,6 @@ document.addEventListener('DOMContentLoaded', function () {
86
 
87
  // Model dropdown elements
88
  const modelSelect = document.getElementById('model-select');
89
- const modelNameSpan = document.getElementById('model-name');
90
  const modelLink = document.getElementById('model-link');
91
 
92
  /**
@@ -109,14 +108,11 @@ document.addEventListener('DOMContentLoaded', function () {
109
  */
110
  function updateModelInfo() {
111
  const selectedModel = modelSelect.value;
112
- if (modelNameSpan)
113
- modelNameSpan.textContent = modelInfo[selectedModel].text;
114
  if (modelLink) modelLink.href = modelInfo[selectedModel].link;
115
  }
116
 
117
  if (modelSelect) {
118
  modelSelect.addEventListener('change', updateModelInfo);
119
- updateModelInfo();
120
  }
121
 
122
  // Cache optimization elements
@@ -574,7 +570,16 @@ document.addEventListener('DOMContentLoaded', function () {
574
 
575
  rawOutput.innerHTML = '';
576
 
577
- const formatter = new JSONFormatter(rawData, {
 
 
 
 
 
 
 
 
 
578
  hoverPreviewEnabled: true,
579
  animateOpen: false,
580
  animateClose: false,
 
86
 
87
  // Model dropdown elements
88
  const modelSelect = document.getElementById('model-select');
 
89
  const modelLink = document.getElementById('model-link');
90
 
91
  /**
 
108
  */
109
  function updateModelInfo() {
110
  const selectedModel = modelSelect.value;
 
 
111
  if (modelLink) modelLink.href = modelInfo[selectedModel].link;
112
  }
113
 
114
  if (modelSelect) {
115
  modelSelect.addEventListener('change', updateModelInfo);
 
116
  }
117
 
118
  // Cache optimization elements
 
570
 
571
  rawOutput.innerHTML = '';
572
 
573
+ // Check if JSONFormatter is available
574
+ if (typeof window.JSONFormatter === 'undefined') {
575
+ console.error('JSONFormatter library not loaded, using fallback');
576
+ rawOutput.innerHTML = '<pre style="white-space: pre-wrap; word-wrap: break-word;">' +
577
+ JSON.stringify(rawData, null, 2) + '</pre>';
578
+ rawOutput._jsonData = rawData;
579
+ return;
580
+ }
581
+
582
+ const formatter = new window.JSONFormatter(rawData, {
583
  hoverPreviewEnabled: true,
584
  animateOpen: false,
585
  animateClose: false,
static/style.css CHANGED
@@ -578,6 +578,7 @@ body {
578
  width: 100%;
579
  height: clamp(300px, 50vh, 500px);
580
  min-height: 300px;
 
581
  overflow: auto;
582
  border: 2px solid #e9ecef;
583
  border-radius: 8px;
 
578
  width: 100%;
579
  height: clamp(300px, 50vh, 500px);
580
  min-height: 300px;
581
+ resize: vertical;
582
  overflow: auto;
583
  border: 2px solid #e9ecef;
584
  border-radius: 8px;