from llama_index.core import VectorStoreIndex, Document from llama_index.core.settings import Settings from llama_index.embeddings.huggingface import HuggingFaceEmbedding import os CACHE_DIR = os.getenv("LLAMA_INDEX_CACHE_DIR", "/app/model_cache") embed_model = HuggingFaceEmbedding(model_name="all-MiniLM-L6-v2", cache_folder=CACHE_DIR) Settings.embed_model = embed_model Settings.llm = None def get_index_from_text(document_text: str): """ Builds an in-memory index from user input using local embeddings only. No LLM. """ doc = Document(text=document_text) return VectorStoreIndex.from_documents([doc])