async def eval_relevance(
        self, ctx: Context, ev: RetrieveEvent
    ) -> RelevanceEvalEvent:
        """Evaluate relevancy of retrieved documents with the query."""
        retrieved_nodes = ev.retrieved_nodes
        query_str = ctx.data["query_str"]

        relevancy_results = []
        for node in retrieved_nodes:
            relevancy = ctx.data["relevancy_pipeline"].run(
                context_str=node.text, query_str=query_str
            )
            relevancy_results.append(relevancy.message.content.lower().strip())

        ctx.data["relevancy_results"] = relevancy_results
        return RelevanceEvalEvent(relevant_results=relevancy_results)
Evaluate relevancy of retrieved documents with the query.
llama-index-packs/llama-index-packs-corrective-rag/llama_index/packs/corrective_rag/base.py