Skip to content
Merged
10 changes: 9 additions & 1 deletion giskard/rag/metrics/correctness.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,21 @@ def __call__(self, question_sample: dict, answer: AgentAnswer) -> dict:
temperature=0,
format="json_object",
)
return parse_json_output(

json_output = parse_json_output(
out.content,
llm_client=llm_client,
keys=["correctness", "correctness_reason"],
caller_id=self.__class__.__name__,
)

if "correctness" in json_output and not isinstance(json_output["correctness"], bool):
raise LLMGenerationError(
f"Error in correctness evaluation: {json_output['correctness']}. Please make sure the agent answer is correctly formatted."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switching to repr is better so we can differentiate "True" from True, also

Suggested change
f"Error in correctness evaluation: {json_output['correctness']}. Please make sure the agent answer is correctly formatted."
f"Error in correctness evaluation: {repr(json_output['correctness'])}. Please make sure the agent answer is correctly formatted. Correctness value should be of boolean type."
)

return json_output

except Exception as err:
raise LLMGenerationError("Error while evaluating the agent") from err

Expand Down
Loading