from llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext
from llama_index import LangchainEmbedding
from langchain.embeddings.huggingface import HuggingFaceEmbeddings
from llama_setup import llm

def setup_memory():
    documents = SimpleDirectoryReader("./Data").load_data()
    embed_model = LangchainEmbedding(
        HuggingFaceEmbeddings(model_name="thenlper/gte-large")
    )

    service_context = ServiceContext.from_defaults(
        chunk_size=256,
        llm=llm,
        embed_model=embed_model
    )

    index = VectorStoreIndex.from_documents(documents, service_context=service_context)
    return index.as_query_engine(), embed_model, service_context

query_engine, embed_model, service_context = setup_memory()

langchain.embeddings.huggingface.HuggingFaceEmbeddings
[((429, 507), 'llama_index.ServiceContext.from_defaults', 'ServiceContext.from_defaults', ([], {'chunk_size': '(256)', 'llm': 'llm', 'embed_model': 'embed_model'}), '(chunk_size=256, llm=llm, embed_model=embed_model)\n', (457, 507), False, 'from llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext\n'), ((551, 626), 'llama_index.VectorStoreIndex.from_documents', 'VectorStoreIndex.from_documents', (['documents'], {'service_context': 'service_context'}), '(documents, service_context=service_context)\n', (582, 626), False, 'from llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext\n'), ((345, 399), 'langchain.embeddings.huggingface.HuggingFaceEmbeddings', 'HuggingFaceEmbeddings', ([], {'model_name': '"""thenlper/gte-large"""'}), "(model_name='thenlper/gte-large')\n", (366, 399), False, 'from langchain.embeddings.huggingface import HuggingFaceEmbeddings\n'), ((255, 286), 'llama_index.SimpleDirectoryReader', 'SimpleDirectoryReader', (['"""./Data"""'], {}), "('./Data')\n", (276, 286), False, 'from llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext\n')]