{"record":{"id":"cc5c2ef3492b2b6d","repo":"run-llama/llama_index","slug":"retrieved-texts-must-be-provided","errorCode":null,"errorMessage":"Retrieved texts must be provided","messagePattern":"Retrieved texts must be provided","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/evaluation/retrieval/metrics.py","lineNumber":478,"sourceCode":"    def _get_agg_func(self, agg: Literal[\"max\", \"median\", \"mean\"]) -> Callable:\n        \"\"\"Get agg func.\"\"\"\n        return _AGG_FUNC[agg]\n\n    def compute(\n        self,\n        query: Optional[str] = None,\n        expected_ids: Optional[List[str]] = None,\n        retrieved_ids: Optional[List[str]] = None,\n        expected_texts: Optional[List[str]] = None,\n        retrieved_texts: Optional[List[str]] = None,\n        agg: Literal[\"max\", \"median\", \"mean\"] = \"max\",\n        **kwargs: Any,\n    ) -> RetrievalMetricResult:\n        \"\"\"Compute metric.\"\"\"\n        del expected_texts  # unused\n\n        if retrieved_texts is None:\n            raise ValueError(\"Retrieved texts must be provided\")\n\n        results = self._client.rerank(\n            model=self.model,\n            top_n=len(\n                retrieved_texts\n            ),  # i.e. get a rank score for each retrieved chunk\n            query=query,\n            documents=retrieved_texts,\n        )\n        relevance_scores = [r.relevance_score for r in results.results]\n        agg_func = self._get_agg_func(agg)\n\n        return RetrievalMetricResult(\n            score=agg_func(relevance_scores), metadata={\"agg\": agg}\n        )\n\n\nMETRIC_REGISTRY: Dict[str, Type[BaseRetrievalMetric]] = {","sourceCodeStart":460,"sourceCodeEnd":496,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/evaluation/retrieval/metrics.py#L460-L496","documentation":"Raised by CohereRerankRelevancyMetric.compute when retrieved_texts is None. This metric scores relevancy by sending the retrieved chunks to the Cohere rerank API, so unlike id-based metrics (hit-rate, MRR, precision) it requires the actual text of each retrieved node; expected_texts is explicitly deleted as unused.","triggerScenarios":"Calling RetrieverEvaluator with include_retrieved_text not enabled (so node texts are never populated), or calling metric.compute(retrieved_ids=[...]) without retrieved_texts — any evaluation run that supplies only ids where the cohere_rerank_relevancy metric is registered.","commonSituations":"Copying a RetrieverEvaluator setup from an example that used hit_rate/mrr and adding cohere_rerank_relevancy without also enabling text capture; programmatic eval harnesses that build kwargs generically and skip text fields.","solutions":["Construct the evaluator with RetrieverEvaluator(..., include_cohere_rerank=True) / include_retrieved_text=True so retrieved_texts is populated, or","Call compute() explicitly with retrieved_texts=[node.get_content() for node in retrieved_nodes].","Verify your metric list: if you cannot supply texts, use id-based metrics ('hit_rate', 'mrr', 'precision', 'recall', 'ap', 'ndcg') instead."],"exampleFix":"# before\nresult = await metric.compute(query=q, retrieved_ids=ids)  # retrieved_texts omitted\n\n# after\nresult = await metric.compute(\n    query=q,\n    retrieved_ids=ids,\n    retrieved_texts=[n.get_content() for n in retrieved_nodes],\n)","handlingStrategy":"validation","validationCode":"retrieved_texts = [n.get_content() for n in retrieved_nodes]\nif not retrieved_texts or any(t is None for t in retrieved_texts):\n    raise RuntimeError(\"retrieved_texts required for cohere_rerank_relevancy\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always enable include_retrieved_text when RetrieverEvaluator metrics include cohere_rerank_relevancy.","Standardize your eval harness to pass both ids and texts for every metric.","Reserve cohere_rerank_relevancy for runs where node text is available."],"tags":["validation","evaluation","cohere","missing-argument"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}