Skip to content

Commit b25da54

Browse files
authored
bugfix: result json after doing evaluate has wrong characters in Korean language (Azure#40464)
1 parent 67e187b commit b25da54

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_evaluate/_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def _write_output(path: Union[str, os.PathLike], data_dict: Any) -> None:
241241
p = p / DEFAULT_EVALUATION_RESULTS_FILE_NAME
242242

243243
with open(p, "w", encoding=DefaultOpenEncoding.WRITE) as f:
244-
json.dump(data_dict, f)
244+
json.dump(data_dict, f, ensure_ascii=False)
245245

246246
print(f'Evaluation results saved to "{p.resolve()}".\n')
247247

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"query":"태양에서 가장 가까운 행성은?","response":"태양에서 가장 가까운 행성은 수성입니다.","ground_truth":"태양에서 가장 가까운 행성은 수성(Mercury)입니다. 수성은 태양계의 첫 번째 행성으로, 태양에 가장 가까운 궤도를 돌고 있습니다"}

sdk/evaluation/azure-ai-evaluation/tests/unittests/test_evaluate.py

+23
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ def questions_answers_file():
9090
def questions_answers_basic_file():
9191
return _get_file("questions_answers_basic.jsonl")
9292

93+
@pytest.fixture
94+
def questions_answers_korean_file():
95+
return _get_file("questions_answers_korean.jsonl")
96+
9397

9498
def _target_fn(query):
9599
"""An example target function."""
@@ -851,3 +855,22 @@ def test_target_failure_error_message(self, questions_file):
851855
)
852856

853857
assert "Evaluation target failed to produce any results. Please check the logs at " in str(exc_info.value)
858+
859+
def test_evaluate_korean_characters_result(self, questions_answers_korean_file):
860+
output_path = "eval_test_results_korean.jsonl"
861+
862+
result = evaluate(
863+
data=questions_answers_korean_file,
864+
evaluators={"g": F1ScoreEvaluator()},
865+
output_path=output_path,
866+
)
867+
868+
assert result is not None
869+
870+
with open(questions_answers_korean_file, "r", encoding="utf-8") as f:
871+
first_line = f.readline()
872+
data_from_file = json.loads(first_line)
873+
874+
assert result["rows"][0]["inputs.query"] == data_from_file["query"]
875+
876+
os.remove(output_path)

0 commit comments

Comments
 (0)