from typing import Any
def score(
response_text: str,
input_text: str,
kwargs: dict[str, Any],
) -> dict:
def evaluate_response(response):
"""
Check if the JSON object specifies the price of the house.
Args:
response (str): The LLM's response text
Returns:
float: 1.0 if the JSON object specifies the price, 0.0 otherwise
"""
import json
try:
# Attempt to parse the response as JSON
house_data = json.loads(response)
# Check if the 'price' key exists in the JSON object
if 'price' in house_data:
return 1.0
return 0.0
except json.JSONDecodeError:
# Return 0.0 if the response is not valid JSON
return 0.0
final_score = evaluate_response(response_text)
return {"score": final_score, "explanation": ""}