command/bin/bash -lc "nl -ba retrieval/rag_retriever.py | sed -n '1,80p'"
exit code 0
Output: 1 from langchain_chroma import Chroma 2 from langchain_core.documents import Document 3 from embeddings.embeddings import Embeddings 4 import os 5 6 class RAGRetriever: 7 def __init__(self, vector_db_path: str, embedding_model_name: str, api_key: str): 8 self.vector_db_path = vector_db_path 9 embeddings = Embeddings(model_name=embedding_model_name, api_key=api_key) 10 self.embedding_function = embeddings.get_embedding_function() 11 self.db = Chroma(persist_directory=self.vector_db_path, embedding_function=self.embedding_function) 12 13 def query(self, query_text: str, k: int = 4): 14 # compute similarity between embeddings of query and of pdf text chunks 15 results = self.db.similarity_search_with_score(query_text, k=k) 16 return results 17 18 def format_results(self, results: list[tuple[Document, float]]): 19 context_blocks = [] 20 sources = [] 21 22 for index, (doc, _score) in enumerat