Repository navigation
Conversation
AnswerRelevancyEvaluator.__init__ never set self._refine_template, but _get_prompts() reads it, so the public PromptMixin API get_prompts() raised AttributeError on every invocation. Add the documented refine_template parameter and initialize it with a default template, matching FaithfulnessEvaluator, RelevancyEvaluator, and ContextRelevancyEvaluator.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
AnswerRelevancyEvaluator.get_prompts()raisedAttributeErroron every invocation._get_prompts()returns a"refine_template"entry read fromself._refine_template(llama-index-core/llama_index/core/evaluation/answer_relevancy.py:94onmain), but__init__never initialized that attribute, and the constructor accepted norefine_templateargument — even though the class docstring already documents one (answer_relevancy.py:62onmain) and_update_prompts()already handles the key (answer_relevancy.py:101-102).Since
PromptMixin.get_prompts()is the public prompt-management API, this evaluator was the only prompt-bearing evaluator in the package whoseget_prompts()crashed unconditionally:The fix adds the documented
refine_templateconstructor parameter and initializesself._refine_templatewith a newDEFAULT_REFINE_TEMPLATEfallback, mirroring how every sibling evaluator in the same package already wires up its templates:FaithfulnessEvaluator(faithfulness.py:122,139-143)RelevancyEvaluator(relevancy.py:65,77-81)ContextRelevancyEvaluator(context_relevancy.py:89,107-111)The new parameter is optional and defaults to
None, so existing callers are unaffected. The only construction site inside the repo (tools/eval_query_engine.py:75) passes no arguments.No linked issue — reproduced directly on current
main.New Package?
Did I fill in the
tool.llamahubsection in thepyproject.tomland provide a detailed README.md for my new integration or package?Version Bump?
Did I bump the version in the
pyproject.tomlfile of the package I am updating? (Except for thellama-index-corepackage)Type of Change
How Has This Been Tested?
New
llama-index-core/tests/evaluation/test_answer_relevancy.pycoversget_prompts(), therefine_templateconstructor parameter, andupdate_prompts(). On unpatchedmainthe first two tests fail —test_get_promptswithAttributeError: 'AnswerRelevancyEvaluator' object has no attribute '_refine_template'andtest_init_refine_templatewithTypeError: ... unexpected keyword argument 'refine_template'. With this change all three pass.Run from
llama-index-core/:Suggested Checklist:
uv run make format; uv run make lintto appease the lint gods