Skip to content

Commit 97948e9

Browse files
committed
レスポンス内の<think>タグを処理するメソッドを追加し、LLMの応答をクリーンにする機能を実装
1 parent bfccb2e commit 97948e9

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

tests/real_integration/base_framework.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import logging
99
import os
10+
import re
1011
import subprocess
1112
import sys
1213
import tempfile
@@ -385,6 +386,13 @@ def _add_pr_comment_impl(self, pr_number: int, comment: str) -> dict[str, Any]:
385386
msg = "サブクラスは_add_pr_comment_implを実装する必要があります"
386387
raise NotImplementedError(msg)
387388

389+
def _process_think_tags(self, resp: str) -> str:
390+
"""レスポンス内の<think>タグを処理し、クリーンなレスポンスを返す."""
391+
think_matches = re.findall(r"<think>(.*?)</think>", resp, flags=re.DOTALL)
392+
for think_content in think_matches:
393+
self.logger.info("Processing <think> tag content: %s", think_content.strip())
394+
return resp
395+
388396
def llm_verify_output(self, actual_output: str, expected_criteria: str) -> bool:
389397
"""LLMを使用して出力が基準を満たすかを確認する(非決定的検証用).
390398
@@ -416,7 +424,9 @@ def llm_verify_output(self, actual_output: str, expected_criteria: str) -> bool:
416424
"""
417425

418426
try:
419-
response = llm_client.chat(prompt)
427+
llm_client.send_user_message(prompt)
428+
response = llm_client.get_response()
429+
response = self._process_think_tags(response)
420430

421431
# 応答を解析
422432
lines = response.strip().split("\n")

0 commit comments

Comments
 (0)