Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
femto committed Nov 9, 2024
1 parent 47637b5 commit f78b427
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/actions/test_action_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,30 @@ def test_normalize_response_json_string3(llm_action_node):
assert parsed_result["correct"] is True
assert parsed_result["score"] == 0.9

def test_normalize_response_json_string4(llm_action_node):
# 测试JSON字符串输入
json_input = r'''
```json
{
"feedback": "abc"xx"def",
"correct": true,
"score": 0.9
}
```
'''

result = llm_action_node.normalize_response(json_input)
# 验证返回的是提取并格式化后的JSON字符串
assert isinstance(result, str)
# 确保可以被解析回JSON对象
print(result)
parsed_result = json.loads(result)
assert "feedback" in parsed_result
assert "correct" in parsed_result
assert "score" in parsed_result
assert parsed_result["correct"] is True
assert parsed_result["score"] == 0.9

def test_normalize_response_dict_with_answer(llm_action_node):
# 测试包含answer字段的字典
input_dict = {"answer": "test answer"}
Expand Down

0 comments on commit f78b427

Please sign in to comment.