gpaasch commited on
Commit
2d413a5
·
1 Parent(s): e27189d

improved system prompt and container logs

Browse files
Files changed (2) hide show
  1. app.py +6 -4
  2. services/indexing.py +8 -8
app.py CHANGED
@@ -34,10 +34,12 @@ print("Symptom index built successfully. Ready for queries.", flush=True)
34
 
35
  # ========== Prompt template ==========
36
  SYSTEM_PROMPT = (
37
- "You are a medical assistant helping a user narrow down to the most likely ICD-10 code. "
38
- "At each turn, either ask one focused clarifying question (e.g. 'Is your cough dry or productive?') "
39
- "or if you have enough information, provide a final JSON with fields: {\"diagnoses\": [...], "
40
- "\"confidences\": [...], \"follow_up\": [...]}. Output must be valid JSON with no trailing commas. Your output MUST be strictly valid JSON, starting with '{' and ending with '}', with no extra text outside the JSON."
 
 
41
  )
42
 
43
  # ========== Generator handler ==========
 
34
 
35
  # ========== Prompt template ==========
36
  SYSTEM_PROMPT = (
37
+ "You are a medical assistant helping a user find the most relevant ICD-10 code based on their symptoms.\n",
38
+ "At each turn, determine the top three most relevant ICD-10 codes based on input from the user.\n",
39
+ "Additionally, provide a 1 through 100 score of how confident you are in the relevancy of each code.\n",
40
+ "Continually ask questions to the user to raise or lower your confidence of each code.\n",
41
+ "Replace low-confidence codes with new ones as you learn more.\n",
42
+ "Your goal is to find the most relevant codes with high confidence.\n",
43
  )
44
 
45
  # ========== Generator handler ==========
services/indexing.py CHANGED
@@ -1,20 +1,20 @@
1
- from llama_index.core import SimpleDirectoryReader, VectorStoreIndex
2
- from llama_index.core import Settings
 
 
3
 
4
  def create_symptom_index():
5
- """Create and return symptom index from ICD-10 data."""
6
- print("build_symptom_index: Loading documents from data directory...")
7
  documents = SimpleDirectoryReader(
8
  input_dir="data",
9
  filename_as_id=True
10
  ).load_data()
11
-
12
- print(f"build_symptom_index: Creating vector index from {len(documents)} documents...")
13
  symptom_index = VectorStoreIndex.from_documents(
14
  documents,
15
  show_progress=True
16
  )
17
-
18
- print("build_symptom_index: Symptom index created successfully")
19
 
 
20
  return symptom_index
 
1
+ # at top of file
2
+ import logging, sys
3
+ logging.basicConfig(stream=sys.stdout, level=logging.INFO, force=True)
4
+ logger = logging.getLogger(__name__)
5
 
6
  def create_symptom_index():
7
+ logger.info("build_symptom_index: Loading documents from data directory…")
 
8
  documents = SimpleDirectoryReader(
9
  input_dir="data",
10
  filename_as_id=True
11
  ).load_data()
12
+
13
+ logger.info(f"build_symptom_index: Creating vector index from {len(documents)} documents")
14
  symptom_index = VectorStoreIndex.from_documents(
15
  documents,
16
  show_progress=True
17
  )
 
 
18
 
19
+ logger.info("build_symptom_index: Symptom index created successfully")
20
  return symptom_index