from sentence_transformers import SentenceTransformer import numpy as np import time from embedder import get_model # Use the preloaded model from embedder instead of creating a new instance def retrieve_chunks(index, texts, query, k=5): model = get_model() # Use the preloaded model query_vec = model.encode([query]) distances, indices = index.search(np.array(query_vec), k) results = [texts[i] for i in indices[0]] return results