# llama_index_utils.py from llama_index import SimpleDirectoryReader, GPTVectorStoreIndex _index = None def build_index(data_path="data/icd10cm_tabular_2025"): global _index if _index is None: docs = SimpleDirectoryReader(data_path).load_data() _index = GPTVectorStoreIndex.from_documents(docs) return _index def query_symptoms(prompt: str, top_k: int = 5): idx = build_index() qe = idx.as_query_engine(similarity_top_k=top_k) return qe.query(prompt)