feat: AIPlanner의 GLM 응답 처리 로직 개선
- content가 비어있거나 JSON 형태가 아닐 경우 reasoning_content를 우선 사용하도록 로직 개선 - JSON 유사성을 판단하는 헬퍼 함수 추가 및 기존 동작 유지 - 관련 단위 테스트 추가 및 README.md에 변경 사항 반영
This commit is contained in:
@@ -54,3 +54,18 @@ class TestAIPlannerParseJson(unittest.TestCase):
|
||||
extracted = self.planner._extract_glm_assistant_text(fake)
|
||||
self.assertIn('"current_goal":"g"', extracted)
|
||||
|
||||
def test_extract_glm_text_uses_reasoning_when_content_has_no_json(self):
|
||||
fake = {
|
||||
"choices": [
|
||||
{
|
||||
"finish_reason": "length",
|
||||
"message": {
|
||||
"content": "1. **Current State Analysis:**\n- Location: (0, 0)\n- Inventory: {...}",
|
||||
"reasoning_content": '{"thinking":"t","current_goal":"g","actions":[{"action":"explore","params":{"direction":"east","max_steps":1},"reason":"x"}],"after_this":"a"}',
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
extracted = self.planner._extract_glm_assistant_text(fake)
|
||||
self.assertIn('"current_goal":"g"', extracted)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user