From b014df06b80823b7e1017e2734a99d99a7d98606 Mon Sep 17 00:00:00 2001 From: kswdev0 Date: Thu, 26 Mar 2026 11:04:38 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20GLM=20=EC=9D=91=EB=8B=B5=20content=20?= =?UTF-8?q?=EB=B9=84=EC=96=B4=EC=9E=88=EC=9D=84=20=EB=95=8C=20=EA=B2=BD?= =?UTF-8?q?=EA=B3=A0=20=EB=A9=94=EC=8B=9C=EC=A7=80=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20JSON=20=ED=8C=8C=EC=8B=B1=20=EC=8B=A4=ED=8C=A8=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - GLM 응답의 content가 비어있을 경우 경고 메시지를 출력하도록 로직 추가 - JSON 파싱 시 raw가 비어있을 경우 ValueError를 발생시켜 오류 처리를 강화 - 관련 문서 및 README.md에 변경 사항 반영 --- ai_planner.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ai_planner.py b/ai_planner.py index c67cc99..ef8a6fc 100644 --- a/ai_planner.py +++ b/ai_planner.py @@ -313,6 +313,18 @@ class AIPlanner: t_json0 = time.perf_counter() data = json.loads(raw_text) content = data["choices"][0]["message"]["content"].strip() + if not content: + # content가 비어있으면 이후 JSON 파서가 원인 파악이 어렵다. + # GLM_DEBUG=1에서 raw 응답 일부를 함께 보여준다. + if _glm_debug_enabled(): + finish_reason = data.get("choices", [{}])[0].get("finish_reason") + print( + "[경고] GLM 응답 content 비어있음 | " + f"finish_reason={finish_reason!r} | " + f"raw_preview={raw_text[:600]!r}" + ) + else: + print("[경고] GLM 응답 content가 비어있습니다. (GLM_DEBUG=1 시 raw_preview 출력)") t_json_done = time.perf_counter() dt_total = time.perf_counter() - t_total0 @@ -359,6 +371,9 @@ class AIPlanner: return self._plan_from_actions_array(loaded) except json.JSONDecodeError: pass + if not text: + raise ValueError("JSON 파싱 실패: raw가 비어있습니다.") + start = text.find("{") if start == -1: # GLM이 상단 레벨에서 JSON 배열(`[ ... ]`)로 응답하는 경우를 허용