feat: enhance AIPlanner payload structure for LM Studio compatibility by including 'input' field and improve response content extraction methods
This commit is contained in:
37
tests/test_ai_planner_lmstudio_compat.py
Normal file
37
tests/test_ai_planner_lmstudio_compat.py
Normal 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()
|
||||
Reference in New Issue
Block a user