feat: enhance AIPlanner payload structure for LM Studio compatibility by including 'input' field and improve response content extraction methods

This commit is contained in:
21in7
2026-03-27 20:04:18 +09:00
parent 4b104f2146
commit 2cf072d38c
4 changed files with 114 additions and 12 deletions

View File

@@ -0,0 +1,37 @@
import unittest
from ai_planner import AIPlanner
class TestAIPlannerLMStudioCompat(unittest.TestCase):
def test_build_chat_payload_includes_input_for_responses_compat(self):
payload = AIPlanner._build_chat_payload("hello")
self.assertIn("messages", payload)
self.assertIn("input", payload)
self.assertEqual(payload["input"], "hello")
self.assertEqual(payload["messages"][1]["content"], "hello")
def test_extract_response_content_supports_message_content(self):
data = {
"message": {
"content": (
'{"thinking":"t","current_goal":"g","actions":[],"after_this":"a"}'
)
}
}
content = AIPlanner._extract_response_content(data)
self.assertIn('"current_goal":"g"', content)
def test_extract_response_content_supports_output_text(self):
data = {
"output_text": (
'{"thinking":"t","current_goal":"g","actions":[],"after_this":"a"}'
)
}
content = AIPlanner._extract_response_content(data)
self.assertIn('"after_this":"a"', content)
if __name__ == "__main__":
unittest.main()