{"record":{"id":"6ef8044832b9da39","repo":"run-llama/llama_index","slug":"contexts-and-response-must-be-provided-6ef804","errorCode":null,"errorMessage":"contexts and response must be provided","messagePattern":"contexts and response must be provided","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/evaluation/multi_modal/faithfulness.py","lineNumber":146,"sourceCode":"        if \"eval_template\" in prompts:\n            self._eval_template = prompts[\"eval_template\"]\n        if \"refine_template\" in prompts:\n            self._refine_template = prompts[\"refine_template\"]\n\n    def evaluate(\n        self,\n        query: Union[str, None] = None,\n        response: Union[str, None] = None,\n        contexts: Union[Sequence[str], None] = None,\n        image_paths: Union[List[str], None] = None,\n        image_urls: Union[List[str], None] = None,\n        **kwargs: Any,\n    ) -> EvaluationResult:\n        \"\"\"Evaluate whether the response is faithful to the multi-modal contexts.\"\"\"\n        del query  # Unused\n        del kwargs  # Unused\n        if contexts is None or response is None:\n            raise ValueError(\"contexts and response must be provided\")\n\n        context_str = \"\\n\\n\".join(contexts)\n        fmt_prompt = self._eval_template.format(\n            context_str=context_str, query_str=response\n        )\n\n        image_nodes: List[Union[ImageBlock, TextBlock]] = []\n\n        if image_paths:\n            image_nodes.extend(\n                [ImageBlock(path=Path(image_path)) for image_path in image_paths]\n            )\n        if image_urls:\n            image_nodes.extend([ImageBlock(url=image_url) for image_url in image_urls])\n\n        image_nodes.append(TextBlock(text=fmt_prompt))\n\n        response_obj = self._multi_modal_llm.chat(","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/evaluation/multi_modal/faithfulness.py#L128-L164","documentation":"Thrown by MultiModalFaithfulnessEvaluator.evaluate (sync) when contexts or response is None. The evaluator joins contexts into a prompt string and queries the multi-modal LLM with the response plus image blocks, so both text inputs are mandatory (query is discarded).","triggerScenarios":"Calling evaluator.evaluate(response=r, contexts=None) or evaluate(response=None, contexts=ctxs, image_paths=[...]); commonly when image paths/URLs are supplied but the text contexts were forgotten.","commonSituations":"Mixing up the signature — passing only image_paths/image_urls and omitting contexts; response objects that stringify to None after a failed generation; multimodal pipelines where text context extraction was skipped for image-only documents.","solutions":["Pass both text fields: evaluator.evaluate(response=str(r), contexts=[\"...\"], image_paths=[...]).","If a document is image-only, still supply a minimal non-None contexts entry (e.g. a caption or placeholder string) plus the response.","Validate inputs before calling: skip or log items lacking response or contexts."],"exampleFix":"# before\nresult = evaluator.evaluate(response=r, image_paths=paths)  # contexts missing\n\n# after\nresult = evaluator.evaluate(\n    response=str(r), contexts=texts or [\"\"], image_paths=paths\n)","handlingStrategy":"validation","validationCode":"if response is None or contexts is None:\n    raise ValueError(\"multi-modal faithfulness needs response and text contexts\")\nresult = evaluator.evaluate(response=str(response), contexts=list(contexts), image_paths=paths)","typeGuard":"def mm_evaluable(response, contexts) -> bool:\n    return response is not None and contexts is not None","tryCatchPattern":null,"preventionTips":["Remember image_paths/image_urls supplement — never replace — the text contexts and response.","Use a small wrapper that validates the triple (response, contexts, images) before calling evaluate."],"tags":["multi-modal","faithfulness","input-validation"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}