def load_chunks_from_index()

in demo-python/code/vector-quantization-and-storage/lib/embeddings.py [0:0]


def load_chunks_from_index():
    load_dotenv(override=True)
    endpoint = os.getenv("AZURE_SEARCH_SERVICE_ENDPOINT")
    key = os.getenv("AZURE_SEARCH_ADMIN_KEY")
    index = os.getenv("AZURE_SEARCH_INDEX")
    search_client = SearchClient(endpoint, index, AzureKeyCredential(key))
    content = []
    for doc in search_client.search(search_text="", top=1000, select="chunk_id,chunk,title"):
        content.append({"id": doc["chunk_id"], "chunk": doc["chunk"], "title": doc["title"], "embedding": doc["vector"]})
    with open(content_path, "w") as f:
        json.dump(content, f)