Stable state
This commit is contained in:
+5
-1
@@ -150,7 +150,8 @@ class RAGManager:
|
||||
self, query: str, top_k: int = 5, summarize: bool = False
|
||||
) -> List[ContextUpdate]:
|
||||
"""
|
||||
Retrieves the top-K most relevant snippets for a given query.
|
||||
Retrieves the top-K most relevant snippets for a given query,
|
||||
filtering for those with a similarity score > 0.7.
|
||||
"""
|
||||
if not self.index:
|
||||
print("Index not initialized. Please ingest documents first.")
|
||||
@@ -160,6 +161,9 @@ class RAGManager:
|
||||
retriever = self.index.as_retriever(similarity_top_k=top_k)
|
||||
nodes = retriever.retrieve(query)
|
||||
|
||||
# Filter nodes by similarity score (threshold > 0.7)
|
||||
nodes = [node for node in nodes if node.score >= 0.7]
|
||||
|
||||
if summarize:
|
||||
return self.summarize_results(query, nodes)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user