async def retrieve(self, ctx: Context, ev: StartEvent) -> Optional[RetrieveEvent]:
        """Retrieve the relevant nodes for the query."""
        query_str = ev.get("query_str")
        retriever_kwargs = ev.get("retriever_kwargs", {})

        if query_str is None:
            return None

        if "index" not in ctx.data or "tavily_tool" not in ctx.data:
            raise ValueError(
                "Index and tavily tool must be constructed. Run with 'documents' and 'tavily_ai_apikey' params first."
            )

        retriever: BaseRetriever = ctx.data["index"].as_retriever(**retriever_kwargs)
        result = retriever.retrieve(query_str)
        ctx.data["retrieved_nodes"] = result
        ctx.data["query_str"] = query_str
        return RetrieveEvent(retrieved_nodes=result)
Retrieve the relevant nodes for the query.
llama-index-packs/llama-index-packs-corrective-rag/llama_index/packs/corrective_rag/base.py