File size: 266 Bytes
2e8d6bf
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
from langchain_chroma import Chroma


TOP_K_RETRIEVAL = 3


def retrieve_chunks(vectorstore: Chroma, query: str, top_k: int = TOP_K_RETRIEVAL) -> list[str]:
    results = vectorstore.similarity_search(query, k=top_k)
    return [doc.page_content for doc in results]