Spaces:
Running
Running
enhanced logging
Browse files- src/app.py +4 -0
- src/parse_tabular.py +8 -3
src/app.py
CHANGED
@@ -143,6 +143,10 @@ def process_speech(new_transcript, history):
|
|
143 |
if not new_transcript:
|
144 |
return history
|
145 |
|
|
|
|
|
|
|
|
|
146 |
try:
|
147 |
# First, get potential diagnoses based on symptoms
|
148 |
diagnosis_query = f"""
|
|
|
143 |
if not new_transcript:
|
144 |
return history
|
145 |
|
146 |
+
if not isinstance(new_transcript, str):
|
147 |
+
print(f"Warning: Expected string transcript, got {type(new_transcript)}")
|
148 |
+
new_transcript = str(new_transcript)
|
149 |
+
|
150 |
try:
|
151 |
# First, get potential diagnoses based on symptoms
|
152 |
diagnosis_query = f"""
|
src/parse_tabular.py
CHANGED
@@ -4,6 +4,10 @@ import sys
|
|
4 |
import os
|
5 |
from llama_index.core import SimpleDirectoryReader, VectorStoreIndex
|
6 |
from llama_index.core import Settings
|
|
|
|
|
|
|
|
|
7 |
|
8 |
# Update path constants
|
9 |
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
|
@@ -55,22 +59,23 @@ def main(xml_path=DEFAULT_XML_PATH):
|
|
55 |
def create_symptom_index():
|
56 |
"""Create and return symptom index from ICD-10 data."""
|
57 |
try:
|
58 |
-
|
59 |
documents = SimpleDirectoryReader(
|
60 |
input_dir="data",
|
61 |
filename_as_id=True
|
62 |
).load_data()
|
63 |
|
64 |
-
|
65 |
index = VectorStoreIndex.from_documents(
|
66 |
documents,
|
67 |
show_progress=True
|
68 |
)
|
69 |
|
|
|
70 |
return index
|
71 |
|
72 |
except Exception as e:
|
73 |
-
|
74 |
raise
|
75 |
|
76 |
# Move this outside the main() function
|
|
|
4 |
import os
|
5 |
from llama_index.core import SimpleDirectoryReader, VectorStoreIndex
|
6 |
from llama_index.core import Settings
|
7 |
+
import logging
|
8 |
+
|
9 |
+
logging.basicConfig(level=logging.INFO)
|
10 |
+
logger = logging.getLogger(__name__)
|
11 |
|
12 |
# Update path constants
|
13 |
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
|
|
|
59 |
def create_symptom_index():
|
60 |
"""Create and return symptom index from ICD-10 data."""
|
61 |
try:
|
62 |
+
logger.info("Loading documents from data directory...")
|
63 |
documents = SimpleDirectoryReader(
|
64 |
input_dir="data",
|
65 |
filename_as_id=True
|
66 |
).load_data()
|
67 |
|
68 |
+
logger.info(f"Creating vector index from {len(documents)} documents...")
|
69 |
index = VectorStoreIndex.from_documents(
|
70 |
documents,
|
71 |
show_progress=True
|
72 |
)
|
73 |
|
74 |
+
logger.info("Symptom index created successfully")
|
75 |
return index
|
76 |
|
77 |
except Exception as e:
|
78 |
+
logger.error(f"Failed to create symptom index: {str(e)}")
|
79 |
raise
|
80 |
|
81 |
# Move this outside the main() function
|