Skip to content

GH-6322: Populate feedback and expose raw LLM response in evaluators#6330

Open
kuntal1461 wants to merge 1 commit into
spring-projects:mainfrom
kuntal1461:gh-6322-expose-evaluationresponse-from-llm
Open

GH-6322: Populate feedback and expose raw LLM response in evaluators#6330
kuntal1461 wants to merge 1 commit into
spring-projects:mainfrom
kuntal1461:gh-6322-expose-evaluationresponse-from-llm

Conversation

@kuntal1461

Copy link
Copy Markdown
Contributor

Fixes #6322.

Summary

FactCheckingEvaluator and RelevancyEvaluator were hardcoding the feedback field to empty string and discarding the LLM response text, making it impossible for users to understand why an evaluation passed or failed.

  • Populate feedback with the raw LLM response string in both evaluators
  • Add llm_raw_response to metadata for structured key-based access
  • Expose LLM_RAW_RESPONSE_METADATA_KEY constant on both classes so callers can read metadata without magic strings
  • Add .trim() to the yes/no check to tolerate trailing whitespace/newlines from LLMs (root cause of silent failures with custom prompts)
  • Null-safe handling of LLM response (empty string fallback)
  • Update evaluate() Javadoc to document the new feedback and metadata contract

No changes to EvaluationResponse, EvaluationRequest, or the Evaluator interface. Fully backward-compatible.

Test plan

  • whenLlmRespondsYesThenPassIsTrueAndFeedbackIsPopulated
  • whenLlmRespondsNoThenPassIsFalseAndFeedbackIsPopulated
  • whenLlmRespondsYesWithWhitespaceThenPassIsTrue
  • whenLlmReturnsNullThenPassIsFalseAndFeedbackIsEmpty
  • All pre-existing tests continue to pass (13/13)

@kuntal1461 kuntal1461 force-pushed the gh-6322-expose-evaluationresponse-from-llm branch 2 times, most recently from 496f190 to 709babc Compare June 8, 2026 08:05
… in evaluators

FactCheckingEvaluator and RelevancyEvaluator were hardcoding the
feedback field to "" and discarding the LLM response text entirely.

- Set feedback to the raw LLM response string in both evaluators
- Add llm_raw_response entry to metadata for structured key-based access
- Expose LLM_RAW_RESPONSE_METADATA_KEY constant on both classes so
  callers can read metadata without magic strings
- Add .strip() to the yes/no check to tolerate trailing whitespace/newlines
  from LLMs, fixing silent failures with custom prompts
- Null-safe handling of LLM response (empty string fallback)
- Update evaluate() Javadoc to document the new feedback/metadata contract
- Add unit tests covering yes, no, whitespace trim, and null LLM responses

Signed-off-by: kuntal1461 <kuntal.1461@gmail.com>
@kuntal1461 kuntal1461 force-pushed the gh-6322-expose-evaluationresponse-from-llm branch from 709babc to 9d2b444 Compare June 8, 2026 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose EvaluationResponse from LLM

1 participant