From 6d2a3d6ac54c7b1ece4f809918ace7720c59052a Mon Sep 17 00:00:00 2001 From: Oleksandr Kozachuk Date: Fri, 24 Mar 2023 17:42:56 +0100 Subject: [PATCH] Add a test for the fix functionality. --- tests/test_ai.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/test_ai.py b/tests/test_ai.py index b9763d7..839436b 100644 --- a/tests/test_ai.py +++ b/tests/test_ai.py @@ -41,6 +41,28 @@ You always try to say something positive about the current day and the Fjærkroa print(f"\n{response}") self.assertAIResponse(response, AIResponse('test', True, None, None, False)) + async def test_fix1(self) -> None: + old_config = self.bot.airesponder.config + config = {k: v for k, v in old_config.items()} + config['fix-model'] = 'gpt-3.5-turbo' + config['fix-description'] = 'You are an AI which fixes JSON documents. User send you JSON document, possibly invalid, and you fix it as good as you can and return as answer' + self.bot.airesponder.config = config + response = await self.bot.airesponder.send(AIMessage("lala", "who are you?")) + self.bot.airesponder.config = old_config + print(f"\n{response}") + self.assertAIResponse(response, AIResponse('test', True, None, None, False)) + + async def test_fix2(self) -> None: + old_config = self.bot.airesponder.config + config = {k: v for k, v in old_config.items()} + config['fix-model'] = 'gpt-3.5-turbo' + config['fix-description'] = 'You are an AI which fixes JSON documents. User send you JSON document, possibly invalid, and you fix it as good as you can and return as answer' + self.bot.airesponder.config = config + response = await self.bot.airesponder.send(AIMessage("lala", "Can I access Apple Music API from Python?")) + self.bot.airesponder.config = old_config + print(f"\n{response}") + self.assertAIResponse(response, AIResponse('test', True, None, None, False)) + async def test_history(self) -> None: self.bot.airesponder.history = [] response = await self.bot.airesponder.send(AIMessage("lala", "which date is today?"))