Spaces:
Sleeping
Sleeping
should resolve the `ModuleNotFoundError` in the Hugging Face Space while maintaining the local development setup
Browse files- app.py +1 -1
- src/app.py +1 -1
- src/parse_tabular.py +19 -21
app.py
CHANGED
|
@@ -2,4 +2,4 @@
|
|
| 2 |
from src.app import demo
|
| 3 |
|
| 4 |
if __name__ == "__main__":
|
| 5 |
-
demo.launch(server_name="0.0.0.0", server_port=7860
|
|
|
|
| 2 |
from src.app import demo
|
| 3 |
|
| 4 |
if __name__ == "__main__":
|
| 5 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|
src/app.py
CHANGED
|
@@ -5,7 +5,7 @@ import gradio as gr
|
|
| 5 |
from llama_index.core import Settings
|
| 6 |
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
|
| 7 |
from llama_index.llms.llama_cpp import LlamaCPP
|
| 8 |
-
from parse_tabular import create_symptom_index
|
| 9 |
import json
|
| 10 |
import psutil
|
| 11 |
from typing import Tuple, Dict
|
|
|
|
| 5 |
from llama_index.core import Settings
|
| 6 |
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
|
| 7 |
from llama_index.llms.llama_cpp import LlamaCPP
|
| 8 |
+
from .parse_tabular import create_symptom_index # Use relative import
|
| 9 |
import json
|
| 10 |
import psutil
|
| 11 |
from typing import Tuple, Dict
|
src/parse_tabular.py
CHANGED
|
@@ -2,8 +2,8 @@ import xml.etree.ElementTree as ET
|
|
| 2 |
import json
|
| 3 |
import sys
|
| 4 |
import os
|
| 5 |
-
from llama_index.core import
|
| 6 |
-
from llama_index.
|
| 7 |
|
| 8 |
# Update path constants
|
| 9 |
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
|
|
@@ -53,27 +53,25 @@ def main(xml_path=DEFAULT_XML_PATH):
|
|
| 53 |
print(f"Wrote {len(icd_to_description)} code entries to {out_path}")
|
| 54 |
|
| 55 |
def create_symptom_index():
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
Document(
|
| 69 |
-
text=f"ICD-10 Code {code}: {desc}",
|
| 70 |
-
metadata={"code": code}
|
| 71 |
)
|
| 72 |
-
|
| 73 |
-
|
| 74 |
|
| 75 |
-
|
| 76 |
-
|
|
|
|
| 77 |
|
| 78 |
# Move this outside the main() function
|
| 79 |
symptom_index = None
|
|
|
|
| 2 |
import json
|
| 3 |
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__))
|
|
|
|
| 53 |
print(f"Wrote {len(icd_to_description)} code entries to {out_path}")
|
| 54 |
|
| 55 |
def create_symptom_index():
|
| 56 |
+
"""Create and return symptom index from ICD-10 data."""
|
| 57 |
+
try:
|
| 58 |
+
# Load documents from data directory
|
| 59 |
+
documents = SimpleDirectoryReader(
|
| 60 |
+
input_dir="data",
|
| 61 |
+
filename_as_id=True
|
| 62 |
+
).load_data()
|
| 63 |
+
|
| 64 |
+
# Create vector store index
|
| 65 |
+
index = VectorStoreIndex.from_documents(
|
| 66 |
+
documents,
|
| 67 |
+
show_progress=True
|
|
|
|
|
|
|
|
|
|
| 68 |
)
|
| 69 |
+
|
| 70 |
+
return index
|
| 71 |
|
| 72 |
+
except Exception as e:
|
| 73 |
+
print(f"Error creating symptom index: {e}")
|
| 74 |
+
raise
|
| 75 |
|
| 76 |
# Move this outside the main() function
|
| 77 |
symptom_index = None
|